diff --git a/home/battery/default.nix b/home/battery/default.nix index 235a9d9..ddd5c7d 100644 --- a/home/battery/default.nix +++ b/home/battery/default.nix @@ -6,27 +6,21 @@ 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}%" - else - ${pkgs.dunst}/bin/dunstify \ - -C 9991 2>/dev/null || true - fi + if [ "$STATUS" = "Discharging" ] && [ "$LEVEL" -lt 20 ]; then + ${pkgs.dunst}/bin/dunstify \ + -r 9991 \ + -t 0 \ + -u critical \ + "Battery Low" \ + "Battery is at ''${LEVEL}%" 2>/dev/null || true + else + ${pkgs.dunst}/bin/dunstify \ + -C 9991 2>/dev/null || true fi ''; in @@ -49,7 +43,8 @@ in Timer = { OnBootSec = "15s"; - OnUnitActiveSec = "15s"; + OnUnitInactiveSec = "15s"; + AccuracySec = "1s"; }; Install = {