diff options
author | David Runge <dave@sleepmap.de> | 2017-06-26 15:52:04 +0200 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2017-06-26 15:52:04 +0200 |
commit | f7aeb073e09c5118063108659550743c1bd04755 (patch) | |
tree | a336c6ddf001eff77ad2fcedb669f1f50e5e77f2 /bin/postpone-screensaver | |
parent | bd0dad221eabfcd94d0848d022c61e06b30843b9 (diff) | |
parent | 8b3300b9a7105fa34252c90e30e43296d04eeb39 (diff) | |
download | uenv-f7aeb073e09c5118063108659550743c1bd04755.tar.gz uenv-f7aeb073e09c5118063108659550743c1bd04755.tar.bz2 uenv-f7aeb073e09c5118063108659550743c1bd04755.tar.xz uenv-f7aeb073e09c5118063108659550743c1bd04755.zip |
Merge branch 'master' of sleepmap.de:software/uenv0.9
* 'master' of sleepmap.de:software/uenv:
README.rst: Adding working homepage link for XenGi.
bin/update-motd: Fix non-zero exit code in bashs safe mode.
user/postpone-screensaver.service: Moving executable to /usr/bin. scripts/{postpone-screensaver,update-motd}: moving to bin subfolder for better distinction from scripts.
scripts/update-motd,system/update-motd.service: Adding script to be called by update-motd.service instead of using so many sh invocations in the service file.
Diffstat (limited to 'bin/postpone-screensaver')
-rwxr-xr-x | bin/postpone-screensaver | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/bin/postpone-screensaver b/bin/postpone-screensaver new file mode 100755 index 0000000..7ece93d --- /dev/null +++ b/bin/postpone-screensaver @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Script to adjust dpms settings when running certain programs, +# that don't use fullscreen, but should not be "blanked" in between. + +export DISPLAY=:0.0 + +blankoff=0 +programs=( ${programs} ) +# loop all programs and check for running instances +for i in "${programs[@]}" +do + pid=$(pidof -x $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 -gt 0 ]; then + echo "Some program requires screensaver to be off." + # print currently set values for screensaver timeout to tmp file + echo "s $(xset q|grep timeout|awk '{print $2}') $(xset q|grep timeout|awk '{print $4}')" > $adjust_dpms + echo "dpms $(xset q|grep Standby|awk '{print $2}') $(xset q|grep Standby|awk '{print $4}') $(xset q|grep Standby|awk '{print $6}')" >> $adjust_dpms + # disable screensaver and dpms + xset s off + xset -dpms +else + xsetq=$(xset q|grep timeout|awk '{print $2}') + # if the timeout is still 0, set it to its former value, or just switch on screensaver/dpms again + if [[ $xsetq -eq 0 ]];then + if [[ -f "$adjust_dpms" ]];then + xset $(head -n1 $adjust_dpms) + xset $(tail -n1 $adjust_dpms) + rm -rf $adjust_dpms + else + xset +dpms + xset s on + fi + fi +fi + |