Dotfiles/i3/blocks/mediaplayer
2018-05-04 11:10:11 +01:00

29 lines
466 B
Bash
Executable file

#!/usr/bin/sh
COMMAND="playerctl --player=$BLOCK_INSTANCE"
case $BLOCK_BUTTON in
1) $COMMAND previous ;;
3) $COMMAND next ;;
esac
if [ "$($COMMAND status)" = "Playing" ]; then
colour="#00FF00"
else
colour="#FF8000"
fi
title=$($COMMAND metadata title | sed "s/\&/\&/g")
artist=$($COMMAND metadata artist | sed "s/\&/\&/g")
if [ "$title" != "(null)" ]; then
ret="<span foreground='$colour'>$title</span>"
ret="$ret - $artist"
echo "$ret";
fi