From 3f2a9b99b4f9867a99a09a0e5b7e1c3612359d29 Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 20 Feb 2014 14:46:29 +0100 Subject: Adding 'adjust_dpms' variable in script, to only have one storage location for all settings --- bin/adjust_dpms | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/adjust_dpms b/bin/adjust_dpms index 0f56b46..a54e539 100755 --- a/bin/adjust_dpms +++ b/bin/adjust_dpms @@ -1,11 +1,13 @@ #!/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 +# Programs are defined in separate config file ~/.config/dpms +# Run as timed user script (i.e. adjust_dpms@.service) with systemd +# from /etc/systemd/system/timer-minutely.target.wants export DISPLAY=:0 -config="/home/dave/.config/dpms" +config="/home/$(whoami)/.config/dpms" blankoff=0 # check for config file existence @@ -42,20 +44,19 @@ done if [ $blankoff -gt 0 ]; then echo "Some program requires screensaver to be off." # print currently set values for screensaver timeout to tmp file - echo "$(xset q|grep timeout|awk '{print $2}') $(xset q|grep timeout|awk '{print $4}')" > /tmp/xset_screensaver - echo "$(xset q|grep Standby|awk '{print $2}') $(xset q|grep Standby|awk '{print $4}') $(xset q|grep Standby|awk '{print $6}')" > /tmp/xset_dpms + 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 set 360 seconds as blank time 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 /tmp/xset_screensaver && -f /tmp/xset_dpms ]];then - xset s $(cat /tmp/xset_screensaver) - xset dpms $(cat /tmp/xset_dpms) - rm -rf /tmp/xset_screensaver /tmp/xset_dpms + 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 -- cgit v1.2.3-70-g09d2