23 lines
849 B
Bash
Executable File
23 lines
849 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euf -o pipefail
|
|
|
|
if [ -d /sys/class/power_supply/BAT0 ]; then
|
|
battery_info="$(head -n 1 /sys/class/power_supply/BAT0/capacity)%"
|
|
current_charge=$(echo "$battery_info" | grep -o '[0-9]\+%' | awk '{sub (/%/, "", $1); print $1}')
|
|
|
|
if [[ $current_charge -lt 11 ]]; then
|
|
ICON="/home/deadguy/Pictures/.icn/battery-empty.png"
|
|
elif [[ $current_charge -lt 31 ]]; then
|
|
ICON="/home/deadguy/Pictures/.icn/battery-caution.png"
|
|
elif [[ $current_charge -lt 51 ]]; then
|
|
ICON="/home/deadguy/Pictures/.icn/battery-low.png"
|
|
elif [[ $current_charge -lt 71 ]]; then
|
|
ICON="/home/deadguy/Pictures/.icn/battery-good.png"
|
|
elif [[ $current_charge -lt 90 ]]; then
|
|
ICON="/home/deadguy/Pictures/.icn/battery-full.png"
|
|
else
|
|
ICON="/home/deadguy/Pictures/.icn/battery-full.png"
|
|
fi
|
|
notify-send -t 5000 -i "$ICON" "$current_charge%"
|
|
fi
|