Skip to content

Instantly share code, notes, and snippets.

@mithereal
Created August 14, 2015 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mithereal/df11e1b4521d91956970 to your computer and use it in GitHub Desktop.
Save mithereal/df11e1b4521d91956970 to your computer and use it in GitHub Desktop.
#!/bin/bash
while sleep 55
do
players_list=$(gdbus call --session --dest org.freedesktop.DBus \
--object-path / --method org.freedesktop.DBus.ListNames | \
awk 'BEGIN { RS=","; } /org.mpris.MediaPlayer2./ { gsub(/[\[\]()\x27]/, ""); print $1; }')
for player in $players_list
do
state=$(gdbus call --session \
--dest $player \
--object-path /org/mpris/MediaPlayer2 \
--method org.freedesktop.DBus.Properties.Get \
"org.mpris.MediaPlayer2.Player" \
"PlaybackStatus")
fullscreen=$(gdbus call --session \
--dest $player \
--object-path /org/mpris/MediaPlayer2 \
--method org.freedesktop.DBus.Properties.Get \
"org.mpris.MediaPlayer2" \
"Fullscreen")
if [ "$state" = "(<'Playing'>,)" -a "$fullscreen" = "(<true>,)" ]
then
echo $player $state $fullscreen send signal
xscreensaver-command -deactivate
break
else
echo $player $state $fullscreen
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment