treewide: remove battery-notify script

This commit is contained in:
Primrose 2025-07-01 20:42:01 +02:00
parent 32b6fbccf0
commit ae8273ee9d
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
5 changed files with 0 additions and 84 deletions

View file

@ -134,7 +134,6 @@ in
../homeModules/common/vim ../homeModules/common/vim
../homeModules/common/wired ../homeModules/common/wired
../homeModules/common/atuin.nix ../homeModules/common/atuin.nix
../homeModules/common/battery-notify.nix
../homeModules/common/direnv.nix ../homeModules/common/direnv.nix
../homeModules/common/feh.nix ../homeModules/common/feh.nix
../homeModules/common/firefox.nix ../homeModules/common/firefox.nix

View file

@ -103,12 +103,6 @@
enable = true; enable = true;
components = ["secrets"]; components = ["secrets"];
}; };
battery-notify = {
enable = true;
device_full = "/sys/class/power_supply/BAT0/charge_full";
device_now = "/sys/class/power_supply/BAT0/charge_now";
};
}; };
} }
]; ];

View file

@ -153,7 +153,6 @@ in
../homeModules/common/vim ../homeModules/common/vim
../homeModules/common/wired ../homeModules/common/wired
../homeModules/common/atuin.nix ../homeModules/common/atuin.nix
../homeModules/common/battery-notify.nix
../homeModules/common/direnv.nix ../homeModules/common/direnv.nix
../homeModules/common/feh.nix ../homeModules/common/feh.nix
../homeModules/common/firefox.nix ../homeModules/common/firefox.nix

View file

@ -158,12 +158,6 @@
enable = true; enable = true;
components = ["secrets"]; components = ["secrets"];
}; };
battery-notify = {
enable = true;
device_full = "/sys/class/power_supply/BAT1/charge_full";
device_now = "/sys/class/power_supply/BAT1/charge_now";
};
}; };
} }
]; ];

View file

@ -1,70 +0,0 @@
{
pkgs,
lib,
config,
...
}: let
cfg = config.services."battery-notify";
in {
options = {
services."battery-notify" = {
enable = lib.mkEnableOption "battery-notify";
triggerLevel = lib.mkOption {
type = with lib.types; ints.between 0 100;
description = "Below which percentage should the script send a notification";
default = 20;
};
checkAt = lib.mkOption {
type = with lib.types; listOf str;
description = "At which frequency should the service check for the battery status";
default = ["*:0/5"]; # every five minutes
};
device_full = lib.mkOption {
type = with lib.types; str;
description = "The device to read for full energy status";
};
device_now = lib.mkOption {
type = with lib.types; str;
description = "The device to read for current energy status";
};
};
};
config = lib.mkIf cfg.enable {
systemd.user.services."battery-notify" = {
Unit.Description = "Notify when battery is low";
Install = {
WantedBy = ["multi-user.target"];
};
Service = {
ExecStart = let
script = pkgs.writeShellApplication {
name = "battery-notify";
runtimeInputs = [
pkgs.libnotify
pkgs.bc
pkgs.uutils-coreutils-noprefix
];
text = ''
now="$(cat ${cfg.device_now})"
full="$(cat ${cfg.device_full})"
if (( $(bc -l <<< "($now / $full) * 100 < ${builtins.toString cfg.triggerLevel}") )); then
notify-send -u critical "Battery Low" "Please charge your battery"
fi
'';
};
in "${lib.getExe script}";
};
};
systemd.user.timers."battery-notify" = {
Unit.Description = "Notify when battery is low";
Timer = {
OnCalendar = cfg.checkAt;
Persistent = true;
};
Install.WantedBy = ["timers.target"];
};
};
}