Skip to content

Instantly share code, notes, and snippets.

@ohhskar
Last active September 19, 2021 14:02
Show Gist options
  • Save ohhskar/efe71e82337ed54b9aa704d3df28d2ae to your computer and use it in GitHub Desktop.
Save ohhskar/efe71e82337ed54b9aa704d3df28d2ae to your computer and use it in GitHub Desktop.
Spotifyd Notification using Playerctl and notify-send.sh
#!/bin/bash
if [ "$PLAYER_EVENT" = "start" ] || [ "$PLAYER_EVENT" = "change" ];
then
trackName=$(playerctl metadata title)
artistAndAlbumName=$(playerctl metadata --format "{{ artist }} ({{ album }})")
notify-send -u low "$trackName" "$artistAndAlbumName "
fi
@greenbigfrog
Copy link

#!/bin/bash

if [ "$PLAYER_EVENT" = "start" ] || [ "$PLAYER_EVENT" = "change" ];
then
	trackName=$(playerctl -p spotifyd,%any metadata title)
	artistAndAlbumName=$(playerctl -p spotifyd,%any metadata --format "{{ artist }} ({{ album }})")

	notify-send -u low "$trackName" "$artistAndAlbumName "
fi

If you specify the -p flag to only select spotifyd, you won't end up having it display the metadata from eg your browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment