diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2019-11-15 10:08:23 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2019-11-15 10:08:23 +0100 |
commit | 07010e9b439e20e2ac76c5937c71cd27625d046f (patch) | |
tree | 3f24259104e44796c794089ef4b227284863974e | |
parent | In progress (diff) | |
download | lowbat-gnu-07010e9b439e20e2ac76c5937c71cd27625d046f.tar.gz lowbat-gnu-07010e9b439e20e2ac76c5937c71cd27625d046f.tar.bz2 lowbat-gnu-07010e9b439e20e2ac76c5937c71cd27625d046f.tar.xz lowbat-gnu-07010e9b439e20e2ac76c5937c71cd27625d046f.tar.zst lowbat-gnu-07010e9b439e20e2ac76c5937c71cd27625d046f.zip |
Now handles custom messages
-rwxr-xr-x | bin/lowbat | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -1,20 +1,23 @@ #!/bin/sh -##if [ $@ -lt 2 ]; then -## message="beep beep - low battery" -##else -## message=$2 -##fi +if [ $# -lt 1 ]; then + message="beep beep - low battery" +else + message=$1 +fi notify() { - notify-send "Low battery" "Please plug in computer" -u critical -t 15000 - echo $message | espeak + notify-send "Low battery: $batlvl%" "Please plug in computer" -u critical -t 15000 + if [ "$message" = "no-audio" ]; then + else + echo "$message" | espeak + fi } while [ 1 ]; do acstat=$(acpi | awk '{print $3}' | rev | cut -c 2- | rev) batlvl=$(acpi | awk '{print $4}' | rev | cut -c 3- | rev) - if [ $batlvl -lt 15 ]; then + if [ $batlvl -lt 115 ]; then while [ "$acstat" = "Discharging" ]; do $(notify) sleep 20 |