helm/os/arch/.config/panel/lemons/music.sh
2016-11-03 18:46:23 +01:00

27 lines
752 B
Bash
Executable file

#!/usr/bin/env bash
while :
do
output=$(mpc --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]") echo -n "SP" ;;
"[paused]") echo -n "Sp" ;;
*) echo -n "S " ;;
esac
echo "$title^$artist^$album^$seek^$perc"
else
echo "S"
fi
sleep 1
done