From ae8273ee9d53db9029a8864c13a04f8778e6fed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Tue, 1 Jul 2025 20:42:01 +0200 Subject: [PATCH] treewide: remove battery-notify script --- nix/configurations/tungsten.nix | 1 - nix/configurations/tungsten/home/programs.nix | 6 -- nix/configurations/vanadium.nix | 1 - nix/configurations/vanadium/home/programs.nix | 6 -- nix/homeModules/common/battery-notify.nix | 70 ------------------- 5 files changed, 84 deletions(-) delete mode 100644 nix/homeModules/common/battery-notify.nix diff --git a/nix/configurations/tungsten.nix b/nix/configurations/tungsten.nix index 90f25d93..1fae09ed 100644 --- a/nix/configurations/tungsten.nix +++ b/nix/configurations/tungsten.nix @@ -134,7 +134,6 @@ in ../homeModules/common/vim ../homeModules/common/wired ../homeModules/common/atuin.nix - ../homeModules/common/battery-notify.nix ../homeModules/common/direnv.nix ../homeModules/common/feh.nix ../homeModules/common/firefox.nix diff --git a/nix/configurations/tungsten/home/programs.nix b/nix/configurations/tungsten/home/programs.nix index f662d598..25377437 100644 --- a/nix/configurations/tungsten/home/programs.nix +++ b/nix/configurations/tungsten/home/programs.nix @@ -103,12 +103,6 @@ enable = true; components = ["secrets"]; }; - - battery-notify = { - enable = true; - device_full = "/sys/class/power_supply/BAT0/charge_full"; - device_now = "/sys/class/power_supply/BAT0/charge_now"; - }; }; } ]; diff --git a/nix/configurations/vanadium.nix b/nix/configurations/vanadium.nix index 1614f330..59899aac 100644 --- a/nix/configurations/vanadium.nix +++ b/nix/configurations/vanadium.nix @@ -153,7 +153,6 @@ in ../homeModules/common/vim ../homeModules/common/wired ../homeModules/common/atuin.nix - ../homeModules/common/battery-notify.nix ../homeModules/common/direnv.nix ../homeModules/common/feh.nix ../homeModules/common/firefox.nix diff --git a/nix/configurations/vanadium/home/programs.nix b/nix/configurations/vanadium/home/programs.nix index 2361abed..70b02447 100644 --- a/nix/configurations/vanadium/home/programs.nix +++ b/nix/configurations/vanadium/home/programs.nix @@ -158,12 +158,6 @@ enable = true; components = ["secrets"]; }; - - battery-notify = { - enable = true; - device_full = "/sys/class/power_supply/BAT1/charge_full"; - device_now = "/sys/class/power_supply/BAT1/charge_now"; - }; }; } ]; diff --git a/nix/homeModules/common/battery-notify.nix b/nix/homeModules/common/battery-notify.nix deleted file mode 100644 index e7fce649..00000000 --- a/nix/homeModules/common/battery-notify.nix +++ /dev/null @@ -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"]; - }; - }; -}