Create a gist now

Instantly share code, notes, and snippets.

@phpmoli /nosaver.sh
Last active Aug 23, 2016

stop running screen saver when playing full screen video or tab in a chrome browser
#!/bin/bash
#run from kde system settings/system administration/startup and shutdown/autostart/add script
while true ; do
id="$(DISPLAY=:0.0 xprop -root _NET_ACTIVE_WINDOW)"
id=${id:40:9}
if DISPLAY=:0.0 xprop -id "$id" | grep -F '_NET_WM_STATE_FULLSCREEN' >/dev/null && DISPLAY=:0.0 xprop -id "$id" | grep -E 'WM_CLASS\(STRING\) = ("google\-chrome", "google-chrome"|"Navigator", "Iceweasel"|"plugin\-container", "Plugin\-container")' >/dev/null ; then
if which qdbus >/dev/null ; then
qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity >/dev/null
qdbus org.kde.ksmserver /ScreenSaver SimulateUserActivity >/dev/null
fi
if which xscreensaver-command >/dev/null ; then xscreensaver-command -deactivate >/dev/null ; fi
if xset -q | grep -F 'DPMS is Enabled' >/dev/null ; then
xset -dpms
xset dpms
fi
fi
sleep 50
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment