diff --git a/packages/omamobile-shell/bin/omamobile-setup-user b/packages/omamobile-shell/bin/omamobile-setup-user index b6f4c60cd..a8e0ba60a 100755 --- a/packages/omamobile-shell/bin/omamobile-setup-user +++ b/packages/omamobile-shell/bin/omamobile-setup-user @@ -328,6 +328,18 @@ if omarchy-done ensure omamobile-chromium-mobile; then echo "\"--user-agent=Mozilla/5.0 (Linux; Android 14; Pixel 7 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${major:-153}.0.0.0 Mobile Safari/537.36\"" >>"$flags" fi +# Auto-sleep (omamobile-sleepd: s2idle 30 s after the screen goes off behind +# a secure lock), once, on a phone whose device package says its suspend is +# verified (/usr/share/omamobile/auto-sleep-default; device/'s +# SUSPEND-PLAN). The user's later choice stays: this runs once, and the +# toggle (omarchy-toggle omamobile-sleep off) turns it off for good. With the +# modem up the phone still doesn't sleep: the modem holds a sleep inhibitor. +if [[ -e ${OMAMOBILE_AUTO_SLEEP_DEFAULT:-/usr/share/omamobile/auto-sleep-default} ]] && + omarchy-done ensure omamobile-auto-sleep-on; then + mkdir -p ~/.local/state/omarchy/toggles + touch ~/.local/state/omarchy/toggles/omamobile-sleep +fi + # Lock screen: Omarchy's lock with a number pad (lock-keypad toggle, see # patches/omarchy/0003-*), since its session lock hides the on-screen keyboard. if omarchy-done ensure omamobile-lock-keypad; then diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 30dcb5f16..85affa2b1 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -1206,9 +1206,15 @@ grep -cx 'ExecStart=/usr/bin/omamobile-weather' systemd/user/omamobile-weather.s && grep -cx 'Unit=omamobile-weather.service' systemd/user/omamobile-weather.timer >/dev/null \ || fail "the weather timer runs the one-shot service every 30 minutes" pass "the lock screen's weather runs at login and every 30 minutes" -if grep -rnE '^[^#]*(omarchy-toggle omamobile-sleep( on| toggle|$)|toggles/omamobile-sleep)' bin install systemd plugins; then - fail "nothing turns the omamobile-sleep toggle on by default" +# Auto-sleep is on by default only where the device package says suspend is +# verified: setup-user's one step, gated on auto-sleep-default (its behaviour +# is test/setup-user.sh's). Nothing else turns the toggle on. +if grep -rnE '^[^#]*(omarchy-toggle omamobile-sleep( on| toggle|$)|toggles/omamobile-sleep)' bin install systemd plugins | + grep -vE '^bin/omamobile-setup-user:[0-9]+: touch ~/\.local/state/omarchy/toggles/omamobile-sleep$'; then + fail "nothing but the device-gated setup step turns the omamobile-sleep toggle on by default" fi +grep -B3 'touch ~/.local/state/omarchy/toggles/omamobile-sleep$' bin/omamobile-setup-user | grep -c 'auto-sleep-default' >/dev/null || + fail "setup-user turns auto-sleep on only behind the device's auto-sleep-default" [[ -x $tmp/root/usr/bin/omamobile-setup-user ]] || fail "setup-user is installed where the unit runs it" [[ -x $tmp/root/usr/bin/omamobile-portal-access && -f $tmp/root/usr/share/xdg-desktop-portal/portals/omamobile.portal \ && -f $tmp/root/etc/xdg/xdg-desktop-portal/hyprland-portals.conf \ diff --git a/packages/omamobile-shell/test/setup-user.sh b/packages/omamobile-shell/test/setup-user.sh index 45621364d..5642ed59b 100644 --- a/packages/omamobile-shell/test/setup-user.sh +++ b/packages/omamobile-shell/test/setup-user.sh @@ -75,6 +75,7 @@ run() { OMAMOBILE_VOICE_MODELS="${RUN_VOICE_MODELS:-$t/no-voice-models}" OMAMOBILE_VOXTYPE="${RUN_VOXTYPE:-voxtype}" \ OMARCHY_PATH="${RUN_OMARCHY_PATH:-$t/omarchy}" \ OMAMOBILE_USER_UNITS="${RUN_USER_UNITS:-$t/no-user-units}" \ + OMAMOBILE_AUTO_SLEEP_DEFAULT="${RUN_AUTO_SLEEP:-$t/no-auto-sleep-default}" \ bash bin/omamobile-setup-user "$@" >"$t/out" 2>&1 || { cat "$t/out"; fail "omamobile-setup-user runs"; } } run @@ -484,3 +485,18 @@ for gliff in no yes; do done rm -f "$F/gliff-server" pass "Omarchy's remote session is off on every phone, once, with or without gliff, and a user can turn it back on" + +# Auto-sleep: on once where the device package says suspend is verified; +# off by default elsewhere; a user who turns it off keeps it off. +ha=$t/auto-sleep; mkdir -p "$ha/.config/hypr" "$ha/.local/state/omarchy/done" +cp "$H"/.config/hypr/*.lua "$ha/.config/hypr/" +touch "$ha/.local/state/omarchy/done/omamobile-shell-profile" +RUN_HOME=$ha run +[[ ! -e $ha/.local/state/omarchy/toggles/omamobile-sleep ]] || fail "no device flag: auto-sleep stays off" +touch "$t/auto-sleep-default" +RUN_HOME=$ha RUN_AUTO_SLEEP=$t/auto-sleep-default run +[[ -e $ha/.local/state/omarchy/toggles/omamobile-sleep ]] || fail "the device flag turns auto-sleep on" +rm "$ha/.local/state/omarchy/toggles/omamobile-sleep" +RUN_HOME=$ha RUN_AUTO_SLEEP=$t/auto-sleep-default run +[[ ! -e $ha/.local/state/omarchy/toggles/omamobile-sleep ]] || fail "a user who turns auto-sleep off keeps it off" +pass "auto-sleep: on once where the device says suspend is verified, a user's off kept" diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index 4f079a5e5..f548ee6e2 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.127 +0.2.129