fix(sxmo): re-enable automatic screen-off on idle to stop backlight battery drain
The previous commit disabled sxmo_idle.sh and the idle_locker in the unlock/lock hooks, leaving the display backlight pinned at maximum brightness forever (Xorg runs with -s 0 -dpms and /sys/power/state is empty, so the panel never blanks). On a phone with no suspend this is by far the dominant battery drain. Restore sxmo_idle.sh and start idle_locker from the unlock and lock hooks so the screen blanks after SXMO_UNLOCK_IDLE_TIME (default 30s) / once locked after SXMO_LOCK_IDLE_TIME (default 8s). Locking itself stays explicit-only, matching the documented design; only the display blanks. Verified live on the device: after the idle timeout the state transitions to screenoff and /sys/class/backlight/backlight/brightness drops to 0.
This commit is contained in:
@@ -118,7 +118,7 @@ sudo dd if=./images/bananarchy-nokia-argon.img of=/dev/sdX bs=4M status=progress
|
||||
| **Slider close / open** | `SW_LID` (`lid:on` / `lid:off`) | **Close**: close open menu, turn off keypad backlight, and lock/turn screen off; **Open**: restore keypad backlight, unlock, and turn screen on |
|
||||
|
||||
> **Explicit locking & waking**:
|
||||
> X11 screensaver/DPMS blanking and automatic idle locking are disabled so the phone only locks when explicitly requested (`Power -> Lock / Lock (Screen off)`, `XDrawer -> Lock`, `2× End / Power`, or closing the physical slider). When locked, you can wake and unlock the phone in a single action by either:
|
||||
> X11 screensaver/DPMS blanking is disabled (the display is blanked explicitly by Sxmo, not by the X server), and automatic idle *locking* is disabled so the phone only locks when explicitly requested (`Power -> Lock / Lock (Screen off)`, `XDrawer -> Lock`, `2× End / Power`, or closing the physical slider). To save battery, the display still blanks automatically after a period of inactivity (`SXMO_UNLOCK_IDLE_TIME`, default 30s; `SXMO_LOCK_IDLE_TIME`, default 8s once locked) without locking. When the screen is off, you can wake and unlock the phone in a single action by either:
|
||||
> - **Opening the slider** (`SW_LID` off), or
|
||||
> - Pressing **End / Power (red)**, **Left softkey**, **Right softkey**, or **Call (green)** once.
|
||||
|
||||
|
||||
@@ -1,4 +1,78 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Automatic idle locking and screen blanking are disabled on Bananarchy.
|
||||
exit 0
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
_swayidletoidles() {
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
timeout)
|
||||
printf "%s|%s" "$2" "$3"
|
||||
shift 3
|
||||
case "$1" in
|
||||
resume)
|
||||
printf "|%s" "$2"
|
||||
shift 2
|
||||
;;
|
||||
esac
|
||||
printf "\n"
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
xorgidle() {
|
||||
if ! command -v xprintidle >/dev/null 2>&1; then
|
||||
while : ; do
|
||||
sleep 3600
|
||||
done
|
||||
fi
|
||||
|
||||
idles="$(_swayidletoidles "$@")"
|
||||
resumes=""
|
||||
|
||||
tick=0
|
||||
new_idle="$(xprintidle 2>/dev/null || printf '0')"
|
||||
[ -n "$new_idle" ] || new_idle=0
|
||||
last_idle="$new_idle"
|
||||
|
||||
finish() {
|
||||
sh -c "$resumes"
|
||||
resumes=""
|
||||
exit
|
||||
}
|
||||
trap 'finish' TERM INT EXIT
|
||||
|
||||
while : ; do
|
||||
last_idle="$new_idle"
|
||||
new_idle="$(xprintidle 2>/dev/null || printf '0')"
|
||||
[ -n "$new_idle" ] || new_idle=0
|
||||
if [ "$last_idle" -gt "$new_idle" ] 2>/dev/null; then
|
||||
sh -c "$resumes"
|
||||
tick=0
|
||||
resumes=""
|
||||
fi
|
||||
|
||||
if printf "%b\n" "$idles" | grep -q "^$tick|"; then
|
||||
printf "%b\n" "$idles" | \
|
||||
grep "^$tick|" | \
|
||||
cut -d'|' -f2 | \
|
||||
xargs -I{} -0 sh -c "{}"
|
||||
resumes="$(printf "%b\n" "$idles" | grep "^$tick|" | cut -d'|' -f3);$resumes"
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
tick=$((tick + 1))
|
||||
done
|
||||
}
|
||||
|
||||
case "$SXMO_WM" in
|
||||
dwm|i3)
|
||||
xorgidle "$@"
|
||||
;;
|
||||
sway|river)
|
||||
exec swayidle "$@"
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -32,7 +32,14 @@ if [ -z "$SXMO_DISABLE_LEDS" ]; then
|
||||
fi
|
||||
sxmo_jobs.sh stop periodic_wakelock_check
|
||||
|
||||
# Automatic idle transitions are disabled; only explicit locking is used
|
||||
sxmo_jobs.sh stop idle_locker 2>/dev/null || true
|
||||
# Re-enable automatic screen-off on idle to save battery. The phone only
|
||||
# locks on explicit request; once locked we blank the screen after a short
|
||||
# idle period.
|
||||
if [ -e "$XDG_CACHE_HOME/sxmo/sxmo.noidle" ]; then
|
||||
sxmo_jobs.sh stop idle_locker
|
||||
else
|
||||
sxmo_jobs.sh start idle_locker sxmo_idle.sh -w \
|
||||
timeout "${SXMO_LOCK_IDLE_TIME:-8}" 'sh -c "sxmo_state.sh set screenoff"'
|
||||
fi
|
||||
|
||||
wait
|
||||
|
||||
@@ -26,7 +26,13 @@ if [ -z "$SXMO_DISABLE_LEDS" ]; then
|
||||
fi
|
||||
sxmo_jobs.sh stop periodic_wakelock_check
|
||||
|
||||
# Automatic idle locking is disabled; only explicit locking is used
|
||||
sxmo_jobs.sh stop idle_locker 2>/dev/null || true
|
||||
# Re-enable automatic screen-off on idle to save battery. Locking stays
|
||||
# explicit (the user locks only on request); we only blank the display.
|
||||
if [ -e "$XDG_CACHE_HOME/sxmo/sxmo.noidle" ]; then
|
||||
sxmo_jobs.sh stop idle_locker
|
||||
else
|
||||
sxmo_jobs.sh start idle_locker sxmo_idle.sh -w \
|
||||
timeout "${SXMO_UNLOCK_IDLE_TIME:-30}" 'sh -c "sxmo_state.sh set screenoff"'
|
||||
fi
|
||||
|
||||
wait
|
||||
|
||||
Reference in New Issue
Block a user