Repository navigation
omamobile-settings: lock screen timeout, and lock after 30 minutes while a keyboard is connected - #866
omamobile-settings: lock screen timeout, and lock after 30 minutes while a keyboard is connected#866Somnius wants to merge 15 commits into
Conversation
|
Thank you, Lef. There is a lot of care in this: nothing is written until the owner picks something, It can't merge as it is, though, and the main reason is the step that makes a new time take effect:
Smaller: a broken If you'd like something in sooner: "Lock screen after" on its own, with |
9b9ce51 to
d1a5618
Compare
|
Thanks @derekross, that's a big one, I didn't know
The small ones: a broken test/all passes on my desktop. The kernel release, package versions and a |
|
@derekross your point 2, the readings. On my 8 Pro (omarchy 4.0.6-1, quickshell 0.3.2.r7.g2b4501a-1, hyprland 0.57.0-3.2):
So the service gets the new number by itself, as you read it. But the phone still never locked: untouched and unlocked for 100 s after a change to 30 s, no idle at all, not even at the old timeout. A standalone That's a bug in the idle service, so as you said it goes in our Omarchy patch series: #879. With it, a change to 30 s locked 30 s later on the phone. With that in, this PR's |
|
Thank you, Lef. This is the change I asked for and then some. The idle toggle is gone and nothing in the package calls an What is left before it can merge:
For the merge: I'm changing the order I gave last time. #860 is now inert on every phone until the charger work lands, so I'll take it first as 0.1.3, and this one rebased onto it becomes 0.1.4. The conflicts are all "keep both"; in |
|
@derekross done in d85aca6:
test/all passes here. The phone run on 4.5 comes after #879's package is on my 8 Pro, and I'll post it here. |
ActionRunner and Backend's start-up probe take a backend directory (setBackendDir, as in derekross#866); the probe now starts from the event loop so the setter applies. The Qt tests point both at stub charge.sh scripts and check the available and not-available answers. The helper test adds supply=../power_supply/max77759-charger, which only the name check refuses. README: the Battery row needs the charger present at start.
derekross
left a comment
There was a problem hiding this comment.
Thank you, Lef. "Never" is out the way I hoped (a 0 set by hand still works and the page says so, and the keyboard rule still leaves it alone), the dependency on #879 is there, and the new title and description match the code. I ran test/lock-backend.sh and test/display-backend.sh on this head here; both pass, and CI is green.
Two things are left, neither a change of design:
-
The run on your phone, on 4.5, with #879's package installed. Your 8 Pro has both now, so whenever you get to it:
pacman -Q omarchy quickshell omamobile-omarchy omamobile-settings,uname -r, atools/phone-smokereport, and then each lock time set from Settings opened on the home screen withomarchy-shell idle statusbefore and after, and one of them left to lock; the Display page scrolled to its end with a screenshot (the scroll view is new since my last look); the toggle with your Bluetooth keyboard (shell.jsonat 1800 while connected, your time back when it goes,systemctl --user status omamobile-lock-keyboard); a reboot with the toggle on and the keyboard connected, and one with it off; and whatreloadConfigdoes from the unit's stop at the end of a session. I'll run the page on my Pixel 7 Pro before merging as well. -
A rebase once #860 is in, which I'm merging first as 0.1.3. The two conflict in seven files, all "keep both": in
dependskeepcoreutilsbeforesystemdand youromamobile-omarchyentry; the runner's list becomes display, charge, lock, andsetBackendDiris the same on both sides; #860's core tests now point everyBackendat stub directories, so yours should too. Please take 0.1.4.
On the dependency number: I plan to merge #879 as 0.1.49 ahead of #610, so >=0.1.49 stays right. If that changes I'll say so here.
…hout it Some launch paths (the shell's processes) don't pass HYPRLAND_INSTANCE_SIGNATURE, so hyprctl found no Hyprland and the Display page lost its refresh rate rows. display.sh now takes it from the newest live socket under $XDG_RUNTIME_DIR/hypr.
backends/lock.sh reads and sets the screen lock time (Omarchy's idle.lock in shell.json, the one timer that locks and then turns the screen off), and with the keyboard toggle on writes 0 there while a Bluetooth or USB keyboard is connected. The choice is kept in ~/.config/omamobile/lock.json; a value changed in Omarchy's own settings is adopted, and nothing is written before the user picks something. omamobile-lock-keyboard (a user unit) runs apply at start and after each burst of input udev events. Tests use a fake sysfs and udev data.
… keyboard The Display page gets 30 s, 1, 2, 3, 5 min and Never, plus an on/off for staying unlocked while a keyboard is connected. The text says that lock and screen off are the same timer and that Never also keeps the phone awake. 0.1.3 clashes with open derekross#629, derekross#630 and derekross#860; renumber at merge.
lock.json (with an override flag) is saved before shell.json, so our own 0 is never adopted as the user's Never. Both files under one flock, mkstemp temp files with fsync, shell.json read again just before the write. An unparseable or other-version shell.json is an error and nothing is written. The 0 is only written while the watcher runs; the unit restarts always and puts the choice back with lock.sh restore on stop. The watcher exits non-zero when udevadm monitor ends or an apply fails, and skips the udevadm header line. Keyboards need the letter keys and space and a name that isn't a token or scanner.
The lock tests no longer depend on whether the backend is installed on the host.
…n brightnessctl can't Settings started from a login outside the graphical session (for example over SSH) is not in the logind session that owns the screen, so brightnessctl's SetBrightness on the caller's session is refused and the buttons did nothing. Fall back to the user's graphical session (loginctl Display) by its object path.
…ng the shell Omarchy's idle service keeps the timeout its idle monitor was made with, so a lock time changed on the page only applied after the shell restarted (seen on the 8 Pro: 30 s set live never locked, and locked 30 s after a shell restart). After writing idle.lock, switch idle off and on through its IPC when idle is on and stay-awake is off. Tests never touch the host's idle service.
…er leave it off From review: the keyboard watcher calls apply after every input change, and each re-arm restarts the idle countdown, so re-arm only when idle.lock was really written. If idle doesn't come back on after disable, retry and fail loudly instead of leaving the phone never locking.
… 30 min lock with a keyboard Following Derek's review: a new idle.lock now reaches the running shell through `omarchy-shell shell reloadConfig`, the same way omarchy-shell-config does it. The idle disable/enable step is gone, so Stay awake is never touched. If the reload fails, the value stays saved and the JSON carries an error the page shows. A failed reload stays pending in lock.json and is retried on the next run until it works. If the watcher cannot be started the toggle goes back to off; turning it off does not wait for the unit (--no-block), since the backend has already written the choice back. With a keyboard connected the lock is now 1800 s instead of never (a chosen Never stays never). The watcher unit is no longer enabled for everyone: the toggle enables and starts it, and turning it off stops and disables it, which restores the choice. A failed apply (a broken shell.json) is logged once instead of restarting the unit every 10 s. lock.json is only rewritten when it changed, and depends now lists coreutils and systemd.
On the 8 Pro the keyboard toggle's text ran off the bottom of the page and couldn't be reached. The page is now a ScrollView like the About page.
…e idle re-arm A phone that never locks by itself isn't offered one tap away; a 0 set by hand in shell.json still means no idle lock, and the page says so. depends names omamobile-omarchy>=0.1.49 (derekross#879, the number is set at merge): without its re-arm, changing the lock time on a running shell leaves the phone with no idle lock until the shell restarts.
d85aca6 to
854e4fb
Compare
|
@derekross rebased on main with #860 in, and it's 0.1.4 now. The conflicts went the way you listed: |
…cher if lock.json says on An older build could leave keyboardAwake on in lock.json with the unit never enabled, so the page showed On while nothing watched keyboards. lock.sh get now enables+starts the unit in that case and disables it when the choice is off but the unit is enabled. Never on a missing or broken lock.json; a systemctl failure comes back as an error in the JSON.
The choice is read again under the same flock as set, so a set landing meanwhile waits and wins. Only enabled/enabled-runtime and disabled from is-enabled count; anything else is reported and nothing is done.
|
@derekross the run you asked for, on my 8 Pro. Versions:
One bug the run found, fixed in two commits now on the branch: after an upgrade from my older build, |
In CI the racing set keyboard off ends up a child of the container's PID 1, which never reaps it, so kill -0 kept seeing the zombie and the loop never ended (the suite was stopped after 1800 s). The racer's group also gets its own stdout, so it can't hold get's command substitution open.
|
@derekross the CI hang on this one was my new race test in The red that's left is in omamobile-shell, which this PR doesn't touch: |
This adds two things to the Display page in Settings: "Lock screen after" (30 s, 1, 2, 3 or 5 min) and "Lock after 30 minutes while a keyboard is connected", Bluetooth or USB. It also fixes two things I hit on the same page on my Pixel 8 Pro, and the page scrolls now.
It builds on the Settings app @marselnenaj started in #526. It's a great app to have on the phone, so I'd rather keep adding pages to it.
How the lock works: the phone has one timer. Omarchy's idle service locks after
idle.lockseconds from shell.json, and the lock screen blanks a few seconds later, so the page says lock and screen off are the same timer. There's no Never: a phone that never locks by itself isn't offered one tap away. A 0 set by hand in shell.json still means no idle lock, and the page says so. After writing shell.json the backend runsomarchy-shell shell reloadConfig; it never touches idle on/off or Stay awake.A changed lock time on a running shell only works with the re-arm from #879 (#879): without it the phone stops locking by itself until the shell restarts. So
dependsnamesomamobile-omarchy>=0.1.49, and this should merge after #879. The number follows whatever #879 lands as.The keyboard part is a small user service that runs only while the toggle is on. It watches udev and writes 1800 to idle.lock while a keyboard is connected, then puts the chosen time back. lock.json is written before shell.json and marks the 1800 as ours, so a crash in between can't leave our value behind as if it were the user's, and the unit restores the chosen time when it stops. It doesn't restart on a broken shell.json and doesn't rewrite lock.json when nothing changed. It counts devices udev calls keyboards with the letter keys and space, on Bluetooth or real USB, so the phone's own keys, the OSK, uinput and headphone buttons don't count. A USB receiver or dock that exposes a full keyboard still counts; that's a known limit.
The two fixes, as separate commits, both for Settings started from a login outside the graphical session (that's how I opened it when I saw them, over SSH):
Testing: on my desktop test/all passes, with tests for the lock backend (stand-ins for omarchy-shell and systemctl), the watcher, the missing signature, and the 5 lock choices. On the phone, the first version of this ran on Omarchy 4.0.6: 1 min then 30 s from the page locked 30 s later, and with my Dell KB7120W over Bluetooth the watcher wrote its value about 2 s after connect and put my 3 min back after the keyboard went off. This head hasn't run on the phone yet. My 8 Pro is on Omarchy 4.5.0-3 now, and I’ll post the run from the review (lock times from Settings opened on the home screen, the keyboard toggle, reboots with it on and off, reloadConfig at session end) once #879’s package is on it.
Version: the numbers get set at merge (#860 first as 0.1.3, then this as 0.1.4).