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
# 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
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
if ! superctl status > /dev/null 2>&1; then
pkill -9 -x superd > /dev/null 2>&1 || true
rm -f "$XDG_RUNTIME_DIR/superd.lock" "$XDG_RUNTIME_DIR/superd.sock"
sxmo_jobs.sh start daemon_manager superd
while ! superctl status > /dev/null 2>&1; do
sleep 0.05
done
pkill -9 -x superd > /dev/null 2>&1 || true
rm -f "$XDG_RUNTIME_DIR/superd.lock" "$XDG_RUNTIME_DIR/superd.sock"
sxmo_jobs.sh start daemon_manager superd
while ! superctl status > /dev/null 2>&1; do
sleep 0.05
done
fi
if [ -n "$SXMO_ROTATE_START" ]; then
sxmo_rotate.sh
sxmo_rotate.sh
fi
# Load our sound daemons
if [ -z "$SXMO_NO_AUDIO" ]; then
if ! [ -d /run/systemd/system ]; then
if [ "$(command -v pulseaudio)" ]; then
superctl start pulseaudio
elif [ "$(command -v pipewire)" ]; then
# pipewire-pulse will start pipewire
pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse
pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber
fi
fi
if ! [ -d /run/systemd/system ]; then
if [ "$(command -v pulseaudio)" ]; then
superctl start pulseaudio
elif [ "$(command -v pipewire)" ]; then
# pipewire-pulse will start pipewire
pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse
pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber
fi
fi
# monitor for headphone for statusbar
superctl start sxmo_soundmonitor
(
sleep 1
sxmo_audio.sh device apply >/dev/null 2>&1 || true
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
) &
# monitor for headphone for statusbar
superctl start sxmo_soundmonitor
(
(
sleep 1
sxmo_audio.sh device apply >/dev/null 2>&1 || true
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
) &
)
fi
# Periodically update some status bar components
sxmo_hook_statusbar.sh all
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.
/usr/bin/bananarchy-sync-dunst-theme --no-restart >/dev/null 2>&1 || true
superctl start dunst
# start adaptive brightness at boot
@@ -67,7 +70,7 @@ superctl start dunst
[ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob
[ "$(command -v bonsaid)" ] && superctl start bonsaid
if [ "$(command -v fcitx5)" ]; then
superctl start fcitx5
superctl start fcitx5
fi
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
@@ -75,32 +78,32 @@ fi
mkdir -p "$XDG_CACHE_HOME/sxmo"
touch "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend"
if sxmo_wakelock.sh isenabled; then
sxmo_wakelock.sh lock sxmo_not_suspendable infinite
sxmo_wakelock.sh lock sxmo_not_suspendable infinite
fi
# Activate lockscreen upon GUI startup
printf '1\n' > /tmp/bananarchy_screen_locked
sxmo_state.sh set lock
# Ensure lockscreen is active if session is still locked and locker has not yet mapped
if [ -f /tmp/bananarchy_screen_locked ] && [ ! -f "$XDG_RUNTIME_DIR/xlocker.pid" ]; then
( xlocker >/dev/null 2>&1 & )
fi
# Turn on lisgd only on touch devices
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
if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then
# Turn on the dbus-monitors for modem-related tasks
superctl start sxmo_modemmonitor
# Turn on the dbus-monitors for modem-related tasks
superctl start sxmo_modemmonitor
# 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.)
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
# 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.)
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
fi
# 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
if [ -f /tmp/bananarchy_screen_locked ]; then
pkill -STOP -x conky 2>/dev/null || true
xlocker wake >/dev/null 2>&1 &
pkill -STOP -x conky 2>/dev/null || true
fi
# 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
(
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
# 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
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
if ! superctl status > /dev/null 2>&1; then
pkill -9 -x superd > /dev/null 2>&1 || true
rm -f "$XDG_RUNTIME_DIR/superd.lock" "$XDG_RUNTIME_DIR/superd.sock"
sxmo_jobs.sh start daemon_manager superd
while ! superctl status > /dev/null 2>&1; do
sleep 0.05
done
pkill -9 -x superd > /dev/null 2>&1 || true
rm -f "$XDG_RUNTIME_DIR/superd.lock" "$XDG_RUNTIME_DIR/superd.sock"
sxmo_jobs.sh start daemon_manager superd
while ! superctl status > /dev/null 2>&1; do
sleep 0.05
done
fi
if [ -n "$SXMO_ROTATE_START" ]; then
sxmo_rotate.sh
sxmo_rotate.sh
fi
# Load our sound daemons
if [ -z "$SXMO_NO_AUDIO" ]; then
if ! [ -d /run/systemd/system ]; then
if [ "$(command -v pulseaudio)" ]; then
superctl start pulseaudio
elif [ "$(command -v pipewire)" ]; then
# pipewire-pulse will start pipewire
pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse
pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber
fi
fi
if ! [ -d /run/systemd/system ]; then
if [ "$(command -v pulseaudio)" ]; then
superctl start pulseaudio
elif [ "$(command -v pipewire)" ]; then
# pipewire-pulse will start pipewire
pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse
pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber
fi
fi
# monitor for headphone for statusbar
superctl start sxmo_soundmonitor
(
sleep 1
sxmo_audio.sh device apply >/dev/null 2>&1 || true
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
) &
# monitor for headphone for statusbar
superctl start sxmo_soundmonitor
(
(
sleep 1
sxmo_audio.sh device apply >/dev/null 2>&1 || true
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
) &
)
fi
# Periodically update some status bar components
sxmo_hook_statusbar.sh all
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.
/usr/bin/bananarchy-sync-dunst-theme --no-restart >/dev/null 2>&1 || true
superctl start dunst
# start adaptive brightness at boot
@@ -67,7 +70,7 @@ superctl start dunst
[ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob
[ "$(command -v bonsaid)" ] && superctl start bonsaid
if [ "$(command -v fcitx5)" ]; then
superctl start fcitx5
superctl start fcitx5
fi
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
@@ -75,32 +78,32 @@ fi
mkdir -p "$XDG_CACHE_HOME/sxmo"
touch "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend"
if sxmo_wakelock.sh isenabled; then
sxmo_wakelock.sh lock sxmo_not_suspendable infinite
sxmo_wakelock.sh lock sxmo_not_suspendable infinite
fi
# Activate lockscreen upon GUI startup
printf '1\n' > /tmp/bananarchy_screen_locked
sxmo_state.sh set lock
# Ensure lockscreen is active if session is still locked and locker has not yet mapped
if [ -f /tmp/bananarchy_screen_locked ] && [ ! -f "$XDG_RUNTIME_DIR/xlocker.pid" ]; then
( xlocker >/dev/null 2>&1 & )
fi
# Turn on lisgd only on touch devices
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
if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then
# Turn on the dbus-monitors for modem-related tasks
superctl start sxmo_modemmonitor
# Turn on the dbus-monitors for modem-related tasks
superctl start sxmo_modemmonitor
# 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.)
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
# 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.)
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
fi
# 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
if [ -f /tmp/bananarchy_screen_locked ]; then
pkill -STOP -x conky 2>/dev/null || true
xlocker wake >/dev/null 2>&1 &
pkill -STOP -x conky 2>/dev/null || true
fi
# 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
(
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
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"
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=""
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
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
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 & )
first_iter=1
Binary file not shown.
@@ -26,7 +26,7 @@ case "$SXMO_WM" in
if ! sxmo_jobs.sh running proximity_lock -q; then
sxmo_dmenu.sh close
fi
xlocker >/dev/null 2>&1 &
[ -f "$XDG_RUNTIME_DIR/xlocker.pid" ] || xlocker >/dev/null 2>&1 &
;;
esac
@@ -81,9 +81,10 @@ if sxmo_wakelock.sh isenabled; then
sxmo_wakelock.sh lock sxmo_not_suspendable infinite
fi
# Activate lockscreen upon GUI startup
printf '1\n' > /tmp/bananarchy_screen_locked
sxmo_state.sh set lock
# Ensure lockscreen is active if session is still locked and locker has not yet mapped
if [ -f /tmp/bananarchy_screen_locked ] && [ ! -f "$XDG_RUNTIME_DIR/xlocker.pid" ]; then
( xlocker >/dev/null 2>&1 & )
fi
# Turn on lisgd only on touch devices
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
if [ -f /tmp/bananarchy_screen_locked ]; then
pkill -STOP -x conky 2>/dev/null || true
( xlocker wake >/dev/null 2>&1 & )
fi
# 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) {
bool alreadyVisible = visible;
writeSmallFileStr(kLockFlagPath, "1\n");
writeIntFile(activePidPath, static_cast<int>(::getpid()));
closeOtherOverlays();
verifier.refreshIfNeeded();
passcode.clear();
statusMsg.clear();
statusIsError = false;
lockActivatedMs = nowMs();
lastActivityMs = lockActivatedMs;
writeSoftkeySuppress(lockActivatedMs + 400);
int64_t now = nowMs();
lastActivityMs = now;
if (!alreadyVisible || blankDisplay) {
passcode.clear();
statusMsg.clear();
statusIsError = false;
lockActivatedMs = now;
writeSoftkeySuppress(now + 400);
}
if (!visible) {
XMapRaised(dpy, win);
XMoveResizeWindow(dpy, win, 0, 0, kScreenWidth, kScreenHeight);