add lowpower.sh

This commit is contained in:
cuu 2018-12-14 18:20:09 +08:00
parent 425cb66d6f
commit 52bc2bed04
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1 @@
Low Battery Warning

View File

@ -0,0 +1,17 @@
#!/bin/bash
BAT_PNT=`upower -i $(upower -e | grep 'battery') | grep -E "state|to\ full|percentage" | awk '/perc/{print $2}' | cut -d % -f1 `
if [ "$BAT_PNT" -lt "20" ]; then
if [ "$BAT_PNT" -lt "10" ]; then
echo '{"type":"once","content":"Low Battery: 10% of battery remaining"}'
fi
if [ "$BAT_PNT" -lt "5" ]; then
echo '{"type":"once","content":"Low Battery: 10% of battery remaining"}'
fi
else
echo $BAT_PNT
fi