summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAudric Schiltknecht <audric.schiltknecht@viagenie.ca>2019-06-11 08:35:54 -0400
committerAudric Schiltknecht <audric.schiltknecht@viagenie.ca>2019-07-18 15:40:13 -0400
commit098d1ae889afe5921fa0c0d6e17178d70c0cd263 (patch)
treec0bd3b714644f585b27e03054ed1e9ac9a7962cf /bin
parentdf6cddf79543abd8f6504fc5a3e9ce0f5ab444b7 (diff)
downloaddotfiles-098d1ae889afe5921fa0c0d6e17178d70c0cd263.tar.gz
dotfiles-098d1ae889afe5921fa0c0d6e17178d70c0cd263.tar.bz2
dotfiles-098d1ae889afe5921fa0c0d6e17178d70c0cd263.zip
lock_screen: New script to pause player and lock screen
Use the MediaPlayer2 DBus interface.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lock_screen14
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