From: Fred Hamster Date: Fri, 21 Nov 2025 15:25:10 +0000 (-0500) Subject: added support to start a screensaver for x windows X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=1aba6e3cc5a20c7a8242852549bf5a462364a9ca;p=feisty_meow.git added support to start a screensaver for x windows 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. --- diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 4820ffdd..88af2067 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -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. diff --git a/scripts/core/launch_feisty_meow.sh b/scripts/core/launch_feisty_meow.sh index 30430edf..00e4a0bf 100644 --- a/scripts/core/launch_feisty_meow.sh +++ b/scripts/core/launch_feisty_meow.sh @@ -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 index 00000000..ffa202d3 --- /dev/null +++ b/scripts/core/start_xwin_screensaver.sh @@ -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 + diff --git a/scripts/processes/process_manager.sh b/scripts/processes/process_manager.sh index 762e43a6..68472110 100644 --- a/scripts/processes/process_manager.sh +++ b/scripts/processes/process_manager.sh @@ -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