summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2022-10-05 21:06:22 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2022-10-05 21:06:22 +0530
commitba8cf40f6e69fdb66e19dc29c696d5acf02fc22a (patch)
tree47db320c3ab762a8f3a0b172e50cba7d2efcb052
parent66ba6ec85d446f83f37240c8f2f30857c4588cea (diff)
battery script update
-rwxr-xr-x.scripts/battery11
1 files changed, 5 insertions, 6 deletions
diff --git a/.scripts/battery b/.scripts/battery
index 1f33383..41a7142 100755
--- a/.scripts/battery
+++ b/.scripts/battery
@@ -1,7 +1,7 @@
#!/bin/sh
# Prints all batteries, their percentage remaining and an emoji corresponding
-# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.).
+# to charge status ( for plugged up, "$capacity_lvl" for discharging on battery, etc.).
# Loop through all attached batteries and format the info
for battery in /sys/class/power_supply/BAT?*; do
# If non-first battery, print a space separator.
@@ -26,17 +26,16 @@ for battery in /sys/class/power_supply/BAT?*; do
# Sets up the status and capacity
case "$(cat "$battery/status" 2>&1)" in
"Full") status="" ;;
-# "Discharging") status="$capacity-level" ;;
"Discharging") status="$capacity_lvl" ;;
"Charging") status=" " ;;
- "Not charging") status="🛑" ;;
- "Unknown") status="🟢" ;;
+ "Not charging") status=" " ;;
+ "Unknown") status="" ;;
*) exit 1 ;;
esac
# Will make a warn variable if discharging and low
- [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" && dunstify "Critical Battery" "Charge Immediately" -u critical -i battery-quarter
+ [ "$(cat "$battery/status" 2>&1)" = "Discharging" ] && [ "$capacity" -le 25 ] && warn="❗" && dunstify "Critical Battery" "Charge Immediately" -u critical -i battery-quarter
#parse json file in future and close the persistent Critical Battery notification
- [ "$status" = "🔌" ] && [ "$capacity" -le 25 ] && [ "$warn" = "❗" ] && [ $(dunsctl count displayed) == 1 ] && dunstctl close
+ [ "$status" = " " ] && [ "$capacity" -le 25 ] && [ $(dunstctl count displayed) == 1 ] && dunstctl close
# Prints the info
printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
done && printf "\\n"