diff options
Diffstat (limited to 'screensaver-pause')
-rwxr-xr-x | screensaver-pause | 42 |
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 |