diff options
| author | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
|---|---|---|
| committer | JaKooLit <jimmielovejay@gmail.com> | 2023-10-22 15:55:57 +0900 |
| commit | c222e1bad2ba5e779c3af5b956906c82ead43271 (patch) | |
| tree | a5253e0861c200ff90354169e1f67ef42ebf0ef9 /config/hypr/scripts/MediaCtrl.sh | |
| parent | bb0be21dba7980fc1c047eaba24eda1712bd7f31 (diff) | |
Initial upload
Diffstat (limited to 'config/hypr/scripts/MediaCtrl.sh')
| -rwxr-xr-x | config/hypr/scripts/MediaCtrl.sh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/config/hypr/scripts/MediaCtrl.sh b/config/hypr/scripts/MediaCtrl.sh new file mode 100755 index 00000000..f9611523 --- /dev/null +++ b/config/hypr/scripts/MediaCtrl.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +music_icon="$HOME/.config/dunst/icons/music.png" + +# Play the next track +play_next() { + playerctl next + show_music_notification +} + +# Play the previous track +play_previous() { + playerctl previous + show_music_notification +} + +# Toggle play/pause +toggle_play_pause() { + playerctl play-pause + show_music_notification +} + +# Stop playback +stop_playback() { + playerctl stop + dunstify -r 123 -i "$music_icon" "Playback Stopped" +} + +# Display Dunst notification with song information +show_music_notification() { + status=$(playerctl status) + if [[ "$status" == "Playing" ]]; then + song_title=$(playerctl metadata title) + song_artist=$(playerctl metadata artist) + dunstify -r 123 -i "$music_icon" "Now Playing:" "$song_title\nby $song_artist" + elif [[ "$status" == "Paused" ]]; then + dunstify -r 123 -i "$music_icon" "Playback Paused" + fi +} + +# Get media control action from command line argument +case "$1" in + "--nxt") + play_next + ;; + "--prv") + play_previous + ;; + "--pause") + toggle_play_pause + ;; + "--stop") + stop_playback + ;; + *) + echo "Usage: $0 [--nxt|--prv|--pause|--stop]" + exit 1 + ;; +esac |
