summaryrefslogtreecommitdiff
path: root/screensaver-pause
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2016-07-02 12:59:03 +0200
committerPeter Palfrader <peter@palfrader.org>2016-07-02 12:59:09 +0200
commit3c27a0a32ed746947b658cf2d2449b32c4c2446c (patch)
treeb3ed7c85fd8e959052ad6c8c3a27cb3b8b648db9 /screensaver-pause
parent09943d4439a49f89f014d75b1016c6935d0699a3 (diff)
add screensaver-pause
Diffstat (limited to 'screensaver-pause')
-rwxr-xr-xscreensaver-pause42
1 files changed, 42 insertions, 0 deletions
diff --git a/screensaver-pause b/screensaver-pause
new file mode 100755
index 0000000..f606250
--- /dev/null
+++ b/screensaver-pause
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+set -e
+set -u
+
+FLAGFILE="$HOME/.screensaver-pause.flag"
+
+usage() {
+ echo "$0 [<minutes>]"
+}
+
+while getopts "h" OPTION; do
+ case "$OPTION" in
+ h)
+ usage
+ exit 0
+ ;;
+ *)
+ usage >&2
+ exit 1
+ esac
+done
+shift $(($OPTIND - 1))
+
+if [ "$#" -gt 1 ]; then
+ usage >&2
+ exit 1
+elif [ "$#" -eq 1 ]; then
+ timeout="$1"
+else
+ timeout=60
+fi
+
+touch -d "+$timeout minutes" "$FLAGFILE"
+(
+while find "$FLAGFILE" -mmin -0 2>/dev/null | grep -q .; do
+ qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity >/dev/null
+ sleep 30
+done
+rm -f "$FLAGFILE"
+) &
+disown