From 1d70accabd7e66dc4fc3ec256da3eb383e59e528 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sun, 25 Sep 2022 23:12:30 +0530 Subject: using font-awesome icon for battery script --- .scripts/battery | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/.scripts/battery b/.scripts/battery index 4ff2318..ab01b9b 100755 --- a/.scripts/battery +++ b/.scripts/battery @@ -2,36 +2,41 @@ # Prints all batteries, their percentage remaining and an emoji corresponding # to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.). - -case $BLOCK_BUTTON in - 3) notify-send "🔋 Battery module" "🔋: discharging -🛑: not charging -♻ : stagnant charge -🔌: charging -⚡: charged -❗: battery very low! -- Scroll to change adjust xbacklight." ;; - 4) xbacklight -inc 10 ;; - 5) xbacklight -dec 10 ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - # 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. [ -n "${capacity+x}" ] && printf " " - # Sets up the status and capacity + + #capacity-level + capacity="$(cat "$battery/capacity" 2>&1)" + + if [ "$capacity" -ge 75 ] && [ "$capacity" -le 100 ] + then + capacity_lvl=" " + elif [ 51<="$capacity" && "$capacity"<=75 ] + then + capacity_lvl=" " + elif [ 25<="$capacity" && "$capacity"<=50 ] + then + capacity_lvl=" " + else + capacity_lvl=" " + fi + + # Sets up the status and capacity case "$(cat "$battery/status" 2>&1)" in "Full") status="⚡" ;; - "Discharging") status="🔋" ;; +# "Discharging") status="$capacity-level" ;; + "Discharging") status="$capacity_lvl" ;; "Charging") status="🔌" ;; "Not charging") status="🛑" ;; "Unknown") status="🟢" ;; *) exit 1 ;; esac - capacity="$(cat "$battery/capacity" 2>&1)" # Will make a warn variable if discharging and low [ "$status" = "🔋" ] && [ "$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 # Prints the info printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn done && printf "\\n" -- cgit v1.2.3