Adds delay to mediactrl
This commit is contained in:
parent
6d141a1a3b
commit
9d145716ff
1 changed files with 33 additions and 32 deletions
|
|
@ -6,56 +6,57 @@ music_icon="$HOME/.config/swaync/icons/music.png"
|
||||||
|
|
||||||
# Play the next track
|
# Play the next track
|
||||||
play_next() {
|
play_next() {
|
||||||
playerctl next
|
playerctl next
|
||||||
show_music_notification
|
show_music_notification
|
||||||
}
|
}
|
||||||
|
|
||||||
# Play the previous track
|
# Play the previous track
|
||||||
play_previous() {
|
play_previous() {
|
||||||
playerctl previous
|
playerctl previous
|
||||||
show_music_notification
|
show_music_notification
|
||||||
}
|
}
|
||||||
|
|
||||||
# Toggle play/pause
|
# Toggle play/pause
|
||||||
toggle_play_pause() {
|
toggle_play_pause() {
|
||||||
playerctl play-pause
|
playerctl play-pause
|
||||||
show_music_notification
|
show_music_notification
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stop playback
|
# Stop playback
|
||||||
stop_playback() {
|
stop_playback() {
|
||||||
playerctl stop
|
playerctl stop
|
||||||
notify-send -e -u low -i $music_icon " Playback:" " Stopped"
|
notify-send -e -u low -i $music_icon " Playback:" " Stopped"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Display notification with song information
|
# Display notification with song information
|
||||||
show_music_notification() {
|
show_music_notification() {
|
||||||
status=$(playerctl status)
|
sleep 0.5s
|
||||||
if [[ "$status" == "Playing" ]]; then
|
status=$(playerctl status)
|
||||||
song_title=$(playerctl metadata title)
|
if [[ "$status" == "Playing" ]]; then
|
||||||
song_artist=$(playerctl metadata artist)
|
song_title=$(playerctl metadata title)
|
||||||
notify-send -e -u low -i $music_icon "Now Playing:" "$song_title by $song_artist"
|
song_artist=$(playerctl metadata artist)
|
||||||
elif [[ "$status" == "Paused" ]]; then
|
notify-send -e -u low -i $music_icon "Now Playing:" "$song_title by $song_artist"
|
||||||
notify-send -e -u low -i $music_icon " Playback:" " Paused"
|
elif [[ "$status" == "Paused" ]]; then
|
||||||
fi
|
notify-send -e -u low -i $music_icon " Playback:" " Paused"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get media control action from command line argument
|
# Get media control action from command line argument
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--nxt")
|
"--nxt")
|
||||||
play_next
|
play_next
|
||||||
;;
|
;;
|
||||||
"--prv")
|
"--prv")
|
||||||
play_previous
|
play_previous
|
||||||
;;
|
;;
|
||||||
"--pause")
|
"--pause")
|
||||||
toggle_play_pause
|
toggle_play_pause
|
||||||
;;
|
;;
|
||||||
"--stop")
|
"--stop")
|
||||||
stop_playback
|
stop_playback
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 [--nxt|--prv|--pause|--stop]"
|
echo "Usage: $0 [--nxt|--prv|--pause|--stop]"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue