Commit Graph

3 Commits

Author SHA1 Message Date
Joachim Hummel
2e65dadfa9 Add low-battery warning and auto-shutdown to the tray icon
The oneUpPower kernel module powered the system off at low SOC, but the
icon now reads the battery over I2C and no longer relies on that module.
Restore the safety net in the icon itself.

While running on battery, warn via a tray notification at <=10% and run
`systemctl poweroff` at <=5%. systemctl poweroff is authorised for the
active desktop session without sudo (logind CanPowerOff returns "yes").
State resets when AC is reconnected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 23:03:54 +02:00
Joachim Hummel
19f1e2962e Read battery state over I2C instead of the kernel module
batteryIcon.py read SOC and AC status from /sys/class/power_supply,
which only exists when the oneUpPower kernel module is loaded. When the
module fails to load (e.g. a DKMS vermagic mismatch after a kernel
update), the icon showed only "N/A".

Read the battery IC directly over I2C (bus 1, addr 0x64, regs 0x04 and
0x0E -- the same registers oneUpPower.c uses) via smbus2. force=True
bypasses the I2C_SLAVE busy check so the read still works whether or not
the kernel module has claimed the address. The icon now works for an
ordinary user in the i2c group, with no sudo and no kernel module.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 22:58:20 +02:00
Joachim Hummel
462dc2d380 Add battery tray icon with reliable autostart
Add batteryIcon.py, a PyQt5 system tray icon for the Argon ONE UP
that shows battery SOC and charging status, plus an XDG autostart
entry (batteryIcon.desktop).

The icon now waits up to 120s for the system tray to become
available instead of exiting immediately. At login the autostart
entry runs before the labwc panel (wf-panel-pi) provides its tray,
which previously caused the script to sys.exit(1) and the icon to
be missing after every reboot.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 22:31:12 +02:00