mirror of
https://github.com/alyraffauf/nixcfg.git
synced 2024-11-21 19:53:55 -05:00
waybar: nag on battery critical
This commit is contained in:
parent
f0b064c19b
commit
1e43224619
|
@ -83,10 +83,24 @@
|
|||
"tooltip-format" = "{:%Y-%m-%d | %H:%M}";
|
||||
};
|
||||
|
||||
"battery" = {
|
||||
"battery" = let
|
||||
checkBattery = pkgs.writeShellScript "check-battery" ''
|
||||
bat=/sys/class/power_supply/BAT0
|
||||
CRIT=''${1:-10}
|
||||
NOTIFY=${lib.getExe' pkgs.libnotify "notify-send"}
|
||||
|
||||
stat=$(cat $bat/status)
|
||||
perc=$(cat $bat/capacity)
|
||||
|
||||
if [[ $perc -le $CRIT ]] && [[ $stat == "Discharging" ]]; then
|
||||
$NOTIFY --urgency=critical --icon=dialog-warning "Battery Critical" "Current charge: $perc%".
|
||||
fi
|
||||
'';
|
||||
in {
|
||||
"format" = "{icon}";
|
||||
"format-icons" = ["" "" "" "" "" "" "" "" "" ""];
|
||||
|
||||
"on-update" = "${checkBattery}";
|
||||
"tooltip-format" = ''
|
||||
{capacity}%: {timeTo}.
|
||||
Draw: {power} watts.'';
|
||||
|
|
Loading…
Reference in a new issue