Last active
October 10, 2023 16:39
-
-
Save bonnebulle/93b148d9f391ed3d2a98f0ed7ce5a71c to your computer and use it in GitHub Desktop.
Change track with playerctl + notify !
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# DO Change track with playerctl + notify ! | |
# SOURCE https://github.com/altdesktop/playerctl#printing-properties-and-metadata | |
# SOURCE https://www.reddit.com/r/archlinux/comments/5np6ne/comment/dcdopbk/?utm_source=share&utm_medium=web2x&context=3 | |
# DEP https://github.com/vlevit/notify-send.sh | |
# DEP https://github.com/altdesktop/playerctl | |
# USE Keyboard_media_key | |
# OPT play, playpause, next, previous, infos | |
status=$(playerctl status) | |
if [[ $1 == "next" ]] | |
then | |
playerctl next | |
sleep 2 | |
elif [[ $1 == "previous" ]] | |
then | |
playerctl previous | |
sleep 2 | |
elif [[ $1 == "play" ]] | |
then | |
playerctl play | |
elif [[ $1 == "playpause" ]] | |
then | |
playerctl play-pause | |
elif [[ $1 == "infos" ]] | |
then | |
# DO NOTHING continue | |
echo "infos" | |
elif [[ $status = "Playing" || $status = "Paused" ]] | |
then | |
# DO NOTHING continue | |
playerctl play | |
else | |
playerctl play | |
fi | |
artist=$(playerctl metadata --format "{{ lc(artist) }}") | |
album=$(playerctl metadata --format "{{ lc(album) }}") | |
title=$(playerctl metadata --format "{{ lc(title) }}") | |
url=$(playerctl metadata mpris:artUrl | cut -c 1-) | |
# echo $status | |
if [[ $status == "Playing" && $1 != "playpause" ]] # IF Playing and NOT go pausing | |
then | |
notify-send.sh -t 6000 -i "$url" "$title" "→ $artist \n↦ $album" | |
elif [[ $status == "Paused" && $1 == "playpause" ]] # IF Paused and go palying | |
then | |
notify-send.sh -t 6000 -i "$url" "$title" "→ $artist \n↦ $album" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment