helm/os/+arch/.config/panel/lemons/disabled/music
2017-04-25 23:29:43 -04:00

48 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env dash
. $(dirname $0)/../panel-config
progress_bar() {
BAR_SIZE=${2:-26}
C1="%{F${COLOR_6}}-%{F-}"
C2="%{F${COLOR_DIM}}-%{F-}"
DELIM=
echo "$1" | SIZE=$BAR_SIZE CHAR1="$C1" CHAR2="$C2" SEP='' START="$DELIM" END="$DELIM" mkb
}
while :; do
if ! pgrep mpd >/dev/null; then
sleep 5
continue
fi
output=$(mpc -h $HOME/.config/mpd/mpd.sock --format ";%title%;%artist%;%album%")
if echo $output | grep "^;" 2>&1 >/dev/null; then
# title=$(echo "$output" | head -1 | cut -d';' -f2)
# artist=$(echo "$output" | head -1 | cut -d';' -f3)
# album=$(echo "$output" | head -1 | cut -d';' -f4)
seek=$(echo "$output" | awk 'NR==2 {print $3}')
perc=$(echo "$output" | awk 'NR==2 {print $4}' | tr -d '()')
state=$(echo "$output" | awk 'NR==2 {print $1}')
case "$state" in
"[playing]") icon="%{F${COLOR_2}}${ICON_PLAY}%{F-}" ;;
"[paused]") icon="%{F${COLOR_4}}${ICON_PAUSE}%{F-}" ;;
*) icon="" ;;
esac
if [ -n "$icon" ]
then
# song="$title - $artist"
# [ -n "$album" ] && song="$song ($album)"
echo "S%{B${COLOR_ALTBG}} $icon ${seek%/*} $(progress_bar $perc 16) ${seek#*/} %{B-} "
fi
else
echo "S"
fi
sleep 1
done
# vim:set ft=sh: