diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-08-17 16:17:11 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-08-17 16:17:11 +0300 |
| commit | b7c5168e977b38cd360f9894200cc26f282aba30 (patch) | |
| tree | 41ad6bbf04e9c8b3cf3ed28aa1c1258af15e96ce | |
| parent | 8c16e555361cff313dfb5ba0910d6c97d8d04477 (diff) | |
| download | dotfiles-b7c5168e977b38cd360f9894200cc26f282aba30.tar dotfiles-b7c5168e977b38cd360f9894200cc26f282aba30.tar.gz dotfiles-b7c5168e977b38cd360f9894200cc26f282aba30.zip | |
Fixed battery status sending multiple notifications
| -rwxr-xr-x | battery-status.sh | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/battery-status.sh b/battery-status.sh index f0a829f..d796568 100755 --- a/battery-status.sh +++ b/battery-status.sh @@ -1,11 +1,9 @@ #!/bin/bash battery_notify () { - if [ ${__bat_per} -eq $1 ] && [[ ${__bat_power} = $2 ]] && ! [[ -f "/tmp/battery.tmp" ]]; then + if [ ${__bat_per} -eq $1 ] && ! grep -q $1 "/tmp/battery.tmp" && [[ ${__bat_power} = $2 ]]; then notify-send -u critical -i battery-low "$3" - touch /tmp/battery.tmp - elif ! [ ${__bat_per} -eq $1 ] && [[ -f "/tmp/battery.tmp" ]]; then - rm /tmp/battery.tmp + echo $1 >> /tmp/battery.tmp fi } @@ -30,8 +28,12 @@ if command -v upower > /dev/null 2>&1 ; then echo " ${__time_full}" fi + if [ ! -f "/tmp/battery.tmp" ]; then + touch /tmp/battery.tmp + fi + battery_notify 100 'fully-charged' 'Battery charged!' - battery_notify 15 'discharging' 'Battery low!' - battery_notify 10 'discharging' 'Battery lower!!' - battery_notify 5 'discharging' 'Battery critical!!!' + battery_notify 15 'discharging' 'Battery low (15%)!' + battery_notify 10 'discharging' 'Battery lower (10%)!!' + battery_notify 5 'discharging' 'Battery critical (5%)!!!' fi |
