diff options
author | Saumit Dinesan <justsaumit@protonmail.com> | 2022-09-25 23:12:30 +0530 |
---|---|---|
committer | Saumit Dinesan <justsaumit@protonmail.com> | 2022-09-25 23:12:30 +0530 |
commit | 1d70accabd7e66dc4fc3ec256da3eb383e59e528 (patch) | |
tree | 72974336039c264280d66c7380d0d7dc315b0207 /.scripts/battery | |
parent | ed116d02cf893106134a18e8d51c1fc174967bde (diff) |
using font-awesome icon for battery script
Diffstat (limited to '.scripts/battery')
-rwxr-xr-x | .scripts/battery | 39 |
1 files 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" |