diff options
-rwxr-xr-x | bin/lock_screen | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bin/lock_screen b/bin/lock_screen new file mode 100755 index 0000000..1aa83d8 --- /dev/null +++ b/bin/lock_screen @@ -0,0 +1,14 @@ +#!/bin/sh + +# Retrieve playback status +dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus' | grep Playing -q +playback_status=$? # 0 if playing, 1 otherwise + +# Stop spotify +dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause + +i3lock -n + +if [ $playback_status -eq 0 ] ; then + dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play +fi |