mirror of
https://github.com/alyraffauf/nixcfg.git
synced 2024-11-22 02:53:55 -05:00
waybar: check for BAT0 and BAT1 in check-battery
Some checks are pending
git-mirror / gitlab-sync (push) Waiting to run
nix-build / default-build (push) Waiting to run
nix-build / fallarbor-build (push) Waiting to run
nix-build / lavaridge-build (push) Waiting to run
nix-build / mauville-build (push) Waiting to run
nix-build / petalburg-build (push) Waiting to run
nix-build / rustboro-build (push) Waiting to run
nix-check / fmt-check (push) Waiting to run
nix-check / eval-check (push) Waiting to run
Some checks are pending
git-mirror / gitlab-sync (push) Waiting to run
nix-build / default-build (push) Waiting to run
nix-build / fallarbor-build (push) Waiting to run
nix-build / lavaridge-build (push) Waiting to run
nix-build / mauville-build (push) Waiting to run
nix-build / petalburg-build (push) Waiting to run
nix-build / rustboro-build (push) Waiting to run
nix-check / fmt-check (push) Waiting to run
nix-check / eval-check (push) Waiting to run
This commit is contained in:
parent
23c783cfc5
commit
02aa2e13d5
|
@ -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%".
|
||||
|
|
Loading…
Reference in a new issue