From 8571b74c829b8369eb7c11bb4cf7cbf52aa10d0b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 5 Dec 2015 12:59:58 +1300 Subject: Add mplrc-notify-send example --- README.markdown | 5 +++-- mpdlrc-notify-send | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 mpdlrc-notify-send diff --git a/README.markdown b/README.markdown index 2e7fdc4..2cacbef 100644 --- a/README.markdown +++ b/README.markdown @@ -10,8 +10,9 @@ Needs `Net::MPD` and a few core Perl packages. Expects to find lyrics named This code is not great. It will be improved. It needs to be more configurable from environment variables or options, for one thing. -This could maybe be used with `dzen` or a similar desktop notification tool to -display lyrics in a corner as you work on other things. +This could maybe be used with `libnotify` or a similar desktop notification +tool to display lyrics in a corner as you work on other things. I've included a +simple Bash wrapper around `notify-send(1)` which works for me. An LRC file I made for Darkthrone's "To Walk The Infernal Fields" from their 1993 album "Under a Funeral Moon" is included for testing. diff --git a/mpdlrc-notify-send b/mpdlrc-notify-send new file mode 100755 index 0000000..977cf1b --- /dev/null +++ b/mpdlrc-notify-send @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Check we have the two programs we need +hash mpdlrc || exit +hash notify-send || exit + +# Read the priority and timeout from the environment, or set default values +priority=${MPDLC_PRIORITY:-low} +timeout=${MPDLC_TIMEOUT:-2000} + +# Loop over each line output by mpdlrc (which will need to be somewhere in your +# PATH) and pass it to notify-send(1) +while IFS= read -r lyric ; do + notify-send -u "$priority" -t "$timeout" "$lyric" +done < <(mpdlrc) + -- cgit v1.2.3