mirror of
https://github.com/alyraffauf/nixcfg.git
synced 2024-11-25 13:51:54 -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}";
|
"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" = "{icon}";
|
||||||
"format-icons" = ["" "" "" "" "" "" "" "" "" ""];
|
"format-icons" = ["" "" "" "" "" "" "" "" "" ""];
|
||||||
|
|
||||||
|
"on-update" = "${checkBattery}";
|
||||||
"tooltip-format" = ''
|
"tooltip-format" = ''
|
||||||
{capacity}%: {timeTo}.
|
{capacity}%: {timeTo}.
|
||||||
Draw: {power} watts.'';
|
Draw: {power} watts.'';
|
||||||
|
|
Loading…
Reference in a new issue