From a212e079dd94f70b14363690193b3d4fe7d4f1eb Mon Sep 17 00:00:00 2001 From: ooks-io Date: Sat, 21 Oct 2023 22:22:17 +1300 Subject: [PATCH] remove: battery notify script --- system/common/opt/batterynotify.nix | 60 ----------------------------- 1 file changed, 60 deletions(-) delete mode 100644 system/common/opt/batterynotify.nix diff --git a/system/common/opt/batterynotify.nix b/system/common/opt/batterynotify.nix deleted file mode 100644 index 3a1b0be..0000000 --- a/system/common/opt/batterynotify.nix +++ /dev/null @@ -1,60 +0,0 @@ -{ config, pkgs, lib, ... }: - -# Regularly check the battery status and send a notification when it discharges -# below certain thresholds. -# Implemented by calling the `acpi` program regularly. This is the simpler and -# safer approach because the battery might not send discharging events. -# author: github:Julow - -let conf = config.modules.battery-notify; - -in { - options.modules.battery-notify = with lib; { - enable = mkEnableOption "battery-notify"; - }; - - config = lib.mkIf conf.enable { - # Regularly check battery status - systemd.user.services.battery-notify = { - wantedBy = [ "graphical-session.target" ]; - script = '' - prev_val=100 - check () { [[ $1 -ge $val ]] && [[ $1 -lt $prev_val ]]; } - get_battery_glyph() { - local val="$1" - if [[ "$val" -le 10 ]]; then - echo "" # or echo -e "\uf244" if using the Unicode code - elif [[ "$val" -le 25 ]]; then - echo "" - elif [[ "$val" -le 50 ]]; then - echo "" - elif [[ "$val" -le 75 ]]; then - echo "" - else - echo "" - fi - } - - notify () { - glyph=$(get_battery_glyph $val) - ${pkgs.libnotify}/bin/notify-send -a bat-notify "$glyph $val%" - } - while true; do - IFS=: read _ bat0 < <(${pkgs.acpi}/bin/acpi -b) - IFS=\ , read status val remaining <<<"$bat0" - val=''${val%\%} - if [[ $status = Discharging ]]; then - echo "$val%, $remaining" - if check 75 || check 50 ||check 30 || check 25 || check 20; then notify - elif check 15 || [[ $val -le 10 ]]; then notify -u critical - fi - fi - prev_val=$val - # Sleep longer when battery is high to save CPU - if [[ $val -gt 30 ]]; then sleep 10m; elif [[ $val -ge 20 ]]; then sleep 5m; else sleep 1m; fi - done - ''; - }; - - }; -} \ No newline at end of file