fix(desktop): hardware findings — charge limit, polkit ws, bar deps
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:
2026-07-10 13:29:44 +01:00
parent 3bc8a46927
commit 910f357f08
11 changed files with 134 additions and 42 deletions

View File

@@ -321,26 +321,48 @@ let
fi
back
} | rofi_menu -show-icons -p "Power profile: ''${curp:-n/a}, limit: ''${curc:-default}") || exit 0
# Persist in-flake + apply live to sysfs (udev makes the node
# group-writable for users Bernardo 2026-07-10).
# Persist in-flake, then re-apply via the root oneshot (polkit
# allows users to restart it) so a non-writable sysfs node still
# updates. Fallback: direct echo if the node is group-writable.
set_limit() {
nomarchy-theme-sync --quiet set settings.power.batteryChargeLimit "$1" --no-switch
n="$1"; [ "$n" = null ] && n=100
applied=
if systemctl restart nomarchy-battery-charge-limit.service 2>/dev/null; then
applied=1
else
for d in /sys/class/power_supply/*/; do
[ "$(cat "$d/type" 2>/dev/null)" = Battery ] || continue
[ "$(cat "$d/scope" 2>/dev/null || echo System)" = Device ] && continue
thresh="$d/charge_control_end_threshold"
if [ -w "$thresh" ] && echo "$n" > "$thresh" 2>/dev/null; then
applied=1
fi
done
fi
actual=
for d in /sys/class/power_supply/*/; do
[ "$(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 "$n" > "$thresh" 2>/dev/null || true
[ -r "$d/charge_control_end_threshold" ] \
&& actual=$(cat "$d/charge_control_end_threshold" 2>/dev/null) && break
done
notify-send "Battery limit" "$2 applied now."
if [ -n "$applied" ] && [ -n "$actual" ]; then
notify-send "Battery limit" "$2 sysfs now $actual%."
elif [ -n "$applied" ]; then
notify-send "Battery limit" "$2 applied (could not re-read sysfs)."
else
notify-send -u critical "Battery limit" \
"Saved in theme-state but could not write sysfs (need rebuild or users-group on threshold)."
fi
}
case "$choice" in
"$BACK") exec "$0" ;;
"Profile: "*) powerprofilesctl set "''${choice#Profile: }" ;;
"Charge limit: 80%"*) set_limit 80 "Set to 80%" ;;
"Charge limit: 90%"*) set_limit 90 "Set to 90%" ;;
"Charge limit: 60%"*) set_limit 60 "Set to 60%" ;;
"Charge limit: Off"*) set_limit null "Off charges to 100%" ;;
*"Charge limit: 80%"*) set_limit 80 "Set to 80%" ;;
*"Charge limit: 90%"*) set_limit 90 "Set to 90%" ;;
*"Charge limit: 60%"*) set_limit 60 "Set to 60%" ;;
*"Charge limit: Off"*) set_limit null "Off charges to 100%" ;;
esac ;;
theme)
@@ -521,7 +543,9 @@ ${themeRows}
file="$dir/$(date +%Y%m%d-%H%M%S).png"
case "$choice" in
"$BACK") exec "$0" tools ;;
*"Region clipboard"*) grim -g "$(slurp)" - | wl-copy ;;
*"Region clipboard"*)
grim -g "$(slurp)" - | wl-copy \
&& notify-send "Screenshot" "Region copied to clipboard." ;;
*"Region file"*) mkdir -p "$dir"; grim -g "$(slurp)" "$file" \
&& notify-send "Screenshot saved" "$file" ;;
*"Annotate region"*) mkdir -p "$dir"; grim -g "$(slurp)" - | satty --filename - --fullscreen --output-filename "$file" ;;
@@ -535,7 +559,9 @@ ${themeRows}
|| { notify-send "OCR" "No text recognized in that region."; exit 0; }
printf '%s' "$txt" | wl-copy
notify-send "OCR" "Copied $(printf '%s' "$txt" | wc -w) word(s) to the clipboard." ;;
*"Full screen clipboard"*) grim - | wl-copy ;;
*"Full screen clipboard"*)
grim - | wl-copy \
&& notify-send "Screenshot" "Screen copied to clipboard." ;;
*"Full screen file"*) mkdir -p "$dir"; grim "$file" \
&& notify-send "Screenshot saved" "$file" ;;
*"Stop recording"*) exec nomarchy-record stop ;;
@@ -937,21 +963,43 @@ ${themeRows}
set_limit() {
nomarchy-theme-sync --quiet set settings.power.batteryChargeLimit "$1" --no-switch
n="$1"; [ "$n" = null ] && n=100
applied=
if systemctl restart nomarchy-battery-charge-limit.service 2>/dev/null; then
applied=1
else
for d in /sys/class/power_supply/*/; do
[ "$(cat "$d/type" 2>/dev/null)" = Battery ] || continue
[ "$(cat "$d/scope" 2>/dev/null || echo System)" = Device ] && continue
thresh="$d/charge_control_end_threshold"
if [ -w "$thresh" ] && echo "$n" > "$thresh" 2>/dev/null; then
applied=1
fi
done
fi
actual=
for d in /sys/class/power_supply/*/; do
[ "$(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 "$n" > "$thresh" 2>/dev/null || true
[ -r "$d/charge_control_end_threshold" ] \
&& actual=$(cat "$d/charge_control_end_threshold" 2>/dev/null) && break
done
notify-send "Battery limit" "$2 applied now."
if [ -n "$applied" ] && [ -n "$actual" ]; then
notify-send "Battery limit" "$2 sysfs now $actual%."
elif [ -n "$applied" ]; then
notify-send "Battery limit" "$2 applied (could not re-read sysfs)."
else
notify-send -u critical "Battery limit" \
"Saved in theme-state but could not write sysfs (need rebuild or users-group on threshold)."
fi
}
case "$sel" in
"$BACK") exec "$0" system ;;
"80%"*) set_limit 80 "Set to 80%" ;;
"90%"*) set_limit 90 "Set to 90%" ;;
"60%"*) set_limit 60 "Set to 60%" ;;
"Off"*) set_limit null "Off charges to 100%" ;;
"Custom"*)
# Order: Off (100%) before 90/80/60 so "100%" does not hit *0%* patterns.
*Off*|*100%*) set_limit null "Off charges to 100%" ;;
*90%*) set_limit 90 "Set to 90%" ;;
*80%*) set_limit 80 "Set to 80%" ;;
*60%*) set_limit 60 "Set to 60%" ;;
*Custom*)
limit=$(rofi_menu -p "Charge limit % (50100)" < /dev/null) || exit 0
[ -n "$limit" ] || exit 0
case "$limit" in