Created
February 11, 2013 17:55
-
-
Save sahib/4756163 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Description: | |
# Script to query mpd's status and download a cover of the currently playing | |
# song on song-change and execute a user-defined command to show the cover. | |
# (e.g. with notify-send, by default with a image viewer for testing) | |
# Feel free to make your customizations here. | |
MPD_SERVER="--port 6600 --host localhost" # For default case. | |
COVER_PATH="/tmp/cover.png" # This should be okay for most. | |
CACHE_DIRP="/tmp" # You should set this to ~/.cache e.g | |
NOTIFY_COMMAND="sxiv $COVER_PATH" # Place your command here (notify-send e.g.) | |
function mpc_send { | |
mpc $MPD_SERVER $* | |
} | |
function show_metadata { | |
glyrc cover \ | |
--write $COVER_PATH \ | |
--artist $1 --album $2 --title $3 \ | |
--cache $CACHE_DIRP \ | |
--verbosity 0 | |
$NOTIFY_COMMAND | |
} | |
function get_tag { | |
mpc_send current --format "%"$1"%" | |
} | |
while [ 1 ] | |
do | |
psong=$(mpc_send current) | |
event=$(mpc_send idle) | |
if [[ $event = "player" ]] | |
then | |
if [[ $psong != $(mpc_send current) ]] | |
then | |
show_metadata $(get_tag artist) $(get_tag album) $(get_tag title) | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment