1
0
Fork 0
forked from lukas/nixos-config
nixos-config/home/tnix/localModules/bat.nix
pijukka 9ebd3c4bb2 auto
2025-09-05 21:15:36 +02:00

40 lines
991 B
Nix
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{config, ...}:
{
home.file.".config/battery_notify/notify_if_on_battery.sh" = {
text = ''
#!/usr/bin/env bash
AC_PATH="/sys/class/power_supply/AC/online" # evtl. anpassen
if [ -f "$AC_PATH" ]; then
AC_STATUS=$(cat "$AC_PATH")
if [ "$AC_STATUS" -eq 0 ]; then
hyprctl notify -1 10000 "rgb(ffa500)" "fontsize:30 🔋 Du bist nicht am Strom!"
fi
else
hyprctl notify -1 10000 "rgb(ff0000)" "fontsize:30 ⚠️ AC-Status nicht gefunden"
fi
'';
executable = true;
};
systemd.user.services.notify-on-battery = {
Unit.Description = "Notify when on battery";
Service = {
Type = "oneshot";
ExecStart = "${config.home.homeDirectory}/.config/battery_notify/notify_if_on_battery.sh";
};
};
systemd.user.timers.notify-on-battery = {
Unit.Description = "Check battery status every 2 minutes";
Timer = {
OnBootSec = "30s";
OnUnitActiveSec = "5min";
};
Install.WantedBy = [ "default.target" ];
};
}