added support to start a screensaver for x windows
authorFred Hamster <fred@gruntose.com>
Fri, 21 Nov 2025 15:25:10 +0000 (10:25 -0500)
committerFred Hamster <fred@gruntose.com>
Fri, 21 Nov 2025 15:25:10 +0000 (10:25 -0500)
tries to be subtle by only hooking in if the xsecurelock software is installed, if x windows is running, and if there is no existing screensaver hooked.

scripts/core/functions.sh
scripts/core/launch_feisty_meow.sh
scripts/core/start_xwin_screensaver.sh [new file with mode: 0644]
scripts/processes/process_manager.sh

index 4820ffdd39b2b81a9d85c92cd01d79a40fffad1d..88af20672020f2839b3365ecf948045e2f66768b 100644 (file)
@@ -299,7 +299,7 @@ if [ -z "$skip_all" ]; then
 
   ##############
 
-  # wraps secure shell with some parameters we like, most importantly to enable X forwarding.
+  # wraps secure shell with some parameters we like.
   function ssh()
   {
     local args=($@)
@@ -318,6 +318,18 @@ if [ -z "$skip_all" ]; then
     restore_terminal_title
   }
 
+  # returns zero (success) if the X window system is currently running.
+  function test_for_xwin()
+  {
+    if ! timeout 1s xset q &>/dev/null; then
+#echo "No X server is running on \$DISPLAY [$DISPLAY]" >&2
+      return 1
+    else
+#echo "X server is running on \$DISPLAY [$DISPLAY]" >&2
+      return 0
+    fi
+  }
+
   ##############
 
   # locates a process given a search pattern to match in the process list.
index 30430edffa20c13addf35a277b94f2cd64aea09d..00e4a0bf5da40f250026c947359ed9f6d536aea4 100644 (file)
@@ -181,6 +181,9 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
     # load some helper methods for the terminal which we'll use below.
     source "$FEISTY_MEOW_SCRIPTS/tty/terminal_titler.sh"
 
+    # start up the xsecurelock screen saver if we are running x window system.
+    bash "$FEISTY_MEOW_SCRIPTS/core/start_xwin_screensaver.sh"
+
     ##############
 
 #hmmm: abstract this to a twiddle shell options method.
diff --git a/scripts/core/start_xwin_screensaver.sh b/scripts/core/start_xwin_screensaver.sh
new file mode 100644 (file)
index 0000000..ffa202d
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+
+# sets up a screen lock with the xsecurelock program, and assumes
+# that it will use the xscreensaver utility for the screen saving.
+
+source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
+source "$FEISTY_MEOW_SCRIPTS/processes/process_manager.sh"
+
+if ! test_for_xwin; then
+  if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
+    echo "X windows is not running; will not start up xsecurelock."
+  fi
+  exit 1
+fi
+
+xss_running="$(psa xss-lock)"
+if [ ! -z "$xss_running" ]; then
+  if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
+    echo "The xss-lock application is already running, so a screensaver is already hooked in."
+  fi
+  exit 0
+fi
+
+DIMMER="/usr/libexec/xsecurelock/dimmer"
+if [ ! -x "$DIMMER" ]; then
+  if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
+    echo "Could not find the dimmer app for xsecurelock; assuming xsecurelock is not installed and giving up."
+  fi
+  exit 1
+fi
+
+xset s 300 5
+exit_on_error "setting the x window inactivity timeout"
+
+start_background_action \
+  "xss-lock -n "$DIMMER" -l -- xsecurelock"
+exit_on_error "installing xsecurelock as the screensaver when inactive"
+
+if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
+  echo xsecurelock has been started.
+fi
+
index 762e43a66d6c7d461f930f700c4a4f49362be5ed..684721107ad10223a9a7843994cd124ef528c17a 100644 (file)
@@ -109,5 +109,9 @@ launcher_demonstrator()
   done
 }
 
-launcher_demonstrator;
+# this block should execute when the script is actually run, rather
+# than when it's just being sourced.
+if [[ $0 =~ .*process_manager\.sh.* ]]; then
+  launcher_demonstrator;
+fi