Update battery.sh
This commit is contained in:
parent
1fdc8921fd
commit
6317d046f1
|
@ -1,17 +1,25 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
battery=/sys/class/power_supply/BAT0
|
battery=/sys/class/power_supply/BAT0
|
||||||
|
status=$(cat "$battery/status")
|
||||||
|
maxCapacity=85
|
||||||
|
|
||||||
|
#case "$(cat "$battery/status" 2>&1)" in
|
||||||
case "$(cat "$battery/status" 2>&1)" in
|
case "$(cat "$battery/status" 2>&1)" in
|
||||||
"Full") status="⚡" ;;
|
"Full") statusIcon="⚡" ;;
|
||||||
"Discharging") status="🔋" ;;
|
"Discharging") statusIcon="🔋" ;;
|
||||||
"Charging") status="🔌" ;;
|
"Charging") statusIcon="🔌" ;;
|
||||||
"Not charging") status="🛑" ;;
|
"Not charging") statusIcon="🛑" ;;
|
||||||
"Unknown") status="♻️" ;;
|
"Unknown") statusIcon="♻️" ;;
|
||||||
*) exit 1 ;;
|
*) exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
capacity="$(cat "$battery/capacity" 2>&1)"
|
if [ "$status" = "Full" ]; then
|
||||||
capacity=$(echo "$capacity/83*100" | bc -l)
|
printf "%s 100%%" "$statusIcon"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
printf "%s %.0f%%" "$status" "$capacity"
|
capacity="$(cat "$battery/capacity" 2>&1)"
|
||||||
|
capacity=$(echo "$capacity/$maxCapacity*100" | bc -l)
|
||||||
|
|
||||||
|
printf "%s %.0f%%" "$statusIcon" "$capacity"
|
||||||
|
|
Loading…
Reference in New Issue