Repository navigation
omamobile-settings: a Battery page with a charge limit (80-100 %) for husky - #860
Conversation
|
Here's the page on my Pixel 8 Pro, and the overnight run with the limit at 90 %: it charged from 83 % to 90 % by about 00:10, then held at 89-90 % with the battery current near zero until morning. The page builds on omamobile-settings that @marselnenaj started in #526. It's a great app to have on the phone, so I'd rather add pages to it than keep separate scripts. |
|
Thank you, Lef. This is carefully built: the fixed argument list, the polkit rule limited to five instance names with the helper checking the value again, the charger written before the file is saved, the boot path that does nothing without a saved value, and tests for each refusal. I ran the helper in a scratch root and read it against derekross/linux-omarchy-mobile#266. On today's published kernel it is inert on every phone, as you say. The overnight chart at 90 % is nice to see. Four things before it can merge. The first two are about the other phones, because Settings is installed everywhere:
Smaller:
|
cf35ec9 to
72aa306
Compare
|
@derekross thanks. Reworked in 72aa306, rebased on main:
Husky is 0.1.16 here because #836 takes 0.1.15; I know you set the numbers at merge. Not done yet: the phone run you asked for in 4 ( |
|
Thank you, Lef. Both of the larger points are done the way I hoped, and I checked them by running the helper rather than reading it: in a scratch root shaped like a Pixel 7 Pro on a kernel with linux-omarchy-mobile#266 (a CI is red on this head, and it isn't yours: the one failure is One thing I'd like changed before I merge:
Smaller, as you like:
On order, I'm changing what I said last time. #866 now waits for #879 and for phone runs, and this one is inert on every phone until the charger work lands, so I'll take this one first as omamobile-settings 0.1.3 and #866 can be rebased onto it as 0.1.4 (the conflicts are all "keep both"; the one to watch is The phone run from my last comment still stands, and I understand it needs #266 in your kernel: |
…77759-charger The page runs backends/charge.sh like the Display page does. Setting a value runs systemctl start --no-ask-password omamobile-charge-limit@N.service (a polkit rule allows those five instances for the active local user), which runs libexec/charge-limit as root: start threshold 0 (resume 5 below), then the end threshold, and only then /etc/omamobile/charge-limit is saved. No writable end threshold or a failed write: exit 1, nothing saved. At boot a udev rule on the charger's add pulls in omamobile-charge-limit-apply.service, which applies the saved value on husky only (device tree google,zuma-husky). Units have StartLimitIntervalSec=0. Note: the page is inert on husky today. omamobile-device-husky blacklists max77759_charger, so there is no max77759-charger power supply and the page says the limit is not available until that blacklist is lifted. Version 0.1.3 (to be renumbered at merge; derekross#629 and derekross#630 hold 0.1.3/0.1.4). Tests: test/charge-backend.sh against a scratch root (backend, helper, a stand-in systemctl, polkit/unit/udev contents, staged paths and modes), core tests open BatteryPage and check the runner's charge entry.
…CTION filter With ACTION=="add" the apply unit never started at boot on a Pixel 8 Pro; with the filter gone it starts and sets the saved limit. Checked across a reboot on the phone.
…where the device package declares it Settings' charge backend and both paths of the root helper now need /usr/share/omamobile/charge-limit.conf (supply=NAME), which only omamobile-device-husky ships. The udev rule and the apply unit move to device-husky. The Battery row is hidden unless charge.sh get says a limit is available. The device-tree check (and its tr | grep -qx pipe) is gone, the udev comment is put back in order and the test message fixed.
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.
… backends too The separately built session test entrypoint sets both backend dirs from OMAMOBILE_SETTINGS_TEST_BACKENDS (a path that doesn't exist by default), so test/single-instance.py no longer runs the installed charge.sh. The runner test checks the stub's own answer, not only that the error isn't a refusal.
72aa306 to
7c586ae
Compare
|
@derekross done in c20a80d and 7c586ae:
Rebased on main. test/all and tools/pr-check pass here. When this and #866 meet, the conflicts are the comment and tool lists, the core tests side by side, PKGBUILD, README and install, all keep-both. |
derekross
left a comment
There was a problem hiding this comment.
Thank you, Lef. That is everything I asked for, and I checked it rather than read it: with the name check taken out of the helper, test/charge-backend.sh now fails on supply=../power_supply/max77759-charger ("accepted: 95"), where last round it stayed green; the Qt tests point every Backend and ActionRunner at stubs and run the page once with a limit and once without; and the test-only backend directory exists only in the separately built session test app, not in the shipped binary. CI is green on this head.
I'm merging this as omamobile-settings 0.1.3 and omamobile-device-husky 0.1.16. I'll write the squash message by hand, since the first commit still describes the device-tree check.
Two things follow from it:
- #866 now conflicts with main in seven files. They are all "keep both":
dependsis the union withcoreutilsbeforesystemd(your test checks that), the runner's list becomes display, charge, lock, andsetBackendDiris the same on both sides. It becomes 0.1.4. - The phone run stays as agreed, with the #266 re-runs:
uname -r, the package versions, atools/phone-smokereport,systemctl statusofomamobile-charge-limit@90.serviceand ofomamobile-charge-limit-apply.serviceafter a reboot, and one sleep with the cable in while the limit is holding. Until then nothing on any phone can reach the page.
… 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.


This adds a Battery page to omamobile-settings with a charge limit: 80, 85, 90, 95 or 100 %. It writes charge_control_end_threshold on the max77759-charger.
It depends on the charger PRs, starting with derekross/linux-omarchy-mobile#266. Without them there is no max77759-charger power supply on husky (omamobile-device-husky still blacklists max77759_charger), so the page just says the charge limit is not available.
How it works: the page calls backends/charge.sh like the Display page does. Setting a value runs
systemctl start --no-ask-password omamobile-charge-limit@N.service. A polkit rule lets the active local user start only those five instances, same pattern as the gnss and earpiece rules. The unit runs a small root helper that sets the start threshold to 0, then the end threshold, and only after that saves the value to /etc/omamobile/charge-limit (same file tegu uses). Anything other than 80/85/90/95/100 is refused.At boot a udev rule on the charger pulls in omamobile-charge-limit-apply.service, which applies the saved value. It only does that on husky (google,zuma-husky in the device tree), so other max77759 phones are left alone. The second commit drops the ACTION=="add" filter from that rule, because with it the apply unit never started at boot on my phone.
I put the udev rule and units in the settings package since the helper lives there. If the hook fits better in omamobile-device-husky like tegu's, I can move it.
What I tested: test/all passes on my desktop (charge backend and helper tests against a scratch root, core tests, lifetime, single-instance), and --check is clean. On my Pixel 8 Pro with the charger PRs installed: I tapped 90 % and it applied, the limit came back at boot after the udev fix, and it held at 90 % overnight (Nov 16 to 17). I haven't tried it on any other phone.
Version is 0.1.3 for now, it will need renumbering against #629 and #630.