diff --git a/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh b/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh index e69e861..43f1a62 100755 --- a/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh +++ b/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh @@ -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 - 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 + ) & +) diff --git a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh index e69e861..43f1a62 100755 --- a/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh +++ b/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh @@ -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 - 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 + ) & +) diff --git a/overlay/rootfs/usr/bin/bananarchy-x11-session.sh b/overlay/rootfs/usr/bin/bananarchy-x11-session.sh index d06f712..1afd0e9 100755 --- a/overlay/rootfs/usr/bin/bananarchy-x11-session.sh +++ b/overlay/rootfs/usr/bin/bananarchy-x11-session.sh @@ -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 +fi ( sxmo_hook_start.sh >/tmp/sxmo_hook_start.log 2>&1 /dev/null 2>&1 & + [ -f "$XDG_RUNTIME_DIR/xlocker.pid" ] || xlocker >/dev/null 2>&1 & ;; esac diff --git a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh index 7df8e7c..43f1a62 100755 --- a/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh +++ b/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh @@ -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 - ( xlocker wake >/dev/null 2>&1 & ) fi # It watch network changes and update the status bar icon by example diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/locker.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/locker.so index 6b8d9d0..7b4c606 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/locker.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/locker.so differ diff --git a/src/dwm-plugins/locker_plugin.cpp b/src/dwm-plugins/locker_plugin.cpp index 0738e3e..0989c8d 100644 --- a/src/dwm-plugins/locker_plugin.cpp +++ b/src/dwm-plugins/locker_plugin.cpp @@ -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(::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);