aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/postpone-screensaver
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2015-03-31 02:35:33 +0200
committerDavid Runge <dave@sleepmap.de>2015-03-31 02:35:33 +0200
commit3ea4a7a16def48f085f220e5aafc01099e9543bd (patch)
tree6e3bc176e26614119ff90b2aaf90160c7368f582 /scripts/postpone-screensaver
parent957c19b26c5f37b9eeab7a368e5f8d943412101a (diff)
downloaduenv-3ea4a7a16def48f085f220e5aafc01099e9543bd.tar.gz
uenv-3ea4a7a16def48f085f220e5aafc01099e9543bd.tar.bz2
uenv-3ea4a7a16def48f085f220e5aafc01099e9543bd.tar.xz
uenv-3ea4a7a16def48f085f220e5aafc01099e9543bd.zip
scripts/postpone-screensaver: Adding first version of script, after moving thesourcing of the EnvironmentFile out of the script running it
Diffstat (limited to 'scripts/postpone-screensaver')
-rwxr-xr-xscripts/postpone-screensaver43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/postpone-screensaver b/scripts/postpone-screensaver
new file mode 100755
index 0000000..7ece93d
--- /dev/null
+++ b/scripts/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
+