Prevent duplicate xlocker activation during X11 session startup

This commit is contained in:
Luxferre committed 2026-11-04 15:58:34 +02:00
1 parent b8dea31b59
commit dbd8cef2e1
8 files changed
+114 -96

No files matched your search

@@ -10,54 +10,57 @@
. sxmo_common.sh . sxmo_common.sh
# Create xdg user directories, such as ~/Pictures # Create xdg user directories, such as ~/Pictures
[ -d "$HOME/Pictures" ] || xdg-user-dirs-update & [ -d "$HOME/Pictures" ] || ( xdg-user-dirs-update & )
# Ensure fontconfig cache is valid without forcing a full rescan on every boot # Ensure fontconfig cache is valid without forcing a full rescan on every boot
if command -v fc-cache > /dev/null && [ -z "$(ls -A /var/cache/fontconfig 2>/dev/null)" ]; then if command -v fc-cache > /dev/null && [ -z "$(ls -A /var/cache/fontconfig 2>/dev/null)" ]; then
fc-cache >/dev/null 2>&1 & ( fc-cache >/dev/null 2>&1 & )
fi fi
if ! superctl status > /dev/null 2>&1; then if ! superctl status > /dev/null 2>&1; then
pkill -9 -x superd > /dev/null 2>&1 || true pkill -9 -x superd > /dev/null 2>&1 || true
rm -f "$XDG_RUNTIME_DIR/superd.lock" "$XDG_RUNTIME_DIR/superd.sock" rm -f "$XDG_RUNTIME_DIR/superd.lock" "$XDG_RUNTIME_DIR/superd.sock"
sxmo_jobs.sh start daemon_manager superd sxmo_jobs.sh start daemon_manager superd
while ! superctl status > /dev/null 2>&1; do while ! superctl status > /dev/null 2>&1; do
sleep 0.05 sleep 0.05
done done
fi fi
if [ -n "$SXMO_ROTATE_START" ]; then if [ -n "$SXMO_ROTATE_START" ]; then
sxmo_rotate.sh sxmo_rotate.sh
fi fi
# Load our sound daemons # Load our sound daemons
if [ -z "$SXMO_NO_AUDIO" ]; then if [ -z "$SXMO_NO_AUDIO" ]; then
if ! [ -d /run/systemd/system ]; then if ! [ -d /run/systemd/system ]; then
if [ "$(command -v pulseaudio)" ]; then if [ "$(command -v pulseaudio)" ]; then
superctl start pulseaudio superctl start pulseaudio
elif [ "$(command -v pipewire)" ]; then elif [ "$(command -v pipewire)" ]; then
# pipewire-pulse will start pipewire # pipewire-pulse will start pipewire
pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse
pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber
fi fi
fi fi
# monitor for headphone for statusbar # monitor for headphone for statusbar
superctl start sxmo_soundmonitor superctl start sxmo_soundmonitor
( (
sleep 1 (
sxmo_audio.sh device apply >/dev/null 2>&1 || true sleep 1
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true sxmo_audio.sh device apply >/dev/null 2>&1 || true
) & sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
) &
)
fi fi
# Periodically update some status bar components # Periodically update some status bar components
sxmo_hook_statusbar.sh all sxmo_hook_statusbar.sh all
sxmo_jobs.sh start statusbar_periodics sxmo_run_aligned.sh 60 \ sxmo_jobs.sh start statusbar_periodics sxmo_run_aligned.sh 60 \
sxmo_hook_statusbar.sh periodics sxmo_hook_statusbar.sh periodics
# dunst is required for warnings. # dunst is required for warnings.
/usr/bin/bananarchy-sync-dunst-theme --no-restart >/dev/null 2>&1 || true
superctl start dunst superctl start dunst
# start adaptive brightness at boot # start adaptive brightness at boot
@@ -67,7 +70,7 @@ superctl start dunst
[ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob [ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob
[ "$(command -v bonsaid)" ] && superctl start bonsaid [ "$(command -v bonsaid)" ] && superctl start bonsaid
if [ "$(command -v fcitx5)" ]; then if [ "$(command -v fcitx5)" ]; then
superctl start fcitx5 superctl start fcitx5
fi fi
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary [ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
@@ -75,32 +78,32 @@ fi
mkdir -p "$XDG_CACHE_HOME/sxmo" mkdir -p "$XDG_CACHE_HOME/sxmo"
touch "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend" touch "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend"
if sxmo_wakelock.sh isenabled; then if sxmo_wakelock.sh isenabled; then
sxmo_wakelock.sh lock sxmo_not_suspendable infinite sxmo_wakelock.sh lock sxmo_not_suspendable infinite
fi fi
# Activate lockscreen upon GUI startup # Ensure lockscreen is active if session is still locked and locker has not yet mapped
printf '1\n' > /tmp/bananarchy_screen_locked if [ -f /tmp/bananarchy_screen_locked ] && [ ! -f "$XDG_RUNTIME_DIR/xlocker.pid" ]; then
sxmo_state.sh set lock ( xlocker >/dev/null 2>&1 & )
fi
# Turn on lisgd only on touch devices # Turn on lisgd only on touch devices
if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then
superctl start sxmo_hook_lisgd superctl start sxmo_hook_lisgd
fi fi
if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then
# Turn on the dbus-monitors for modem-related tasks # Turn on the dbus-monitors for modem-related tasks
superctl start sxmo_modemmonitor superctl start sxmo_modemmonitor
# place a wakelock for 120s to allow the modem to fully warm up (eg25 + # place a wakelock for 120s to allow the modem to fully warm up (eg25 +
# elogind/systemd would do this for us, but we don't use those.) # elogind/systemd would do this for us, but we don't use those.)
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
fi fi
# Start the desktop widget (e.g. clock) # Start the desktop widget (e.g. clock)
pidof -s conky >/dev/null 2>&1 || DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true pidof -s conky >/dev/null 2>&1 || DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true
if [ -f /tmp/bananarchy_screen_locked ]; then if [ -f /tmp/bananarchy_screen_locked ]; then
pkill -STOP -x conky 2>/dev/null || true pkill -STOP -x conky 2>/dev/null || true
xlocker wake >/dev/null 2>&1 &
fi fi
# It watch network changes and update the status bar icon by example # It watch network changes and update the status bar icon by example
@@ -111,6 +114,8 @@ superctl start sxmo_notificationmonitor
# Pre-warm app and script menu caches in background # Pre-warm app and script menu caches in background
( (
sxmo_hook_apps.sh >/dev/null 2>&1 || true (
sxmo_hook_scripts.sh >/dev/null 2>&1 || true sxmo_hook_apps.sh >/dev/null 2>&1 || true
) & sxmo_hook_scripts.sh >/dev/null 2>&1 || true
) &
)
@@ -10,54 +10,57 @@
. sxmo_common.sh . sxmo_common.sh
# Create xdg user directories, such as ~/Pictures # Create xdg user directories, such as ~/Pictures
[ -d "$HOME/Pictures" ] || xdg-user-dirs-update & [ -d "$HOME/Pictures" ] || ( xdg-user-dirs-update & )
# Ensure fontconfig cache is valid without forcing a full rescan on every boot # Ensure fontconfig cache is valid without forcing a full rescan on every boot
if command -v fc-cache > /dev/null && [ -z "$(ls -A /var/cache/fontconfig 2>/dev/null)" ]; then if command -v fc-cache > /dev/null && [ -z "$(ls -A /var/cache/fontconfig 2>/dev/null)" ]; then
fc-cache >/dev/null 2>&1 & ( fc-cache >/dev/null 2>&1 & )
fi fi
if ! superctl status > /dev/null 2>&1; then if ! superctl status > /dev/null 2>&1; then
pkill -9 -x superd > /dev/null 2>&1 || true pkill -9 -x superd > /dev/null 2>&1 || true
rm -f "$XDG_RUNTIME_DIR/superd.lock" "$XDG_RUNTIME_DIR/superd.sock" rm -f "$XDG_RUNTIME_DIR/superd.lock" "$XDG_RUNTIME_DIR/superd.sock"
sxmo_jobs.sh start daemon_manager superd sxmo_jobs.sh start daemon_manager superd
while ! superctl status > /dev/null 2>&1; do while ! superctl status > /dev/null 2>&1; do
sleep 0.05 sleep 0.05
done done
fi fi
if [ -n "$SXMO_ROTATE_START" ]; then if [ -n "$SXMO_ROTATE_START" ]; then
sxmo_rotate.sh sxmo_rotate.sh
fi fi
# Load our sound daemons # Load our sound daemons
if [ -z "$SXMO_NO_AUDIO" ]; then if [ -z "$SXMO_NO_AUDIO" ]; then
if ! [ -d /run/systemd/system ]; then if ! [ -d /run/systemd/system ]; then
if [ "$(command -v pulseaudio)" ]; then if [ "$(command -v pulseaudio)" ]; then
superctl start pulseaudio superctl start pulseaudio
elif [ "$(command -v pipewire)" ]; then elif [ "$(command -v pipewire)" ]; then
# pipewire-pulse will start pipewire # pipewire-pulse will start pipewire
pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse
pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber
fi fi
fi fi
# monitor for headphone for statusbar # monitor for headphone for statusbar
superctl start sxmo_soundmonitor superctl start sxmo_soundmonitor
( (
sleep 1 (
sxmo_audio.sh device apply >/dev/null 2>&1 || true sleep 1
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true sxmo_audio.sh device apply >/dev/null 2>&1 || true
) & sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
) &
)
fi fi
# Periodically update some status bar components # Periodically update some status bar components
sxmo_hook_statusbar.sh all sxmo_hook_statusbar.sh all
sxmo_jobs.sh start statusbar_periodics sxmo_run_aligned.sh 60 \ sxmo_jobs.sh start statusbar_periodics sxmo_run_aligned.sh 60 \
sxmo_hook_statusbar.sh periodics sxmo_hook_statusbar.sh periodics
# dunst is required for warnings. # dunst is required for warnings.
/usr/bin/bananarchy-sync-dunst-theme --no-restart >/dev/null 2>&1 || true
superctl start dunst superctl start dunst
# start adaptive brightness at boot # start adaptive brightness at boot
@@ -67,7 +70,7 @@ superctl start dunst
[ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob [ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob
[ "$(command -v bonsaid)" ] && superctl start bonsaid [ "$(command -v bonsaid)" ] && superctl start bonsaid
if [ "$(command -v fcitx5)" ]; then if [ "$(command -v fcitx5)" ]; then
superctl start fcitx5 superctl start fcitx5
fi fi
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary [ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
@@ -75,32 +78,32 @@ fi
mkdir -p "$XDG_CACHE_HOME/sxmo" mkdir -p "$XDG_CACHE_HOME/sxmo"
touch "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend" touch "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend"
if sxmo_wakelock.sh isenabled; then if sxmo_wakelock.sh isenabled; then
sxmo_wakelock.sh lock sxmo_not_suspendable infinite sxmo_wakelock.sh lock sxmo_not_suspendable infinite
fi fi
# Activate lockscreen upon GUI startup # Ensure lockscreen is active if session is still locked and locker has not yet mapped
printf '1\n' > /tmp/bananarchy_screen_locked if [ -f /tmp/bananarchy_screen_locked ] && [ ! -f "$XDG_RUNTIME_DIR/xlocker.pid" ]; then
sxmo_state.sh set lock ( xlocker >/dev/null 2>&1 & )
fi
# Turn on lisgd only on touch devices # Turn on lisgd only on touch devices
if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then
superctl start sxmo_hook_lisgd superctl start sxmo_hook_lisgd
fi fi
if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then
# Turn on the dbus-monitors for modem-related tasks # Turn on the dbus-monitors for modem-related tasks
superctl start sxmo_modemmonitor superctl start sxmo_modemmonitor
# place a wakelock for 120s to allow the modem to fully warm up (eg25 + # place a wakelock for 120s to allow the modem to fully warm up (eg25 +
# elogind/systemd would do this for us, but we don't use those.) # elogind/systemd would do this for us, but we don't use those.)
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
fi fi
# Start the desktop widget (e.g. clock) # Start the desktop widget (e.g. clock)
pidof -s conky >/dev/null 2>&1 || DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true pidof -s conky >/dev/null 2>&1 || DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true
if [ -f /tmp/bananarchy_screen_locked ]; then if [ -f /tmp/bananarchy_screen_locked ]; then
pkill -STOP -x conky 2>/dev/null || true pkill -STOP -x conky 2>/dev/null || true
xlocker wake >/dev/null 2>&1 &
fi fi
# It watch network changes and update the status bar icon by example # It watch network changes and update the status bar icon by example
@@ -111,6 +114,8 @@ superctl start sxmo_notificationmonitor
# Pre-warm app and script menu caches in background # Pre-warm app and script menu caches in background
( (
sxmo_hook_apps.sh >/dev/null 2>&1 || true (
sxmo_hook_scripts.sh >/dev/null 2>&1 || true sxmo_hook_apps.sh >/dev/null 2>&1 || true
) & sxmo_hook_scripts.sh >/dev/null 2>&1 || true
) &
)
@@ -56,7 +56,8 @@ mkdir -p "$XDG_RUNTIME_DIR" "$XDG_CACHE_HOME/sxmo" "$XDG_CONFIG_HOME/sxmo"
rm -f "$XDG_RUNTIME_DIR/sxmo.led.lock" "$XDG_RUNTIME_DIR"/sxmo_bat_state_* 2>/dev/null || true rm -f "$XDG_RUNTIME_DIR/sxmo.led.lock" "$XDG_RUNTIME_DIR"/sxmo_bat_state_* 2>/dev/null || true
touch "$XDG_CACHE_HOME/sxmo/sxmo.noidle" "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend" touch "$XDG_CACHE_HOME/sxmo/sxmo.noidle" "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend"
[ -n "${DBUS_SESSION_BUS_ADDRESS:-}" ] && printf "%s\n" "$DBUS_SESSION_BUS_ADDRESS" > "$XDG_RUNTIME_DIR/dbus.bus" [ -n "${DBUS_SESSION_BUS_ADDRESS:-}" ] && printf "%s\n" "$DBUS_SESSION_BUS_ADDRESS" > "$XDG_RUNTIME_DIR/dbus.bus"
printf "unlock\n" > "$XDG_RUNTIME_DIR/sxmo.state" printf "1\n" > /tmp/bananarchy_screen_locked
printf "lock\n" > "$XDG_RUNTIME_DIR/sxmo.state"
_init_bl="" _init_bl=""
if [ -r "$XDG_CONFIG_HOME/sxmo/brightness" ]; then if [ -r "$XDG_CONFIG_HOME/sxmo/brightness" ]; then
@@ -116,6 +117,9 @@ trap 'rm -f "$SESSION_PID_FILE"; pkill -P $$ >/dev/null 2>&1 || true; exit 0' IN
pkill -9 -x conky >/dev/null 2>&1 || true pkill -9 -x conky >/dev/null 2>&1 || true
rm -rf /tmp/sxmo_conky_time_state /tmp/sxmo_conky_restart.lock rm -rf /tmp/sxmo_conky_time_state /tmp/sxmo_conky_restart.lock
DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true
if [ -f /tmp/bananarchy_screen_locked ]; then
pkill -STOP -x conky 2>/dev/null || true
fi
( sxmo_hook_start.sh >/tmp/sxmo_hook_start.log 2>&1 </dev/null & ) ( sxmo_hook_start.sh >/tmp/sxmo_hook_start.log 2>&1 </dev/null & )
first_iter=1 first_iter=1
Binary file not shown.
@@ -26,7 +26,7 @@ case "$SXMO_WM" in
if ! sxmo_jobs.sh running proximity_lock -q; then if ! sxmo_jobs.sh running proximity_lock -q; then
sxmo_dmenu.sh close sxmo_dmenu.sh close
fi fi
xlocker >/dev/null 2>&1 & [ -f "$XDG_RUNTIME_DIR/xlocker.pid" ] || xlocker >/dev/null 2>&1 &
;; ;;
esac esac
@@ -81,9 +81,10 @@ if sxmo_wakelock.sh isenabled; then
sxmo_wakelock.sh lock sxmo_not_suspendable infinite sxmo_wakelock.sh lock sxmo_not_suspendable infinite
fi fi
# Activate lockscreen upon GUI startup # Ensure lockscreen is active if session is still locked and locker has not yet mapped
printf '1\n' > /tmp/bananarchy_screen_locked if [ -f /tmp/bananarchy_screen_locked ] && [ ! -f "$XDG_RUNTIME_DIR/xlocker.pid" ]; then
sxmo_state.sh set lock ( xlocker >/dev/null 2>&1 & )
fi
# Turn on lisgd only on touch devices # Turn on lisgd only on touch devices
if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nogesture ]; then
@@ -103,7 +104,6 @@ fi
pidof -s conky >/dev/null 2>&1 || DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true pidof -s conky >/dev/null 2>&1 || DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true
if [ -f /tmp/bananarchy_screen_locked ]; then if [ -f /tmp/bananarchy_screen_locked ]; then
pkill -STOP -x conky 2>/dev/null || true pkill -STOP -x conky 2>/dev/null || true
( xlocker wake >/dev/null 2>&1 & )
fi fi
# It watch network changes and update the status bar icon by example # It watch network changes and update the status bar icon by example
Binary file not shown.
+10 -6
View File
@@ -674,16 +674,20 @@ int locker_run_main(int argc, char** argv) {
}; };
auto lockPhone = [&](bool blankDisplay) { auto lockPhone = [&](bool blankDisplay) {
bool alreadyVisible = visible;
writeSmallFileStr(kLockFlagPath, "1\n"); writeSmallFileStr(kLockFlagPath, "1\n");
writeIntFile(activePidPath, static_cast<int>(::getpid())); writeIntFile(activePidPath, static_cast<int>(::getpid()));
closeOtherOverlays(); closeOtherOverlays();
verifier.refreshIfNeeded(); verifier.refreshIfNeeded();
passcode.clear(); int64_t now = nowMs();
statusMsg.clear(); lastActivityMs = now;
statusIsError = false; if (!alreadyVisible || blankDisplay) {
lockActivatedMs = nowMs(); passcode.clear();
lastActivityMs = lockActivatedMs; statusMsg.clear();
writeSoftkeySuppress(lockActivatedMs + 400); statusIsError = false;
lockActivatedMs = now;
writeSoftkeySuppress(now + 400);
}
if (!visible) { if (!visible) {
XMapRaised(dpy, win); XMapRaised(dpy, win);
XMoveResizeWindow(dpy, win, 0, 0, kScreenWidth, kScreenHeight); XMoveResizeWindow(dpy, win, 0, 0, kScreenWidth, kScreenHeight);