Files
nix/scripts/waybar-music-status.sh
2025-10-11 14:08:24 +03:00

17 lines
587 B
Bash
Executable File

#!/bin/bash
function _sanitize {
sed -r "s/(^[ ]*)|([ ]*$)//g" | sed -r 's/\&/\&/g' | sed -r 's/\"/\"/g' | sed -r "s/'/\'/g"
}
# {{artist}} — {{title}}
SONGNAME="$( playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata -f "{{artist}} — {{title}}" | _sanitize )"
ALBUMNAME="$( playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata album | _sanitize )"
if [ ${#SONGNAME} -gt 0 ] ; then
printf "{\"text\": \" $SONGNAME\", \"tooltip\": \"$ALBUMNAME\", \"class\":\"music\" }"
else
printf "{\"text\": \"\", \"tooltip\": \" \", \"class\":\"invisible\" }"
fi