Implement passcode-based fullscreen phone locker (locker.so / xlocker)

This commit is contained in:
Luxferre committed 2026-10-29 21:31:00 +02:00
1 parent 32d5d2f2b4
commit 0656042f7f
56 files changed
+1264 -120

No files matched your search

+2
View File
@@ -37,6 +37,8 @@ permit nopass :wheel as root cmd /usr/bin/sxmo_power.sh
permit nopass :wheel as root cmd sxmo_power.sh
permit nopass :wheel as root cmd /usr/bin/sxmo_sdcard.sh
permit nopass :wheel as root cmd sxmo_sdcard.sh
permit nopass :wheel as root cmd /usr/bin/bananarchy-verify-passcode
permit nopass :wheel as root cmd bananarchy-verify-passcode
permit nopass :wheel as root cmd /usr/bin/plymouth args quit
permit nopass :wheel as root cmd plymouth args quit
permit nopass :wheel as root cmd rc-service args hexagonrpcd-adsp-sensorspd stop
Binary file not shown.
Binary file not shown.
Binary file not shown.
+21
View File
@@ -22,6 +22,21 @@ transition_can_suspend() {
transition() {
state="$1"
if [ "$state" = "unlock" ] && [ -f /tmp/bananarchy_screen_locked ]; then
state="lock"
printf '%s\n' "$state" > "$SXMO_STATE"
sxmo_wm.sh display on >/dev/null 2>&1 &
xlocker wake >/dev/null 2>&1 &
return 0
fi
if [ "$state" = "lock" ]; then
printf '1\n' > /tmp/bananarchy_screen_locked
xlocker >/dev/null 2>&1 &
elif [ "$state" = "screenoff" ]; then
printf '1\n' > /tmp/bananarchy_screen_locked
xlocker screenoff >/dev/null 2>&1 &
fi
sxmo_log "transitioning to stage $state"
printf '%s\n' "$state" > "$SXMO_STATE"
@@ -106,10 +121,16 @@ shift
case "$action" in
get)
read_state
if [ -f /tmp/bananarchy_screen_locked ] && [ "$state" = "unlock" ]; then
state="lock"
fi
printf %s "$state"
exit 0
;;
is_locked)
if [ -f /tmp/bananarchy_screen_locked ]; then
exit 0
fi
if [ -n "$SXMO_HAS_PEANUTBUTTER" ]; then
pidof peanutbutter swaylock waylock i3lock > /dev/null && exit 0
fi
+1
View File
@@ -0,0 +1 @@
dwm-plugin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -25,15 +25,15 @@ else
CURRENT_STATE="$(sxmo_state.sh get)"
fi
if [ "$CURRENT_STATE" != "unlock" ] && sxmo_state.sh is_locked; then
if [ -f /tmp/bananarchy_screen_locked ] || { [ "$CURRENT_STATE" != "unlock" ] && sxmo_state.sh is_locked; }; then
case "$ACTION" in
"powerbutton_one"|"powerbutton_two"|"powerbutton_three"|"menuleft_one"|"menuright_one"|"enter_one"|"enter_two"|"enter_three")
if [ -n "$WAYLAND_DISPLAY" ]; then
wlopm --on "*" >/dev/null 2>&1 || sxmo_wm.sh display on
sxmo_wm.sh display on
if [ -f /tmp/bananarchy_screen_locked ]; then
xlocker wake >/dev/null 2>&1 &
else
sxmo_wm.sh display on
sxmo_state.sh set unlock &
fi
sxmo_state.sh set unlock &
exit 0
;;
"voldown_one"|"volup_one")
@@ -2,14 +2,6 @@
# configversion: 70028f54f5d7428d4e3178de5c98978b
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
#
# See man 7 sxmo.states.
#
# This will:
# - blink blue led once
# - turn screen on
# - disable input
# - set up a daemon to automatically transition to screenoff state after 8s.
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
@@ -22,30 +14,23 @@ cur_state=""
[ -r "$STATE_FILE" ] && { read -r cur_state < "$STATE_FILE" 2>/dev/null || true; }
[ "$cur_state" = "unlock" ] && exit 0
if [ -z "$SXMO_DISABLE_LEDS" ]; then
sxmo_led.sh blink blue &
fi
printf '1\n' > /tmp/bananarchy_screen_locked
[ "$SXMO_WM" = "sway" ] && swaymsg mode default
cur_state=""
[ -r "$STATE_FILE" ] && { read -r cur_state < "$STATE_FILE" 2>/dev/null || true; }
if [ "$cur_state" != "unlock" ]; then
sxmo_wm.sh display off
fi
if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then
sxmo_wm.sh inputevent touchscreen off
if [ -z "$SXMO_DISABLE_LEDS" ]; then
sxmo_led.sh blink blue &
fi
case "$SXMO_WM" in
dwm)
if ! sxmo_jobs.sh running proximity_lock -q; then
sxmo_dmenu.sh close
fi
;;
dwm)
if ! sxmo_jobs.sh running proximity_lock -q; then
sxmo_dmenu.sh close
fi
xlocker >/dev/null 2>&1 &
;;
esac
if [ -z "$SXMO_DISABLE_LEDS" ]; then
sxmo_jobs.sh stop periodic_blink
sxmo_jobs.sh stop periodic_blink
fi
sxmo_jobs.sh stop periodic_wakelock_check
sxmo_jobs.sh stop idle_locker
@@ -2,63 +2,40 @@
# configversion: 66b67db06146e3b2dd3ae9a6f1411c5e
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
#
# See man 7 sxmo.states.
#
# This will:
# - turn screen off
# - turn input off
# - launch a demon to blink purple led every 2s
# - check wakelocks and if none suspend after 3s hold
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
# This hook is called when the system reaches a off state (screen off)
# This hook is called when the system reaches a screenoff state
STATE_FILE="${SXMO_STATE:-$XDG_RUNTIME_DIR/sxmo.state}"
cur_state=""
[ -r "$STATE_FILE" ] && { read -r cur_state < "$STATE_FILE" 2>/dev/null || true; }
[ "$cur_state" = "unlock" ] && exit 0
printf '1\n' > /tmp/bananarchy_screen_locked
if [ -z "$SXMO_DISABLE_LEDS" ]; then
sxmo_led.sh blink red blue &
fi
[ "$SXMO_WM" = "sway" ] && swaymsg mode default
cur_state=""
[ -r "$STATE_FILE" ] && { read -r cur_state < "$STATE_FILE" 2>/dev/null || true; }
if [ "$cur_state" != "unlock" ]; then
sxmo_wm.sh display off
fi
if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then
sxmo_wm.sh inputevent touchscreen off
fi
if [ -z "$SXMO_DISABLE_LEDS" ] && [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nosuspend ]; then
sxmo_jobs.sh start periodic_blink \
sxmo_run_periodically.sh -w 2 -- sxmo_led.sh blink red blue
sxmo_led.sh blink red blue &
fi
case "$SXMO_WM" in
dwm)
# dmenu will grab input focus (i.e. power button) so kill it before going to
# screenoff unless proximity lock is running (i.e. there's a phone call).
if ! sxmo_jobs.sh running proximity_lock -q; then
sxmo_dmenu.sh close
fi
;;
dwm)
if ! sxmo_jobs.sh running proximity_lock -q; then
sxmo_dmenu.sh close
fi
xlocker screenoff >/dev/null 2>&1 &
;;
esac
if [ "$cur_state" != "unlock" ]; then
sxmo_wm.sh display off
fi
if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then
sxmo_wm.sh inputevent touchscreen off
fi
sxmo_jobs.sh stop idle_locker
wait
case "$SXMO_WM" in
sway)
if [ -n "$SXMO_HAS_PEANUTBUTTER" ] && command -v peanutbutter > /dev/null; then
peanutbutter --font Sxmo --statuscommand sxmo_hook_lockstatusbar.sh && sxmo_hook_statusbar.sh state_change &
fi
;;
esac