From 02aa2e13d53a4f7ecfd2d329f62a14be5ad0101d Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Wed, 7 Aug 2024 23:34:26 -0400 Subject: [PATCH] waybar: check for BAT0 and BAT1 in check-battery --- homeManagerModules/services/waybar/default.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/homeManagerModules/services/waybar/default.nix b/homeManagerModules/services/waybar/default.nix index 27a32049..2b316d76 100644 --- a/homeManagerModules/services/waybar/default.nix +++ b/homeManagerModules/services/waybar/default.nix @@ -87,12 +87,19 @@ in { "battery" = let checkBattery = pkgs.writeShellScript "check-battery" '' - bat=/sys/class/power_supply/BAT0 + if [ -d /sys/class/power_supply/BAT0 ]; then + BAT=/sys/class/power_supply/BAT0 + elif [ -d /sys/class/power_supply/BAT1 ]; then + BAT=/sys/class/power_supply/BAT1 + else + echo "No battery found." + exit 1 + fi CRIT=''${1:-10} NOTIFY=${lib.getExe' pkgs.libnotify "notify-send"} - stat=$(${lib.getExe' pkgs.coreutils "cat"} $bat/status) - perc=$(${lib.getExe' pkgs.coreutils "cat"} $bat/capacity) + stat=$(${lib.getExe' pkgs.coreutils "cat"} $BAT/status) + perc=$(${lib.getExe' pkgs.coreutils "cat"} $BAT/capacity) if [[ $perc -le $CRIT ]] && [[ $stat == "Discharging" ]]; then $NOTIFY --urgency=critical --icon=dialog-error "Battery Critical" "Current charge: $perc%".