Measurement-corrected battery optimization pass (DSDS + Wi-Fi)

Re-analyzed the running nokia-argon (a1105, 43 h uptime, DSDS + Wi-Fi on) and
implemented the corrected kernel/userspace optimization list. No sleep state
existed at all (/sys/power/state was 0 bytes) and cpuinfo_transition_latency
was UINT_MAX, while the CPU cores were already ~98% power-collapsed.

Kernel (K1-K14)
- Enable CONFIG_SUSPEND / SUSPEND_FREEZER / PM_WAKELOCKS / PM_AUTOSLEEP and
  build the zImage from the tuned config; ship it as overlay/rootfs/boot/vmlinuz
  plus config and System.map. Add wakeup-source to the WCNSS pronto remoteproc.
- Add clock-latency-ns to cpu-opp-table in all 5 device trees (fixes
  CPUFREQ_ETERNAL at its source instead of a userspace rate_limit_us override).
- New patch 0006: wcn36xx keep-alive 30s->120s, listen_interval=3, VM-BMS
  sample interval 10s->30s, power_supply_changed() only on real capacity
  changes, GPU devfreq polling_ms 50->100.
- Retune the config for idle (HZ=100, PREEMPT_VOLUNTARY, TEO cpuidle governor,
  no ftrace/perf/kprobes/BPF-JIT-always-on/debug options, no serial console,
  DRM_FBDEV_OVERALLOC=0, lz4 zram, ENERGY_MODEL) and drop earlycon /
  console=ttyMSM0 from every kernel cmdline.
- net.ipv6.conf.default.disable_ipv6=1 to stop ND/MLD multicast on new
  interfaces; keep NETFILTER/IPV6/CGROUPS and FRAMEBUFFER_CONSOLE for
  VPN/tethering, elogind and plymouth.

Userspace (U1-U14)
- Idle blanking without the passcode locker (bananarchy-idle-blank.sh +
  idle_locker resume hook, SXMO_UNLOCK_IDLE_TIME=60, sxmo.noidle opts out).
- Guarded deep standby (bananarchy-suspend.sh / -deep-standby.sh /
  sxmo_autosuspend.sh / sxmo_suspend.sh), AllowSuspend=yes, doas rule, no
  infinite wakelock, no sxmo.nosuspend. Shipped disabled via
  /etc/bananarchy-no-deep-standby until the new kernel is boot-tested; freeze
  is preferred, mem is opt-in.
- statusbar_periodics 60s->300s, no mmcli/nmcli/rfkill polls, xsetroot only on
  change; battery udev rule filtered and no 2 s recheck fork.
- On-demand QMI DPM port, longer DSDS/modemmonitor backoffs, chrony long polls,
  NM wifi.scan-interval=600, bluetooth AutoEnable=false, tmpfs on /tmp,
  zero-log superd, GPU devfreq governor on screen-off, longer SIP/Tox timers.
- Fix the cosmetic wpa_supplicant yesno typo; withdraw the disproven duplicate
  wpa_supplicant and soundmonitor 5 s loop items.

Rebuilt images/bananarchy-nokia-argon.img with --mkinitfs: boot.img contains
the new zImage + DTB byte-for-byte and no serial-console cmdline. Deployed the
userspace overlay to the connected phone and verified shell/Python syntax, the
idle-blank round trip, the statusbar hook and the deep-standby guard.
check-rebuild.sh and sync-prebuilt-overlay.sh --check both pass.

Docs: BATTERY-OPTIMIZATION-ANALYSIS.md (measurement-corrected, with
implementation status), CHANGELOG.md, MANUAL.md, README.md, AGENTS.md.
This commit is contained in:
Bantam committed 2026-11-07 17:03:12 +02:00
1 parent 2ea2db443d
commit ad3461babf
169 files changed
+151574 -333

No files matched your search

File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
BIN
View File
Binary file not shown.
@@ -4,5 +4,9 @@ level=OFF
[connection]
wifi.powersave=3
[device]
# U8: roam scans are expensive on wcn36xx; 10 min while associated.
wifi.scan-interval=600
[connectivity]
enabled=false
@@ -0,0 +1,8 @@
#!/bin/sh
# U9: only keep the modem data port open while a cellular connection is up.
[ "$1" = "qrtr0" ] || [ "$1" = "wwan0" ] || exit 0
case "$2" in
up|vpn-up) /usr/bin/bananarchy-dpm.sh open ;;
down|vpn-down) /usr/bin/bananarchy-dpm.sh close ;;
esac
exit 0
@@ -0,0 +1,3 @@
# Deep standby is disabled by default. Remove this file to enable
# suspend-to-idle after the screen has been off for 60 s.
# See BATTERY-OPTIMIZATION-ANALYSIS.md (K1/U2).
+9 -7
View File
@@ -1,7 +1,9 @@
[General]
DiscoverableTimeout = 0
PairableTimeout = 0
ControllerMode = dual
# U5: BT is off by default (rfkill soft-block, daemon not started). When a
# user enables it, do not leave the controller permanently discoverable.
DiscoverableTimeout = 60
PairableTimeout = 60
ControllerMode = bredr
MultiProfile = multiple
JustWorksRepairing = always
Experimental = true
@@ -11,7 +13,7 @@ Cache = always
[Policy]
ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb,0000110b-0000-1000-8000-00805f9b34fb,00001108-0000-1000-8000-00805f9b34fb,0000111e-0000-1000-8000-00805f9b34fb,00001124-0000-1000-8000-00805f9b34fb,00001812-0000-1000-8000-00805f9b34fb
ReconnectAttempts=7
ReconnectIntervals=1,2,4,8,16,32,64
AutoEnable=true
ResumeDelay = 2
ReconnectAttempts=3
ReconnectIntervals=2,4,8
AutoEnable=false
ResumeDelay = 0
+8
View File
@@ -0,0 +1,8 @@
# Bananarchy: long NTP polls so chronyd does not keep waking Wi-Fi (U6).
# After a long uptime chronyd ramps to maxpoll anyway; this makes it explicit
# and removes the initial iburst burst of packets.
pool pool.ntp.org minpoll 12 maxpoll 16
driftfile /var/lib/chrony/chrony.drift
rtcsync
cmdport 0
makestep 1 -1
+7 -7
View File
@@ -67,7 +67,7 @@ icmp0= # no incompressible page writing to backup device
idle0= # no idle page writing to backup device
wlim0= # no writeback_limit for idle page writing for backup device
notr0= # keep the default on linux-3.15 or newer
algo0=zstd # zstd (since linux-4.18), lz4 (since linux-3.15), or lzo.
algo0=lz4 # U12/K13: lz4 is far cheaper on CPU than zstd
# Size: zstd (best) > lzo > lz4. Speed: lz4 (best) > zstd > lzo
para0= # No algorithm parameters
labl0=zram_swap # the label name
@@ -80,7 +80,7 @@ args0= # we could e.g. have set args0="-L 'zram_swap'" instead of using labl0
# rc_need=zram-init in their /etc/conf.d/... file
type1=/tmp
flag1=ext4
size1=2048
size1=256
mlim1= # no hard memory limit
back1= # no backup device
icmp1= # no incompressible page writing to backup device
@@ -89,12 +89,12 @@ wlim1= # no writeback_limit for idle page writing for backup device
blck1=1024 # the default blocksize of 4096
irat1= # bytes/inode ratio
inod1= # inode number
opts1="strictatime,nosuid,nodev,noexec" # e.g. "relatime" or "noatime" are also reasonable choices
opts1="noatime,nosuid,nodev,noexec" # U12: no atime writes into compressed RAM
mode1=1777
owgr1= # No reason to change the default "root:root"
notr1= # keep the default on linux-3.15 or newer
algo1=zstd
para1="level=3" # algorithm-specific parameters such as compression level
algo1=lz4
para1= # lz4 has no level parameter
labl1=tmp_dir
uuid1=
args1=
@@ -115,7 +115,7 @@ opts2=relatime # e.g. "noatime" or "strictatime" are also reasonable choices
mode2=1777
owgr2= # No reason to change the default "root:root"
notr2= # keep the default on linux-3.15 or newer
algo2=zstd
algo2=lz4
para2= # No algorithm parameters
labl2=var_tmp_dir
uuid2=
@@ -126,7 +126,7 @@ args2=
type3=- # Only format the filesystem but actually do not mount it
flag3=btrfs
size3=1024
algo3=zstd
algo3=lz4
labl3=zbtrfs
uuid3=
args3=
+2
View File
@@ -33,6 +33,8 @@ permit nopass :wheel as root cmd rtcwake
permit nopass :wheel as root cmd tee args -a /sys/power/wake_lock
permit nopass :wheel as root cmd tee args -a /sys/power/wake_unlock
permit nopass :wheel as root cmd tee args /sys/power/wakeup_count
permit nopass :wheel as root cmd /usr/bin/bananarchy-suspend.sh
permit nopass :wheel as root cmd bananarchy-suspend.sh
permit nopass :wheel as root cmd tee args /sys/module/leds_msm8905_torch/parameters/next_reboot_mode
permit nopass :wheel as root cmd /usr/bin/tee args /sys/module/leds_msm8905_torch/parameters/next_reboot_mode
permit nopass :wheel as root cmd /usr/bin/sxmo_power.sh
+1 -1
View File
@@ -1,5 +1,5 @@
[Sleep]
AllowSuspend=no
AllowSuspend=yes
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no
+5
View File
@@ -0,0 +1,5 @@
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=a1b2c3d4-8110-4000-8000-000000000002 / ext4 defaults 0 0
UUID=a1b2c3d4-8110-4000-8000-000000000001 /boot ext2 nodev,nosuid,noexec 0 0
# U12: keep /tmp in RAM instead of writing to the eMMC rootfs.
tmpfs /tmp tmpfs rw,nosuid,nodev,size=64m 0 0
@@ -27,15 +27,19 @@ start() {
count=$((count + 1))
done
if [ -n "$QMICLI_MODEM" ]; then
$QMICLI_MODEM --dpm-open-port=hw-data-ep-type=bam-dmux,hw-data-ep-iface-number=1,hw-data-rx-id=1,hw-data-tx-id=1 >/dev/null 2>&1 || true
fi
# U9: only open the BAM-DMUX data port when a cellular data profile is
# actually configured. Otherwise the NetworkManager dispatcher opens it
# on demand (see 10-bananarchy-dpm.sh).
_need_dpm=0
for f in /etc/NetworkManager/system-connections/*.nmconnection; do
[ -f "$f" ] || continue
if grep -q "^type=gsm" "$f" 2>/dev/null; then
_need_dpm=1
sed -i '/^\[ipv6\]/,/^\[/ s/^method=auto$/method=ignore/' "$f" 2>/dev/null || true
fi
done
if [ "$_need_dpm" = "1" ] && [ -n "$QMICLI_MODEM" ]; then
$QMICLI_MODEM --dpm-open-port=hw-data-ep-type=bam-dmux,hw-data-ep-iface-number=1,hw-data-rx-id=1,hw-data-tx-id=1 >/dev/null 2>&1 || true
fi
eend 0
}
+80
View File
@@ -0,0 +1,80 @@
#!/sbin/openrc-run
# Copyright (c) 2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
supervisor=supervise-daemon
name="WPA Supplicant"
description="Wi-Fi Protected Access client and IEEE 802.1X supplicant"
command=/sbin/wpa_supplicant
wpa_supplicant_if=${wpa_supplicant_if:+-i}$wpa_supplicant_if
command_args="$wpa_supplicant_args $wpa_supplicant_if"
default_conf=/etc/wpa_supplicant/wpa_supplicant.conf
depend() {
need localmount
use logger dbus
after bootmisc modules entropy udev-settle
before dns dhcpcd net
keyword -shutdown
provide wlan
}
find_wireless() {
local iface=
for iface in /sys/class/net/*; do
if [ -e "$iface"/wireless -o -e "$iface"/phy80211 ]; then
echo "${iface##*/}"
return 0
fi
done
return 1
}
append_wireless() {
local iface= i=
iface=$(find_wireless)
if [ -n "$iface" ]; then
for i in $iface; do
command_args="$command_args -i$i"
done
else
eerror "Could not find a wireless interface"
fi
}
start_pre() {
case " $command_args" in
*" -i"*) ;;
*) append_wireless;;
esac
# set default conf if dbus is explicitly disabled
if [ -n "${wpa_supplicant_dbus}" ] && ! yesno "${wpa_supplicant_dbus}"; then
: ${wpa_supplicant_conf:=${default_conf}}
fi
# use default conf if it exists
if [ -f "${default_conf}" ]; then
: ${wpa_supplicant_conf:=${default_conf}}
fi
# enable default dbus if we still dont have a config
if [ -z "${wpa_supplicant_conf}" ]; then
: ${wpa_supplicant_dbus:=yes}
else
command_args="${command_args} -c$wpa_supplicant_conf"
fi
case " ${command_args}" in
*" -u"*);;
*) if yesno "${wpa_supplicant_dbus}"; then
command_args="-u ${command_args}"
fi
;;
esac
checkpath -d -m 0755 -o root:root /var/run/wpa_supplicant
}
@@ -59,6 +59,15 @@ if [ -r /sys/class/power_supply/pm8916-lbc-chgr/constant_charge_current ]; then
fi
fi
# K5: the kernel patch raises the GPU devfreq sampling interval to 100 ms;
# this also fixes devices that already loaded the older module.
if [ -w /sys/class/devfreq/1c00000.gpu/polling_interval ]; then
printf '100\n' > /sys/class/devfreq/1c00000.gpu/polling_interval 2>/dev/null || true
fi
# K10: no IPv6 on interfaces created after boot (also in sysctl.d).
{ printf '1\n' > /proc/sys/net/ipv6/conf/default/disable_ipv6; } 2>/dev/null || true
# Wi-Fi power save is enabled by NetworkManager (wifi.powersave=3) and by the
# wcn36xx WIPHY_FLAG_PS_ON_BY_DEFAULT / dynamic_ps_timeout=200 kernel patch.
# Verified on-device: "iw dev wlan0 get power_save" reports "Power save: on".
@@ -20,7 +20,14 @@ 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
mkdir -p /tmp/superd_state/superd/logs "$HOME/.local/state/superd/logs" 2>/dev/null || true
ln -sf /dev/null /tmp/superd_state/superd.log 2>/dev/null || true
for svc in /usr/share/superd/services/*.service "$HOME/.config/superd/services"/*.service; do
[ -f "$svc" ] || continue
svc_name="$(basename "$svc" .service)"
ln -sf /dev/null "/tmp/superd_state/superd/logs/${svc_name}.log" 2>/dev/null || true
done
sxmo_jobs.sh start daemon_manager env XDG_STATE_HOME=/tmp/superd_state superd -l /dev/null
while ! superctl status > /dev/null 2>&1; do
sleep 0.05
done
@@ -63,7 +70,7 @@ fi
# Periodically update some status bar components
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 300 \
sxmo_hook_statusbar.sh periodics
# dunst is required for warnings.
@@ -81,12 +88,11 @@ if [ "$(command -v fcitx5)" ]; then
fi
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
# Keep system awake so keypad, lid, and power keys always wake the screen immediately
# U1/U2: idle blanking and deep standby are enabled by default; the
# keypad/lid/power keys still wake the screen immediately.
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
fi
# U2: no infinite wakelock; deep standby is guarded by
# /etc/bananarchy-no-deep-standby and the blocker list.
# 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
@@ -0,0 +1,4 @@
# K10: no IPv6 addresses on interfaces created after boot (wlan0, usb0,
# VPN tunnels). Removes ND/MLD multicast that keeps Wi-Fi out of BMPS.
# The ipv6 module stays loaded for WireGuard/Tor and for ::1 on lo.
net.ipv6.conf.default.disable_ipv6=1
@@ -1 +1,5 @@
SUBSYSTEM=="power_supply", ACTION=="change", RUN+="/bin/sh -c 'DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 /usr/share/sxmo/default_hooks/sxmo_hook_battery.sh udev >/dev/null 2>&1 &'"
# Bananarchy battery/charger statusbar hook (U4).
# Only the two PM8916 supplies exist on these devices; filtering avoids
# spawning a shell for unrelated power_supply change events.
SUBSYSTEM=="power_supply", ACTION=="change", KERNEL=="pm8916-bms-vm", RUN+="/bin/sh -c 'DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 /usr/share/sxmo/default_hooks/sxmo_hook_battery.sh udev >/dev/null 2>&1 &'"
SUBSYSTEM=="power_supply", ACTION=="change", KERNEL=="pm8916-lbc-chgr", RUN+="/bin/sh -c 'DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 /usr/share/sxmo/default_hooks/sxmo_hook_battery.sh udev >/dev/null 2>&1 &'"
@@ -20,7 +20,14 @@ 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
mkdir -p /tmp/superd_state/superd/logs "$HOME/.local/state/superd/logs" 2>/dev/null || true
ln -sf /dev/null /tmp/superd_state/superd.log 2>/dev/null || true
for svc in /usr/share/superd/services/*.service "$HOME/.config/superd/services"/*.service; do
[ -f "$svc" ] || continue
svc_name="$(basename "$svc" .service)"
ln -sf /dev/null "/tmp/superd_state/superd/logs/${svc_name}.log" 2>/dev/null || true
done
sxmo_jobs.sh start daemon_manager env XDG_STATE_HOME=/tmp/superd_state superd -l /dev/null
while ! superctl status > /dev/null 2>&1; do
sleep 0.05
done
@@ -63,7 +70,7 @@ fi
# Periodically update some status bar components
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 300 \
sxmo_hook_statusbar.sh periodics
# dunst is required for warnings.
@@ -81,12 +88,11 @@ if [ "$(command -v fcitx5)" ]; then
fi
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
# Keep system awake so keypad, lid, and power keys always wake the screen immediately
# U1/U2: idle blanking and deep standby are enabled by default; the
# keypad/lid/power keys still wake the screen immediately.
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
fi
# U2: no infinite wakelock; deep standby is guarded by
# /etc/bananarchy-no-deep-standby and the blocker list.
# 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
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
# Enter deep standby when the screen is off (U2). Disable by creating
# /etc/bananarchy-no-deep-standby. Enable suspend-to-RAM by creating
# /etc/bananarchy-allow-mem-suspend (only after verifying wake sources).
[ -f /etc/bananarchy-no-deep-standby ] && exit 0
[ -x /usr/bin/bananarchy-suspend.sh ] || exit 0
[ -r /sys/power/state ] || exit 0
# Blockers: an active call, an SSH session, or an active VPN/tether must
# keep the system awake.
incall=0
[ -r /tmp/sxmo_in_call ] && { read -r incall < /tmp/sxmo_in_call 2>/dev/null || incall=0; }
[ "$incall" = "1" ] && exit 0
pgrep -f 'sxmo_modemcall.sh' >/dev/null 2>&1 && exit 0
pgrep -f 'sshd-session' >/dev/null 2>&1 && exit 0
if command -v nmcli >/dev/null 2>&1; then
nmcli -t con show --active 2>/dev/null | grep -qE ':tun|:wireguard|^Hotspot' && exit 0
fi
# The screen must still be dark.
br=1
[ -r /sys/class/backlight/backlight/brightness ] && \
{ read -r br < /sys/class/backlight/backlight/brightness 2>/dev/null || br=1; }
case "$br" in ''|*[!0-9]*) br=1 ;; esac
[ "$br" -eq 0 ] || exit 0
exec doas -n /usr/bin/bananarchy-suspend.sh
+17
View File
@@ -0,0 +1,17 @@
#!/bin/sh
# Open/close the QMI BAM-DMUX data port on demand (U9/K11).
# With Wi-Fi as the default route and no cellular data profile there is no
# reason to keep the modem data plane open at boot.
QMICLI="qmicli --silent -pd qrtr://0"
case "${1:-}" in
open)
$QMICLI --dpm-open-port=hw-data-ep-type=bam-dmux,hw-data-ep-iface-number=1,hw-data-rx-id=1,hw-data-tx-id=1 >/dev/null 2>&1 || true
;;
close)
$QMICLI --dpm-close-port=hw-data-ep-type=bam-dmux,hw-data-ep-iface-number=1,hw-data-rx-id=1,hw-data-tx-id=1 >/dev/null 2>&1 || true
;;
*)
printf 'Usage: %s [open|close]\n' "${0##*/}" >&2
exit 1
;;
esac
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
# Blank/restore the display without engaging the passcode locker (U1).
# sxmo_wm.sh display off/on already handles brightness, bl_power, DPMS,
# the CPU governor and the keyboard backlight.
case "${1:-}" in
off) exec /usr/bin/sxmo_wm.sh display off ;;
on) exec /usr/bin/sxmo_wm.sh display on ;;
*)
printf 'Usage: %s [off|on]\n' "${0##*/}" >&2
exit 1
;;
esac
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# Root helper: enter the deepest *safe* system sleep state.
# Called via doas from bananarchy-deep-standby.sh.
STATE_FILE=/sys/power/state
[ -r "$STATE_FILE" ] || exit 0
states=""
read -r states < "$STATE_FILE" 2>/dev/null || states=""
target=""
# freeze (s2idle) keeps every IRQ wake-capable, so keypad, lid, modem and
# Wi-Fi always resume the phone. mem needs platform wakeup sources and is
# therefore opt-in.
case " $states " in *" freeze "*) target=freeze ;; esac
if [ -f /etc/bananarchy-allow-mem-suspend ]; then
case " $states " in *" mem "*) target=mem ;; esac
fi
[ -n "$target" ] || exit 0
# This write blocks until the system resumes.
printf '%s\n' "$target" > "$STATE_FILE"
@@ -64,7 +64,10 @@ else
/tmp/tinydm.log /tmp/tinydm.log.old /tmp/Xorg.0.log /tmp/Xorg.0.log.old 2>/dev/null || true
fi
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"
# U1/U2: do not force sxmo.noidle / sxmo.nosuspend. Idle blanking and
# deep standby are the defaults; create ~/.cache/sxmo/sxmo.noidle to opt out
# of idle blanking, or /etc/bananarchy-no-deep-standby to opt out of suspend.
rm -f "$XDG_CACHE_HOME/sxmo/sxmo.nosuspend"
[ -n "${DBUS_SESSION_BUS_ADDRESS:-}" ] && printf "%s\n" "$DBUS_SESSION_BUS_ADDRESS" > "$XDG_RUNTIME_DIR/dbus.bus"
printf "1\n" > /tmp/bananarchy_screen_locked
printf "lock\n" > "$XDG_RUNTIME_DIR/sxmo.state"
@@ -143,8 +146,17 @@ while [ "$(cat "$SESSION_PID_FILE" 2>/dev/null)" = "$$" ]; do
if pidof -s dwm >/dev/null 2>&1; then
exit 0
fi
xrdb -merge "$HOME/.Xresources" >/dev/null 2>&1 || true
/usr/bin/bananarchy-sync-dunst-theme --no-restart >/dev/null 2>&1 || true
# U14: skip X resource/wallpaper work when the panel is powered down.
_dark=0
if [ -r /sys/class/backlight/backlight/brightness ]; then
_bl=1
read -r _bl < /sys/class/backlight/backlight/brightness 2>/dev/null || _bl=1
[ "${_bl:-1}" = "0" ] && _dark=1
fi
if [ "$_dark" = "0" ]; then
xrdb -merge "$HOME/.Xresources" >/dev/null 2>&1 || true
/usr/bin/bananarchy-sync-dunst-theme --no-restart >/dev/null 2>&1 || true
fi
WP_FILE="/usr/share/wallpapers/bananarchy.png"
if [ -f "$XDG_CONFIG_HOME/sxmo/wallpaper" ]; then
custom_wp="$(head -n 1 "$XDG_CONFIG_HOME/sxmo/wallpaper" 2>/dev/null)"
@@ -161,7 +173,7 @@ while [ "$(cat "$SESSION_PID_FILE" 2>/dev/null)" = "$$" ]; do
*) WP_FLAG="--bg-fill" ;;
esac
fi
( feh --no-fehbg "$WP_FLAG" "$WP_FILE" >/dev/null 2>&1 </dev/null & )
if [ "$_dark" = "0" ]; then ( feh --no-fehbg "$WP_FLAG" "$WP_FILE" >/dev/null 2>&1 </dev/null & ); fi
if [ "$first_iter" = "0" ]; then
pidof -s fcitx5 >/dev/null 2>&1 || superctl start fcitx5 >/dev/null 2>&1 || ( /usr/bin/bananarchy-fcitx5.sh </dev/null & )
fi
+11 -2
View File
@@ -1,3 +1,12 @@
#!/bin/sh
# Autosuspend is disabled on Bananarchy so keypad, lid, and power keys always wake the screen immediately.
exit 0
# Wait for a grace period after screen-off, then enter deep standby once (U2).
# The write to /sys/power/state blocks until resume, so this job exits after
# one suspend cycle; sxmo_hook_unlock.sh/postwake.sh cancel it on wake.
[ -f /etc/bananarchy-no-deep-standby ] && exit 0
sleep "${BANANARCHY_SUSPEND_GRACE:-60}"
br=1
[ -r /sys/class/backlight/backlight/brightness ] && \
{ read -r br < /sys/class/backlight/backlight/brightness 2>/dev/null || br=1; }
case "$br" in ''|*[!0-9]*) br=1 ;; esac
[ "$br" -eq 0 ] || exit 0
exec /usr/bin/bananarchy-deep-standby.sh
+2 -2
View File
@@ -75,9 +75,9 @@ mainloop() {
else
/usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
fi
sleep 10
sleep 30
else
sleep 120
sleep 600
fi
done
) &
+2 -1
View File
@@ -180,5 +180,6 @@ monitor_jack_events &
while : ; do
handle_change || true
sleep 2
# U10: pactl subscribe is event-driven; only back off after a failure.
sleep 10
done
+3 -1
View File
@@ -16,7 +16,9 @@ SXMO_SUSPENDABLE_STATES="${SXMO_SUSPENDABLE_STATES:-screenoff 3}"
transition_can_suspend() {
sxmo_jobs.sh stop idle_suspender 2>/dev/null || true
sxmo_wakelock.sh lock sxmo_not_suspendable infinite 2>/dev/null || true
# U2: no infinite wakelock. Deep standby is guarded by
# /etc/bananarchy-no-deep-standby and the blocker list instead.
:
}
transition() {
+2 -2
View File
@@ -1,3 +1,3 @@
#!/bin/sh
# System suspend is disabled on Bananarchy so keypad, lid, and power keys always wake the screen immediately.
exit 0
# Bananarchy deep standby (U2). Guarded by /etc/bananarchy-no-deep-standby.
exec /usr/bin/bananarchy-deep-standby.sh
+7
View File
@@ -52,6 +52,10 @@ xorgdisplay() {
if [ -w /sys/devices/system/cpu/cpufreq/policy0/scaling_governor ]; then
printf 'powersave\n' > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor 2>/dev/null || true
fi
# K5: pin the Adreno 304 devfreq to its minimum OPP while dark.
if [ -w /sys/class/devfreq/1c00000.gpu/governor ]; then
printf 'powersave\n' > /sys/class/devfreq/1c00000.gpu/governor 2>/dev/null || true
fi
xset s off s noblank >/dev/null 2>&1 || true
xset dpms force off >/dev/null 2>&1 || true
;;
@@ -59,6 +63,9 @@ xorgdisplay() {
if [ -w /sys/devices/system/cpu/cpufreq/policy0/scaling_governor ]; then
printf 'schedutil\n' > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor 2>/dev/null || true
fi
if [ -w /sys/class/devfreq/1c00000.gpu/governor ]; then
printf 'simple_ondemand\n' > /sys/class/devfreq/1c00000.gpu/governor 2>/dev/null || true
fi
xset s off s noblank >/dev/null 2>&1 || true
xset dpms force on >/dev/null 2>&1 || true
if [ -w /sys/class/backlight/backlight/bl_power ]; then
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
# K8: no earlycon / serial console. console=ttyMSM0 keeps the UART
# clock on and produces printk wakeups. Re-add for a debug build.
@@ -0,0 +1,2 @@
# K8: no earlycon / serial console. console=ttyMSM0 keeps the UART
# clock on and produces printk wakeups. Re-add for a debug build.
@@ -0,0 +1,2 @@
# K8: no earlycon / serial console. console=ttyMSM0 keeps the UART
# clock on and produces printk wakeups. Re-add for a debug build.
@@ -0,0 +1,2 @@
# K8: no earlycon / serial console. console=ttyMSM0 keeps the UART
# clock on and produces printk wakeups. Re-add for a debug build.
@@ -0,0 +1,2 @@
# K8: no earlycon / serial console. console=ttyMSM0 keeps the UART
# clock on and produces printk wakeups. Re-add for a debug build.
@@ -3121,7 +3121,7 @@ while True:
elif os.path.exists("/tmp/bananarchy_screen_locked"):
poll_timeout = None
else:
poll_timeout = 600.0
poll_timeout = 1800.0
r, _, _ = select.select([ws, vs], [], [], poll_timeout)
got_voice_ind = False
events = []
@@ -3186,7 +3186,7 @@ while True:
if full_tlvs:
sync_sub1_calls(parse_call_info(full_tlvs), sec_slot, vs, voice_addr)
if not os.path.exists("/tmp/bananarchy_screen_locked") and time.time() - last_poll >= 600.0:
if not os.path.exists("/tmp/bananarchy_screen_locked") and time.time() - last_poll >= 1800.0:
w_txn = poll_stored_sms(ws, wms_addr, w_txn, sec_slot)
last_poll = time.time()
except Exception:
@@ -3194,7 +3194,8 @@ while True:
finally:
ws.close()
vs.close()
time.sleep(2)
# U9: back off after a QRTR error instead of re-registering every 2 s.
time.sleep(30)
PY
;;
@@ -17,9 +17,8 @@ FORCE_UPDATE=0
if [ "${1:-}" = "udev" ]; then
object="/org/freedesktop/UPower/devices/battery_default"
event="device changed"
if [ "${2:-}" != "recheck" ]; then
(sleep 2; "$0" udev recheck >/dev/null 2>&1) &
fi
# U4: no 2 s recheck fork. Kernel patch 0006 emits a uevent only when
# the reported capacity actually changes, so one event is sufficient.
elif [ "${1:-}" = "force" ]; then
FORCE_UPDATE=1
object="/org/freedesktop/UPower/devices/battery_default"
@@ -7,6 +7,13 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
# U2: cancel a pending deep-standby job after resume.
if [ -r /tmp/bananarchy_autosuspend.pid ]; then
read -r _as_pid < /tmp/bananarchy_autosuspend.pid 2>/dev/null || _as_pid=""
[ -n "$_as_pid" ] && kill "$_as_pid" 2>/dev/null || true
rm -f /tmp/bananarchy_autosuspend.pid
fi
if [ -z "$SXMO_NO_MODEM" ]; then
MMCLI="$(mmcli -m any -J 2>/dev/null)"
if [ -z "$MMCLI" ]; then
@@ -38,4 +38,8 @@ fi
sxmo_jobs.sh stop idle_locker
# U2: enter deep standby after BANANARCHY_SUSPEND_GRACE seconds of screen-off.
( /usr/bin/sxmo_autosuspend.sh >/dev/null 2>&1 & \
printf '%s\n' "$!" > /tmp/bananarchy_autosuspend.pid )
wait
@@ -78,7 +78,7 @@ fi
# Periodically update some status bar components
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 300 \
sxmo_hook_statusbar.sh periodics
# dunst is required for warnings.
@@ -96,12 +96,11 @@ if [ "$(command -v fcitx5)" ]; then
fi
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
# Keep system awake so keypad, lid, and power keys always wake the screen immediately
# U1/U2: idle blanking and deep standby are enabled by default; the
# keypad/lid/power keys still wake the screen immediately.
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
fi
# U2: no infinite wakelock; deep standby is guarded by
# /etc/bananarchy-no-deep-standby and the blocker list.
# 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
@@ -534,18 +534,14 @@ case "$1" in
sxmo_hook_battery.sh force 2>/dev/null || true
fi
;;
periodics) # 60 s loop
periodics) # 300 s loop (U3): no QMI/D-Bus polls on every tick
if is_screen_dark || [ -f /tmp/bananarchy_screen_locked ]; then
exit 0
fi
set_time
set_inputmethod
if [ -z "$SXMO_NO_MODEM" ]; then
set_modem
fi
set_notch
set_state
set_network wifi wlan0
sxmo_hook_battery.sh 2>/dev/null || true
;;
all)
@@ -570,5 +566,12 @@ case "$1" in
esac
if ! is_screen_dark && [ "${SXMO_WM:-dwm}" = "dwm" ] && command -v xsetroot >/dev/null 2>&1; then
DISPLAY="${DISPLAY:-:0}" xsetroot -name "$(sxmo_status.sh)" 2>/dev/null || true
_bar="$(sxmo_status.sh)"
_bar_cache="${XDG_RUNTIME_DIR:-/run/user/10000}/sxmo_status_bar_cache"
_bar_prev=""
[ -r "$_bar_cache" ] && { read -r _bar_prev < "$_bar_cache" 2>/dev/null || _bar_prev=""; }
if [ "$_bar" != "$_bar_prev" ]; then
printf '%s\n' "$_bar" > "$_bar_cache" 2>/dev/null || true
DISPLAY="${DISPLAY:-:0}" xsetroot -name "$_bar" 2>/dev/null || true
fi
fi
@@ -26,11 +26,21 @@ sxmo_jobs.sh stop periodic_wakelock_check
# Re-enable automatic screen-off on idle to save battery. Locking stays
# explicit (the user locks only on request); we only blank the display.
# U2: cancel a pending deep-standby job on wake.
if [ -r /tmp/bananarchy_autosuspend.pid ]; then
read -r _as_pid < /tmp/bananarchy_autosuspend.pid 2>/dev/null || _as_pid=""
[ -n "$_as_pid" ] && kill "$_as_pid" 2>/dev/null || true
rm -f /tmp/bananarchy_autosuspend.pid
fi
# U1: blank the display after an idle timeout without engaging the locker.
# Create ~/.cache/sxmo/sxmo.noidle to restore the old "never blank" policy.
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"'
timeout "${SXMO_UNLOCK_IDLE_TIME:-60}" 'sh -c "/usr/bin/bananarchy-idle-blank.sh off"' \
resume 'sh -c "/usr/bin/bananarchy-idle-blank.sh on"'
fi
wait