mirror of
https://github.com/Keyitdev/dotfiles.git
synced 2026-09-24 01:52:09 +00:00
Update: Even better battery script.
This commit is contained in:
+7
-6
@@ -11,13 +11,14 @@ dir_icons="/usr/local/bin/icons"
|
||||
# notify when below this percentage
|
||||
warning_level=20
|
||||
|
||||
# how often to check battery status, in minutes
|
||||
check_interval=1
|
||||
# how often to check battery status, in seconds
|
||||
check_interval=60
|
||||
|
||||
while true; do
|
||||
battery_level=$(upower -i $(upower -e | grep BAT) | grep -E "percentage" | sed 's/[^0-9]//g')
|
||||
discharging=$(upower -i $(upower -e | grep BAT) | grep -E "state" | grep -c "discharging")
|
||||
time_to_empty=$(upower -i $(upower -e | grep BAT) | grep -E "time to empty" | sed 's/[^0-9,.]//g')
|
||||
path_to_battery=$(upower -e | grep BAT)
|
||||
battery_level=$(upower -i "$path_to_battery" | grep -E "percentage" | sed 's/[^0-9]//g')
|
||||
discharging=$(upower -i "$path_to_battery" | grep -E "state" | grep -c "discharging")
|
||||
time_to_empty=$(upower -i "$path_to_battery" | grep -E "time to empty" | sed 's/[^0-9,.]//g')
|
||||
|
||||
# check if battery is low and discharging
|
||||
if [ "$battery_level" -lt "$warning_level" ] && [ "$discharging" -eq 1 ]
|
||||
@@ -29,5 +30,5 @@ while true; do
|
||||
-i $dir_icons/battery.svg
|
||||
fi
|
||||
|
||||
sleep ${check_interval}m
|
||||
sleep ${check_interval}s
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user