forked from lukas/nixos-config
40 lines
991 B
Nix
40 lines
991 B
Nix
{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" ];
|
||
};
|
||
|
||
}
|