aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/xblank-toggle
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/xblank-toggle')
-rwxr-xr-x.local/bin/xblank-toggle66
1 files changed, 66 insertions, 0 deletions
diff --git a/.local/bin/xblank-toggle b/.local/bin/xblank-toggle
new file mode 100755
index 0000000..f013b93
--- /dev/null
+++ b/.local/bin/xblank-toggle
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+
+main()
+{
+ # Handle opts
+ while getopts ":S:h" opt
+ do
+ case "$opt" in
+ S) rundir=$OPTARG ;;
+ h) usage && exit 0 ;;
+ *)
+ printf "Invalid option passed: %s\n" "$OPTARG" >&2
+ ;;
+ esac
+ done
+
+ shift $(( OPTIND - 1 ))
+
+ # Set default values
+ [ -z "$rundir" ] && rundir="$XDG_RUNTIME_DIR/xblank"
+
+ # Check if xblank is currently paused
+ if [ "$(head -n 1 "$rundir/paused")" = "0" ]
+ then
+ # xblank is currently not paused
+ printf "1\n" > "$rundir/paused"
+ notify "stock_lock-open" "xblank" "Paused"
+ else
+ # xblank is already paused
+ printf "0\n" > "$rundir/paused"
+ notify "stock_lock" "xblank" "Unpaused"
+ fi
+}
+
+notify()
+{
+ icon=$1
+ shift
+
+ notify-send -i "$icon" -n 26012 -s -t 3 "$@"
+}
+
+usage()
+{
+ cat <<EOF
+Usage:
+ ${0##*/} -h
+
+Nondescript
+
+Options:
+ -h Show this help text and exit.
+EOF
+}
+
+main "$@"