mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
nix: format with alejandra
This commit is contained in:
parent
d5cad148da
commit
95eb4b71e0
118 changed files with 1291 additions and 1703 deletions
|
|
@ -3,14 +3,9 @@
|
|||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
}: let
|
||||
cfg = config.services."battery-notify";
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
in {
|
||||
options = {
|
||||
services."battery-notify" = {
|
||||
enable = lib.mkEnableOption "battery-notify";
|
||||
|
|
@ -22,7 +17,7 @@ in
|
|||
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
|
||||
default = ["*:0/5"]; # every five minutes
|
||||
};
|
||||
device_full = lib.mkOption {
|
||||
type = with lib.types; str;
|
||||
|
|
@ -39,29 +34,27 @@ in
|
|||
systemd.user.services."battery-notify" = {
|
||||
Unit.Description = "Notify when battery is low";
|
||||
Install = {
|
||||
WantedBy = [ "multi-user.target" ];
|
||||
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})"
|
||||
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}";
|
||||
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}";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -71,8 +64,7 @@ in
|
|||
OnCalendar = cfg.checkAt;
|
||||
Persistent = true;
|
||||
};
|
||||
Install.WantedBy = [ "timers.target" ];
|
||||
Install.WantedBy = ["timers.target"];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue