dotfiles/.local/bin/statusbar/music

17 lines
489 B
Bash
Executable File

#!/bin/sh
if mpc status | grep -q '\[paused\]' || [ "$(mpc status | wc -l)" -eq 1 ]; then
printf '\n'
exit
fi
if [ $( mpc status | grep '\[playing\]' | wc -l ) -eq 1 ]; then
full_length="$(mpc status | sed "/^volume:/d" | tac | sed -e "s/\\[paused\\].*//g;s/\\[playing\\].*//g" | tr -d '\n' | sed -e "s/$/ /g")"
#remove full directory structure if no title present and too long
if [ ${#full_length} -gt 40 ]; then
echo "${full_length##*/}"
else
echo "$full_length"
fi
exit
fi