Fix battery script

This commit is contained in:
2026-07-10 20:19:04 +01:00
parent 6154c9cf0d
commit e7fa524261
+3 -8
View File
@@ -6,28 +6,22 @@ let
LEVEL=$(cat "$BAT/capacity")
STATUS=$(cat "$BAT/status")
has_notifications() {
${pkgs.dbus}/bin/busctl --user status org.freedesktop.Notifications >/dev/null 2>&1
}
if [ "$STATUS" = "Discharging" ] && [ "$LEVEL" -lt 3 ]; then
${pkgs.systemd}/bin/systemctl hibernate
exit 0
fi
if has_notifications; then
if [ "$STATUS" = "Discharging" ] && [ "$LEVEL" -lt 20 ]; then
${pkgs.dunst}/bin/dunstify \
-r 9991 \
-t 0 \
-u critical \
"Battery Low" \
"Battery is at ''${LEVEL}%"
"Battery is at ''${LEVEL}%" 2>/dev/null || true
else
${pkgs.dunst}/bin/dunstify \
-C 9991 2>/dev/null || true
fi
fi
'';
in
{
@@ -49,7 +43,8 @@ in
Timer = {
OnBootSec = "15s";
OnUnitActiveSec = "15s";
OnUnitInactiveSec = "15s";
AccuracySec = "1s";
};
Install = {