From ef82a470492d7542ac4ce960a1b724e0f5861ad1 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Tue, 15 Dec 2020 16:29:17 -0500 Subject: conform style --- .local/bin/statusbar/battery | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to '.local/bin') diff --git a/.local/bin/statusbar/battery b/.local/bin/statusbar/battery index 48df164..ac4d9a4 100755 --- a/.local/bin/statusbar/battery +++ b/.local/bin/statusbar/battery @@ -16,40 +16,23 @@ case $BLOCK_BUTTON in 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -# acpi alternative -# acpi | sed "s/Battery [0-9]: //;s/[Dd]ischarging, /🔋/;s/[Nn]ot charging, /🛑/;s/[Cc]harging, /🔌/;s/[Uu]nknown, /♻️/;s/[Ff]ull, /⚡/;s/ \(remaining\|until charged\)//"; exit - # Check if battery directories are detected [ ! -e /sys/class/power_supply/BAT?* ] && echo "No battery found" && exit 1 -# Defines the formatting for the info from the battery folders -format() -{ +# Loop through all attached batteries and format the info +for battery in /sys/class/power_supply/BAT?* +do # Sets up the status and capacity - status=$(cat "$1/status") + status=$(cat "$battery/status") case "$status" in - "Full") - status="⚡ " - ;; - "Discharging") - status="🔋 " - ;; - "Not charging") - status="🛑 " - ;; - "Unknown") - status="♻️/ " - ;; + "Full") status="⚡" ;; + "Discharging") status="🔋" ;; + "Not charging") status="🛑" ;; + "Unknown") status="♻️" ;; esac - capacity=$(cat "$1/capacity") + capacity=$(cat "$battery/capacity") # Will make a warn variable if discharging and low - [ "$status" = "🔋 " ] && [ "$capacity" -le 25 ] && local warn="❗ " + [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && local warn="❗" # Prints the info printf "%s%s%d%%\n" "$status" "$warn" "$capacity" -} - -# Loop through all attached batteries and format the info -for battery in /sys/class/power_supply/BAT?* -do - format $battery done && return 0 -- cgit v1.3.1