2021-04-07 22:56:28 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# Prints all batteries, their percentage remaining and an emoji corresponding
|
2021-08-23 22:39:37 +01:00
|
|
|
# to charge status ( for plugged up, for discharging on battery, etc.).
|
2021-04-07 22:56:28 +01:00
|
|
|
|
|
|
|
|
case $BLOCK_BUTTON in
|
2021-08-23 22:39:37 +01:00
|
|
|
3) notify-send " Battery module" ": discharging
|
|
|
|
|
: not charging
|
|
|
|
|
: stagnant charge
|
|
|
|
|
: charging
|
|
|
|
|
: charged
|
|
|
|
|
: battery very low!
|
2021-04-07 22:56:28 +01:00
|
|
|
- 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
|
|
|
|
|
case "$(cat "$battery/status")" in
|
2021-08-23 22:39:37 +01:00
|
|
|
"Full") status="" ;;
|
|
|
|
|
"Discharging") status="" ;;
|
|
|
|
|
"Charging") status="" ;;
|
|
|
|
|
"Not charging") status="" ;;
|
|
|
|
|
"Unknown") status="" ;;
|
2021-04-07 22:56:28 +01:00
|
|
|
esac
|
|
|
|
|
capacity=$(cat "$battery/capacity")
|
|
|
|
|
# Will make a warn variable if discharging and low
|
2021-08-23 22:39:37 +01:00
|
|
|
[ "$status" = "" ] && [ "$capacity" -le 75 ] && status=""
|
|
|
|
|
[ "$status" = "" ] && [ "$capacity" -le 50 ] && status=""
|
|
|
|
|
[ "$status" = "" ] && [ "$capacity" -le 25 ] && status=""
|
|
|
|
|
[ "$status" = "" ] && [ "$capacity" -le 10 ] && status=""
|
2021-04-07 22:56:28 +01:00
|
|
|
# Prints the info
|
2021-08-23 22:39:37 +01:00
|
|
|
printf "%s %d%%" "$status" "$capacity";
|
2021-04-07 22:56:28 +01:00
|
|
|
done && exit 0
|