mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
treewide: remove battery-notify script
This commit is contained in:
parent
32b6fbccf0
commit
ae8273ee9d
5 changed files with 0 additions and 84 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -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"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue