From e95b5fd295165c4cd8f96c00a9e1cde589acb92c Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Thu, 1 Apr 2021 10:34:39 +0200
Subject: Add some switches to xblank
---
.local/bin/xblank | 41 +++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)
(limited to '.local/bin/xblank')
diff --git a/.local/bin/xblank b/.local/bin/xblank
index 0165455..9804b97 100755
--- a/.local/bin/xblank
+++ b/.local/bin/xblank
@@ -15,12 +15,15 @@ readonly PROGRAM_NAME="$(basename "$0")"
main()
{
# Handle opts
- while getopts ":C:S:c:ht:v" opt
+ while getopts ":PS:d:hpt:v" opt
do
case "$opt" in
+ P) unpause=1 ;;
S) rundir=$OPTARG ;;
d) command_dir=$OPTARG ;;
h) usage && exit 0 ;;
+ p) pause=1 ;;
+ t) trigger=$OPTARG ;;
v) verbose=1 ;;
*)
printf "Invalid option passed: %s\n" "$OPTARG" >&2
@@ -36,25 +39,51 @@ main()
time_old=0
time_now="$(xprintidle)"
+ # Set some environment variables, for exposing to the scripts ran
+ export XBLANK_STATESD="$rundir/states.d"
+
+ if [ -n "$unpause" ]
+ then
+ printf "0\n" > "$rundir/paused"
+ return 0
+ fi
+
+ if [ -n "$pause" ]
+ then
+ printf "1\n" > "$rundir/paused"
+ return 0
+ fi
+
+ if [ -n "$trigger" ]
+ then
+ cmd=$(get_script "$trigger")
+
+ if [ "$cmd" = "" ]
+ then
+ log "No executable found for activation"
+
+ return 5
+ fi
+
+ $cmd
+ fi
+
# Check availability of dependencies
for i in xprintidle xset
do
command -v "$i" >/dev/null && continue
log "Missing dependency $i"
- exit 3
+ return 3
done
# Ensure $DISPLAY is set
if [ -z "$DISPLAY" ]
then
log "\$DISPLAY is unset"
- exit 4
+ return 4
fi
- # Set some environment variables, for exposing to the scripts ran
- export XBLANK_STATESD="$rundir/states.d"
-
# Initialize the rundir
log "Create rundir ($rundir)"
mkdir -p -- "$rundir"
--
cgit v1.1