diff --git a/roles/i3/files/battery b/roles/i3/files/battery index cba88ca..e72d3c8 100755 --- a/roles/i3/files/battery +++ b/roles/i3/files/battery @@ -1,11 +1,13 @@ #!/bin/bash icon="" -battery="$(upower -d | awk '/on-battery/ {print $2}')" + percent="$(upower -d | awk '/percentage/ {print $2}' | head -n 1)" remaining="$(upower -d | awk -F: '/time to empty/ {print $2}' | awk '{print $1,$2}' | head -n 1)" -if [ "$battery" = 'yes' ]; then +if upower -d | grep '\bcharging\b' >/dev/null 2>&1; then + echo "${icon} ${percent}" +elif upower -d | grep '\bdischarging\b' >/dev/null 2>&1; then if [ -n "$remaining" ] && [ "$(echo "$percent" | awk -F% '{print $1}')" -lt "$THRESHOLD" ]; then notify-send "CHARGE BATTERY" for file in /dev/pts/*; do