battery notifier
Some checks failed
Activate Homelab Configuration / rebuild (push) Failing after 9s
Some checks failed
Activate Homelab Configuration / rebuild (push) Failing after 9s
This commit is contained in:
parent
2890b8b503
commit
028a370299
1 changed files with 13 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, resume-dev, ... }: {
|
||||
{ pkgs, username, resume-dev, ... }: {
|
||||
powerManagement.powertop.enable = true;
|
||||
|
||||
services = {
|
||||
|
|
@ -10,6 +10,18 @@
|
|||
echo 85 > /sys/class/power_supply/BAT*/charge_control_end_threshold || true
|
||||
''}"
|
||||
'';
|
||||
cron = {
|
||||
enable = true;
|
||||
systemCronJobs = [
|
||||
"* * * * * ${username} bash -x ${pkgs.writeShellScript "low-battery-notifier" ''
|
||||
BAT_PCT=`${pkgs.acpi}/bin/acpi -b | ${pkgs.gnugrep}/bin/grep -P -o '[0-9]+(?=%)'`
|
||||
BAT_STA=`${pkgs.acpi}/bin/acpi -b | ${pkgs.gnugrep}/bin/grep -P -o '\w+(?=,)'`
|
||||
echo "`date` battery status:$BAT_STA percentage:$BAT_PCT"
|
||||
test $BAT_PCT -le 30 && test $BAT_PCT -gt 15 && test $BAT_STA = "Discharging" && DISPLAY=:0.0 ${pkgs.libnotify}/bin/notify-send -c device -u normal "Low Battery" "\$\{BAT_PCT}% remaining."
|
||||
test $BAT_PCT -le 15 && test $BAT_STA = "Discharging" && DISPLAY=:0.0 ${pkgs.libnotify}/bin/notify-send -c device -u critical "Low Battery" "Shutdown at 10%."
|
||||
''} > /tmp/cron.batt.log 2>&1"
|
||||
];
|
||||
};
|
||||
upower = {
|
||||
enable = true;
|
||||
percentageCritical = 15;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue