mirror of
https://github.com/Keyitdev/dotfiles.git
synced 2026-09-24 01:52:09 +00:00
35 lines
746 B
Bash
Executable File
35 lines
746 B
Bash
Executable File
#!/bin/sh
|
|
|
|
for pid in $(pidof -x battery); do
|
|
if [ "$pid" != $$ ]; then
|
|
kill -9 "$pid"
|
|
fi
|
|
done
|
|
|
|
dir_icons="/usr/local/bin/icons"
|
|
|
|
# notify when below this percentage
|
|
warning_level=15
|
|
|
|
# how often to check battery status, in minutes
|
|
check_interval=1
|
|
|
|
while true; do
|
|
battery_level=$(acpi -b \
|
|
| cut -d, -f2 | cut --characters=2,3,4 \
|
|
| sed 's/%//g')
|
|
charging=$(acpi -b | grep -c "charging")
|
|
|
|
# when battery is low, and not already charging
|
|
if [ "$battery_level" -lt "$warning_level" ] &&
|
|
[ "$charging" -eq 0 ]
|
|
then
|
|
dunstify -a "Battery" \
|
|
"Low battery: ${battery_level}%" \
|
|
"Battery is running low" \
|
|
-r 100 \
|
|
-i $dir_icons/battery.svg
|
|
fi
|
|
|
|
sleep ${check_interval}m
|
|
done |