add low battery notification and add dunst to system-path

This commit is contained in:
Sakooooo 2023-08-04 23:17:51 +03:00
parent 574e89ba17
commit 080834aa77
Signed by: sako
GPG key ID: 3FD715D87D7725E0
2 changed files with 6 additions and 1 deletions

View file

@ -18,10 +18,15 @@ cpu() {
battery() { battery() {
get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)" get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)"
get_status="$(cat /sys/class/power_supply/BAT1/status)" get_status="$(cat /sys/class/power_supply/BAT1/status)"
sent_notification=false
case "$get_status" in case "$get_status" in
Charging) printf "^c$blue^ 󰂄 $get_capacity" ;; Charging) printf "^c$blue^ 󰂄 $get_capacity" ;;
Discharging) if (( $get_capacity <= 20)); then Discharging) if (( $get_capacity <= 20)); then
printf "^c$lightred^ 󰂃 $get_capacity" printf "^c$lightred^ 󰂃 $get_capacity"
if [ $sent_notification = false ]; then
dunstify -u critical "Battery low" "Please charge battery"
sent_notification=true
fi
else else
printf "^c$blue^ 󰁹 $get_capacity" printf "^c$blue^ 󰁹 $get_capacity"
fi ;; fi ;;

View file

@ -9,7 +9,7 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
users.users.sako.packages = with pkgs; [ environment.systemPackages = with pkgs; [
dunst dunst
]; ];
}; };