From 9a2e0c9499c81c72e5fdb72ef9fe0ef0a177d1fa Mon Sep 17 00:00:00 2001 From: Sakooooo <78461130+Sakooooo@users.noreply.github.com> Date: Fri, 4 Aug 2023 18:01:45 +0300 Subject: [PATCH] script color for low battery --- config/dwm/scripts/bar.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/dwm/scripts/bar.sh b/config/dwm/scripts/bar.sh index 89842387..1194b78a 100755 --- a/config/dwm/scripts/bar.sh +++ b/config/dwm/scripts/bar.sh @@ -15,12 +15,21 @@ cpu() { printf "^c$white^ ^b$grey^ $cpu_val" } +lowbattery() { + get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)" + if (( get_capacity <= 20)); then + printf "^c$red^ Low! $get_capacity" + else + printf "^c$blue^  $get_capacity" + fi +} + battery() { get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)" get_status="$(cat /sys/class/power_supply/BAT1/status)" case "$get_status" in Charging) printf "^c$blue^ Charging $get_capacity" ;; - Discharging) printf "^c$blue^  $get_capacity" ;; + Discharging) $(lowbattery) ;; esac #printf "^c$blue^  $get_capacity" }