Skip to content

Instantly share code, notes, and snippets.

@themoonisacheese
Created February 9, 2023 10:47
Show Gist options
  • Save themoonisacheese/b38c56dd6d343a7a8891a820db00f881 to your computer and use it in GitHub Desktop.
Save themoonisacheese/b38c56dd6d343a7a8891a820db00f881 to your computer and use it in GitHub Desktop.
#!/bin/bash
#themoonisacheese@poggers.website
#nowplaying: display currently playing song based on playerctl info (dbus)
#dependencies: playerctl: https://github.com/altdesktop/playerctl
#use with watch (man watch) for live-ish updates ex: watch -tc nowplaying
#spawn a window specifically for a widget-style thing ex: uxterm -bg "#333" -fg "#fff" -geometry 100x1 -e watch -wtc nowplaying
STATUS=`playerctl status 2>&1`
if [[ $STATUS == 'No players found' ]]; then
echo "No music"
else
TITLE=`playerctl metadata title`
ARTIST=`playerctl metadata artist`
echo -ne "Current track: \033[1m$ARTIST - $TITLE\033[0m"
if [[ $STATUS == "Playing" ]]; then
echo ""
else
echo " ($STATUS)"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment