Optimize kernel-to-userspace battery life across CAMSS, SPI runtime PM, dwm, NeoUI, and plugins
This commit is contained in:
1 parent
f112b6ae72
commit
456d3fbc42
61 files changed
+466
-148
No files matched your search
@@ -8,11 +8,11 @@
|
||||
. sxmo_common.sh
|
||||
|
||||
if [ -z "$SXMO_NO_MODEM" ]; then
|
||||
MMCLI="$(mmcli -m any -J 2>/dev/null)"
|
||||
if [ -z "$MMCLI" ]; then
|
||||
sxmo_notify_user.sh "Modem crashed! 30s recovery."
|
||||
sxmo_wakelock.sh lock sxmo_modem_crashed 30s
|
||||
fi
|
||||
MMCLI="$(mmcli -m any -J 2>/dev/null)"
|
||||
if [ -z "$MMCLI" ]; then
|
||||
sxmo_notify_user.sh "Modem crashed! 30s recovery."
|
||||
sxmo_wakelock.sh lock sxmo_modem_crashed 30s
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add here whatever you want to do
|
||||
@@ -15,6 +15,7 @@ cur_state=""
|
||||
[ "$cur_state" = "unlock" ] && exit 0
|
||||
|
||||
printf '1\n' > /tmp/bananarchy_screen_locked
|
||||
pkill -STOP -x conky 2>/dev/null || true
|
||||
|
||||
if [ -z "$SXMO_DISABLE_LEDS" ]; then
|
||||
sxmo_led.sh blink red blue &
|
||||
|
||||
@@ -10,52 +10,54 @@
|
||||
. 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
|
||||
@@ -68,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
|
||||
|
||||
@@ -76,7 +78,7 @@ 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
|
||||
@@ -85,23 +87,23 @@ sxmo_state.sh set lock
|
||||
|
||||
# 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
|
||||
( xlocker wake >/dev/null 2>&1 & )
|
||||
fi
|
||||
|
||||
# It watch network changes and update the status bar icon by example
|
||||
@@ -112,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
|
||||
) &
|
||||
)
|
||||
@@ -501,27 +501,43 @@ set_inputmethod() {
|
||||
sxmobar -a input-method 5 "$im_mode"
|
||||
}
|
||||
|
||||
is_screen_dark() {
|
||||
_st=""
|
||||
[ -r "$SXMO_STATE" ] && { read -r _st < "$SXMO_STATE" 2>/dev/null || true; }
|
||||
_bl=1
|
||||
[ -r /sys/class/backlight/backlight/brightness ] && { read -r _bl < /sys/class/backlight/backlight/brightness 2>/dev/null || _bl=1; }
|
||||
if [ "$_st" = "screenoff" ] || [ "${_bl:-1}" -le 0 ] 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
sxmo_debug "$@"
|
||||
case "$1" in
|
||||
network)
|
||||
is_screen_dark && exit 0
|
||||
shift
|
||||
set_network "$@"
|
||||
;;
|
||||
battery)
|
||||
is_screen_dark && exit 0
|
||||
shift
|
||||
set_battery "$@"
|
||||
;;
|
||||
time)
|
||||
is_screen_dark && exit 0
|
||||
set_time 1
|
||||
;;
|
||||
modem|volume|state|notifications|notch|inputmethod)
|
||||
modem|volume)
|
||||
is_screen_dark && exit 0
|
||||
set_"$1"
|
||||
;;
|
||||
state|notifications|notch|inputmethod)
|
||||
set_"$1"
|
||||
;;
|
||||
state_change)
|
||||
set_state
|
||||
cur_st=""
|
||||
[ -r "$SXMO_STATE" ] && { read -r cur_st < "$SXMO_STATE" 2>/dev/null || true; }
|
||||
if [ "$cur_st" != "screenoff" ]; then
|
||||
if ! is_screen_dark; then
|
||||
set_time
|
||||
set_inputmethod
|
||||
if [ -z "$SXMO_NO_MODEM" ]; then
|
||||
@@ -532,10 +548,7 @@ case "$1" in
|
||||
fi
|
||||
;;
|
||||
periodics) # 60 s loop
|
||||
cur_st=""
|
||||
[ -r "$SXMO_STATE" ] && { read -r cur_st < "$SXMO_STATE" 2>/dev/null || true; }
|
||||
cur_bl="$(cat /sys/class/backlight/backlight/brightness 2>/dev/null || echo 1)"
|
||||
if [ "$cur_st" = "screenoff" ] || [ "${cur_bl:-1}" -le 0 ] 2>/dev/null || [ -f /tmp/bananarchy_screen_locked ]; then
|
||||
if is_screen_dark || [ -f /tmp/bananarchy_screen_locked ]; then
|
||||
exit 0
|
||||
fi
|
||||
set_time
|
||||
@@ -569,6 +582,6 @@ case "$1" in
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${SXMO_WM:-dwm}" = "dwm" ] && command -v xsetroot >/dev/null 2>&1; then
|
||||
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
|
||||
fi
|
||||
@@ -10,27 +10,28 @@
|
||||
# This hook is called when the system becomes unlocked again
|
||||
|
||||
if [ -z "$SXMO_DISABLE_LEDS" ]; then
|
||||
sxmo_led.sh blink red green &
|
||||
sxmo_led.sh blink red green &
|
||||
fi
|
||||
|
||||
sxmo_wm.sh display on
|
||||
pkill -CONT -x conky 2>/dev/null || true
|
||||
( sxmo_hook_statusbar.sh state_change >/dev/null 2>&1 & )
|
||||
if [ -z "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then
|
||||
sxmo_wm.sh inputevent touchscreen on
|
||||
sxmo_wm.sh inputevent touchscreen on
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
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"'
|
||||
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