diff options
author | David Runge <david.runge@frqrec.com> | 2014-02-20 01:32:48 +0100 |
---|---|---|
committer | David Runge <david.runge@frqrec.com> | 2014-02-20 01:32:48 +0100 |
commit | 7fc113632736a80938bbcdfb73f19a61a85ab05f (patch) | |
tree | 321e257f3b5d07e3045678e18d64462a1bd5af1f | |
parent | d5019b72b1882e9d68e4224208b52c7628e7606a (diff) | |
download | dotfiles-7fc113632736a80938bbcdfb73f19a61a85ab05f.tar.gz dotfiles-7fc113632736a80938bbcdfb73f19a61a85ab05f.tar.bz2 dotfiles-7fc113632736a80938bbcdfb73f19a61a85ab05f.tar.xz dotfiles-7fc113632736a80938bbcdfb73f19a61a85ab05f.zip |
Adding script to switch off screensaver when certain programs are running
-rwxr-xr-x | bin/adjust_dpms | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/bin/adjust_dpms b/bin/adjust_dpms new file mode 100755 index 0000000..65f5e0d --- /dev/null +++ b/bin/adjust_dpms @@ -0,0 +1,48 @@ +#!/bin/bash +# Script to adjust dpms settings when running certain programs, +# that don't use fullscreen, but should not be "blanked" in between. +# Run as timed script with systemd from /etc/systemd/system/timer-minutely.target.wants + +export DISPLAY=:0 + +config="/home/dave/.config/dpms" +blankoff=0 + +# check for config file existence +if [[ -f $config ]];then + . /home/dave/.config/dpms +else + echo "Config file not readable $config" + exit 1 +fi + +# loop all pre-compiled programs and check for running instances +for i in "${programs[@]}" +do + pid=$(pidof $i) + re='^[0-9]+$' + if [[ $pid =~ $re ]]; then + echo "$i running ($pid)" + blankoff=1 + fi +done + +# loop all python2 run programs and check for running instances +for i in "${python2[@]}" +do + pid=$(pidof python2 $i) + re='^[0-9]+$' + if [[ $pid =~ $re ]]; then + echo "$i running ($pid)" + blankoff=1 + fi +done + +# if valuable programs are running, don't use screen blanking +if [ blankoff ]; then + echo "Some program requires screensaver to be off." + xset s off +else + xset s on +fi + |