All checks were successful
Update PKGBUILD version / update-pkgver (push) Successful in 2s
Laptops with charge_control_end_threshold support get a click-to-toggle on the battery module (80% ↔ 100%). A ♥ icon appears when conservation is active, hidden when inactive. State persists across reboots via systemd oneshot service. udev rule grants wheel group write access so no sudo is needed for toggling.
29 lines
749 B
Bash
Executable File
29 lines
749 B
Bash
Executable File
#!/usr/bin/bash
|
|
# ABOUTME: Toggles battery conservation mode between 80% and 100% charge limit.
|
|
# ABOUTME: Writes to sysfs (immediate) and state file (persistence across reboots).
|
|
|
|
THRESHOLD_FILE="/sys/class/power_supply/BAT0/charge_control_end_threshold"
|
|
STATE_DIR="/var/lib/moonarch"
|
|
STATE_FILE="${STATE_DIR}/batsaver-threshold"
|
|
CONSERVATION_LIMIT=80
|
|
|
|
[[ -f "$THRESHOLD_FILE" ]] || exit 1
|
|
|
|
CURRENT=$(cat "$THRESHOLD_FILE")
|
|
|
|
if [[ "$CURRENT" -le "$CONSERVATION_LIMIT" ]]; then
|
|
NEW=100
|
|
else
|
|
NEW="$CONSERVATION_LIMIT"
|
|
fi
|
|
|
|
# Apply immediately
|
|
echo "$NEW" > "$THRESHOLD_FILE" || exit 1
|
|
|
|
# Persist for next boot
|
|
mkdir -p "$STATE_DIR"
|
|
echo "$NEW" > "$STATE_FILE"
|
|
|
|
# Signal Waybar to refresh the batsaver module (SIGRTMIN+9)
|
|
pkill -RTMIN+9 waybar
|