aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2021-04-01 10:34:39 +0200
committerPatrick Spek <p.spek@tyil.nl>2021-08-14 12:01:19 +0200
commite95b5fd295165c4cd8f96c00a9e1cde589acb92c (patch)
treef7e2dd40d9d2fd5abc415dbf3e7a9d1b6859b301
parent6610648e838b69b2280dd64b98780a181cd67180 (diff)
Add some switches to xblank
-rwxr-xr-x.local/bin/xblank41
1 files changed, 35 insertions, 6 deletions
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"