helm/os/arch/.config/panel/lemons/music

47 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env dash
2016-11-02 16:58:47 -07:00
2016-11-06 16:40:02 -08:00
. $(dirname $0)/../panel-config
ICON_PLAY=""
ICON_PAUSE=""
# ICON_STOP=""
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
}
2016-11-02 16:58:47 -07:00
while :
do
output=$(mpc --format ";%title%;%artist%;%album%")
if echo $output | grep "^;" 2>&1 >/dev/null
then
2016-11-06 16:40:02 -08:00
# title=$(echo "$output" | head -1 | cut -d';' -f2)
# artist=$(echo "$output" | head -1 | cut -d';' -f3)
# album=$(echo "$output" | head -1 | cut -d';' -f4)
2016-11-02 16:58:47 -07:00
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
2016-11-06 16:40:02 -08:00
"[playing]") icon="%{F${COLOR_2}}${ICON_PLAY}%{F-}" ;;
"[paused]") icon="%{F${COLOR_4}}${ICON_PAUSE}%{F-}" ;;
*) icon="" ;;
2016-11-02 16:58:47 -07:00
esac
2016-11-06 16:40:02 -08:00
if [ -n "$icon" ]
then
# song="$title - $artist"
# [ -n "$album" ] && song="$song ($album)"
echo "%{B${COLOR_ALTBG}} $icon ${seek%/*} $(progress_bar $perc 16) ${seek#*/} %{B-} "
fi
2016-11-02 16:58:47 -07:00
else
echo "S"
fi
sleep 1
done