diff options
| author | Syndamia <kamen@syndamia.com> | 2023-03-18 17:05:44 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2023-03-18 17:05:44 +0200 |
| commit | f92e51c11452a0f015594ce024d7bc2d7c9b6334 (patch) | |
| tree | e370c9f9a4f328fc962bcd740426db750b18099b /.a | |
| parent | 9461558fe1a8af5d686fceffbe6edf6e990731bc (diff) | |
| download | dotfiles-f92e51c11452a0f015594ce024d7bc2d7c9b6334.tar dotfiles-f92e51c11452a0f015594ce024d7bc2d7c9b6334.tar.gz dotfiles-f92e51c11452a0f015594ce024d7bc2d7c9b6334.zip | |
[.a/bs] Fixed power indicator character logic and some formatting
Diffstat (limited to '.a')
| -rwxr-xr-x | .a/battery-status.sh | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/.a/battery-status.sh b/.a/battery-status.sh index 671c243..1947660 100755 --- a/.a/battery-status.sh +++ b/.a/battery-status.sh @@ -10,13 +10,15 @@ upower -i /org/freedesktop/UPower/devices/battery_BAT0 > /tmp/BAT0 [ "$(awk '/native-path/{print $2}' /tmp/BAT0)" = '(null)' ] && exit bat_state="$(awk '/state/{print substr($2, 1, 1)}' /tmp/BAT0)" -[ $bat_state = 'c' ] && bat_power_ind='' || (\ -[ $bat_state = 'd' ] && bat_power_ind='' || \ - bat_power_ind='' ) +if [ $bat_state = 'c' ]; then bat_power_ind='' +elif [ $bat_state = 'd' ]; then bat_power_ind='' +else bat_power_ind='' +fi bat_per="$(awk '/percentage/{print strtonum($2)}' /tmp/BAT0)" +bat_per=$((bat_per * 5 / 4 - 25)) # compensation for failing battery -[ $bat_state = 'd' ] \ +[ $bat_state = 'd' ] \ && bat_time="$(awk '/time to empty/{print $4 substr($5, 1, 1)}' /tmp/BAT0)" \ || bat_time="$(awk '/time to full/ {print $4 substr($5, 1, 1)}' /tmp/BAT0)" @@ -34,7 +36,7 @@ bat_notif="$(cat /tmp/bat_notif)" # Notify when battery is charged to 80% if [ $bat_state = 'c' ]; then if [ "$bat_notif" != 80 ] && [ $bat_per -ge 80 ]; then - notify-send -u normal -i battery-charging -t 999999 "Battery ${per}%" + notify-send -u normal -i battery-charging -t 999999 "Battery 80%" echo 80 > /tmp/bat_notif fi |
