fix(desktop): hardware findings — charge limit, polkit ws, bar deps
All checks were successful
Check / eval (push) Successful in 3m3s
All checks were successful
Check / eval (push) Successful in 3m3s
Latitude 5310 QA:
- Clock tooltip: drop empty {calendar} popup; plain date+zone
- Charge limit: restart oneshot via polkit + dual write/delay for
Dell unplug race; toast verifies sysfs; looser menu match
- pwvucontrol ships with waybar (right-click volume)
- Print/region→clipboard toasts success
- Polkit (and pinentry) open on current workspace + stayfocused
V0: flake check --no-build green. V3: retest A3/A4/B1/tooltip/polkit.
This commit is contained in:
@@ -74,7 +74,16 @@ in
|
||||
[ "$(cat "$d/type" 2>/dev/null)" = Battery ] || continue
|
||||
[ "$(cat "$d/scope" 2>/dev/null || echo System)" = Device ] && continue
|
||||
thresh="$d/charge_control_end_threshold"
|
||||
[ -w "$thresh" ] && echo "$limit" > "$thresh" || true
|
||||
[ -e "$thresh" ] || continue
|
||||
# Keep the node group-writable for the menu's live path (udev
|
||||
# sets this on add; re-assert after firmware recreates attrs).
|
||||
chgrp users "$thresh" 2>/dev/null || true
|
||||
chmod 0664 "$thresh" 2>/dev/null || true
|
||||
# Some firmwares (Dell) reset the threshold on unplug *after*
|
||||
# the udev event — write once, wait, write again.
|
||||
echo "$limit" > "$thresh" 2>/dev/null || true
|
||||
sleep 1
|
||||
echo "$limit" > "$thresh" 2>/dev/null || true
|
||||
done
|
||||
exit 0
|
||||
'';
|
||||
@@ -82,9 +91,33 @@ in
|
||||
|
||||
# Writable threshold for the logged-in user (menu live apply) + AC
|
||||
# re-apply of the oneshot. Laptop only; no-op when the attr is absent.
|
||||
services.udev.extraRules = lib.mkIf cfg.laptop ''
|
||||
SUBSYSTEM=="power_supply", ATTR{type}=="Battery", TEST=="charge_control_end_threshold", GROUP="users", MODE="0664"
|
||||
SUBSYSTEM=="power_supply", ATTR{type}=="Mains", RUN+="${config.systemd.package}/bin/systemctl --no-block restart nomarchy-battery-charge-limit.service"
|
||||
# Immediate + delayed restart: Dell/Latitude firmware often stomps the
|
||||
# threshold to 100 right after unplug; a single immediate oneshot
|
||||
# loses the race (hardware: unplug→100, plug→80). systemd-run hands
|
||||
# the delayed restart off so udev's short RUN budget is not held.
|
||||
services.udev.extraRules = lib.mkIf cfg.laptop (
|
||||
let
|
||||
systemctl = "${config.systemd.package}/bin/systemctl";
|
||||
systemdRun = "${config.systemd.package}/bin/systemd-run";
|
||||
in ''
|
||||
SUBSYSTEM=="power_supply", ATTR{type}=="Battery", TEST=="charge_control_end_threshold", GROUP="users", MODE="0664"
|
||||
SUBSYSTEM=="power_supply", ATTR{type}=="Mains", RUN+="${systemctl} --no-block restart nomarchy-battery-charge-limit.service"
|
||||
SUBSYSTEM=="power_supply", ATTR{type}=="Mains", RUN+="${systemdRun} --no-block --collect --on-active=2s --timer-property=AccuracySec=200ms ${systemctl} --no-block restart nomarchy-battery-charge-limit.service"
|
||||
''
|
||||
);
|
||||
|
||||
# Unprivileged restart of the oneshot so the menu can re-apply as
|
||||
# root when the threshold node is not (yet) user-writable.
|
||||
security.polkit.extraConfig = lib.mkIf cfg.laptop ''
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (action.id == "org.freedesktop.systemd1.manage-units" &&
|
||||
subject.isInGroup("users")) {
|
||||
var unit = action.lookup("unit");
|
||||
if (unit == "nomarchy-battery-charge-limit.service") {
|
||||
return polkit.Result.YES;
|
||||
}
|
||||
}
|
||||
});
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user