Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/omamobile-device-husky/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ grep -qx 'supply=max77759-charger' "$tmp/root/usr/share/omamobile/charge-limit.c
[[ ! -e $tmp/root/usr/lib/systemd/system/multi-user.target.wants/omamobile-charge-limit-apply.service ]] \
|| fail "the apply unit is pulled in by udev, not enabled"
pass "the charge limit declaration, its udev rule and the apply unit are staged; the unit is not enabled"
rule=vendor/udev/rules.d/75-omamobile-charge-limit.rules
unit=vendor/systemd/system/omamobile-charge-limit-apply.service
[[ $(grep -v '^#' "$rule" | grep -c .) -eq 1 ]] \
&& grep -qx 'SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", TAG+="systemd", ENV{SYSTEMD_WANTS}+="omamobile-charge-limit-apply.service"' "$rule" \
&& ! grep -v '^#' "$rule" | grep -c ACTION >/dev/null \
|| fail "one rule, tag and SYSTEMD_WANTS on every event (Wants= is rebuilt per uevent)"
grep -qx 'RemainAfterExit=yes' "$unit" && grep -qx 'StopWhenUnneeded=yes' "$unit" \
|| fail "the apply unit stays active after its run (no restart per change event) and stops with the charger"
! grep -q '^StartLimitIntervalSec=0' "$unit" || fail "systemd's start limit stays on for the apply unit"
pass "the charge limit rule wants the unit on every event; the unit runs once per charger add"


# --- the AoC start: hang marker, nothing without the node ------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
# Applies the saved charge limit (/etc/omamobile/charge-limit) to the charger this package declares
# (/usr/share/omamobile/charge-limit.conf). Pulled in by udev when the charger appears
# (75-omamobile-charge-limit.rules); without a saved file the helper does nothing. The helper is omamobile-settings'.
# Not enabled.
# Not enabled. RemainAfterExit= keeps it active after one run, so the charger's change events (each one
# re-wants it) do not start it again (6968 starts in one boot on 2026-11-25 without it). StopWhenUnneeded= stops
# it when the charger device goes away (driver unbind or module reload), so the next add runs it again. A cable
# replug does not remove the device; the driver keeps the limit across it (checked 2026-11-25).
# On the 2026-11-27 boot systemd marked the charger active on its first change event, not the add, so
# that was the start. If that first run fails the unit is left failed, and the next change event wants it
# again: it is retried, within systemd's default start limit (5 starts in 10 s), not left failed until the
# next boot. (Read from systemd's behaviour and the 2026-11-25 count; a failing first run is not tested.)
[Unit]
Description=Apply the saved charge limit
StartLimitIntervalSec=0
After=local-fs.target
ConditionFileIsExecutable=/usr/lib/omamobile-settings/charge-limit
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/omamobile-settings/charge-limit
TimeoutStartSec=15
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Apply the saved charge limit (/etc/omamobile/charge-limit) when the MAX77759 charger appears, at every boot,
# through omamobile-charge-limit-apply.service rather than inside the udev worker. The helper acts only on the
# supply this package declares in /usr/share/omamobile/charge-limit.conf; no saved file: nothing is touched.
# No ACTION filter: with ACTION=="add" the device loses its systemd tag on the charger's next change event, and
# the unit did not start at boot on husky (2026-11-16); without it, it does.
# No ACTION filter: systemd rebuilds a device's Wants= from SYSTEMD_WANTS on every uevent, so a rule on add
# only leaves Wants= empty after the charger's next change event. The unit keeps itself from storming on change
# events (RemainAfterExit=, StopWhenUnneeded=; see the unit).
SUBSYSTEM=="power_supply", KERNEL=="max77759-charger", TAG+="systemd", ENV{SYSTEMD_WANTS}+="omamobile-charge-limit-apply.service"
2 changes: 1 addition & 1 deletion packages/omamobile-device-husky/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.21
0.1.22
2 changes: 1 addition & 1 deletion packages/omamobile-settings/test/charge-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ if [[ -d $h ]]; then
{ echo "FAIL: udev: one rule, no ACTION filter, pulls in the apply unit" >&2; exit 1; }
a=$h/vendor/systemd/system/omamobile-charge-limit-apply.service
grep -qx 'ExecStart=/usr/lib/omamobile-settings/charge-limit' "$a" && grep -qx 'Type=oneshot' "$a" &&
grep -qx 'StartLimitIntervalSec=0' "$a" && ! grep -q '^\[Install\]' "$a" ||
grep -qx 'RemainAfterExit=yes' "$a" && ! grep -q '^\[Install\]' "$a" ||
{ echo "FAIL: apply unit: oneshot helper with no argument, not enabled" >&2; exit 1; }
grep -qx 'supply=max77759-charger' "$h/charge-limit.conf" || { echo "FAIL: husky declares max77759-charger" >&2; exit 1; }
fi
Expand Down