mirror of
https://github.com/GRFreire/scripts.git
synced 2026-01-08 04:19:39 +00:00
add script check_battery
This commit is contained in:
parent
dfe8069718
commit
6de5431477
1
bin/check_battery
Symbolic link
1
bin/check_battery
Symbolic link
@ -0,0 +1 @@
|
||||
../check_battery/check_battery.sh
|
||||
9
check_battery/README.md
Normal file
9
check_battery/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# check_battery
|
||||
|
||||
## About
|
||||
Check the battery percentage and notify user if it is about to end.
|
||||
|
||||
## Requirements
|
||||
- notify-send
|
||||
- mpv
|
||||
- UPower
|
||||
17
check_battery/check_battery.sh
Executable file
17
check_battery/check_battery.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
DEVICE="/org/freedesktop/UPower/devices/battery_BAT0"
|
||||
|
||||
time="$(upower -i $DEVICE | grep time | cut -d':' -f2 | tr -s ' ' | cut -c2-)"
|
||||
perc="$(upower -i $DEVICE | grep percentage | awk '{print $2}' | tr -d '%')"
|
||||
stat="$(upower -i $DEVICE | grep state | awk '{print $2}')"
|
||||
|
||||
if [ "$perc" -le "20" ]; then
|
||||
urgency="normal"
|
||||
if [ "$perc" -le "10" ]; then
|
||||
urgency="critical"
|
||||
fi
|
||||
notify-send -u "$urgency" --icon="battery" "Battery is low ($perc%)" "Time remaining is $time."
|
||||
mpv /usr/share/sounds/freedesktop/stereo/dialog-information.oga
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user