diff options
author | 2023-06-17 12:33:33 +0200 | |
---|---|---|
committer | 2023-06-17 12:33:33 +0200 | |
commit | a5eb562e7bc67256728a0e416562f26c839135b9 (patch) | |
tree | 56c01fe4969ce7f3de4ed2c031dd01421f31bb8e | |
parent | 2e41349ea2628cee72df9109e1a2ef237d47d9c7 (diff) | |
download | dwmrc-a5eb562e7bc67256728a0e416562f26c839135b9.tar.gz dwmrc-a5eb562e7bc67256728a0e416562f26c839135b9.zip |
Add battery icons
-rwxr-xr-x | dwmbar | 40 |
1 files changed, 39 insertions, 1 deletions
@@ -2,6 +2,39 @@ delim="" +battery_check() +{ + local percentage=`apm | grep 'Remaining battery life' | head -1 | sed -E 's/.*: (.*)%/\1/g'` + + if [ $percentage -lt 10 ]; then + battery=`printf ""` + elif [ $percentage -gt 9 ] && [ $percentage -lt 20 ]; then + battery=`printf ""` + elif [ $percentage -gt 19 ] && [ $percentage -lt 30 ]; then + battery=`printf ""` + elif [ $percentage -gt 29 ] && [ $percentage -lt 40 ]; then + battery=`printf ""` + elif [ $percentage -gt 39 ] && [ $percentage -lt 50 ]; then + battery=`printf ""` + elif [ $percentage -gt 49 ] && [ $percentage -lt 60 ]; then + battery=`printf ""` + elif [ $percentage -gt 59 ] && [ $percentage -lt 70 ]; then + battery=`printf ""` + elif [ $percentage -gt 69 ] && [ $percentage -lt 80 ]; then + battery=`printf ""` + elif [ $percentage -gt 79 ] && [ $percentage -lt 90 ]; then + battery=`printf ""` + elif [ $percentage -gt 89 ] && [ $percentage -lt 96 ]; then + battery=`printf ""` + elif [ $percentage -gt 95 ]; then + battery=`printf ""` + else + battery=`printf ""` + fi + + battery="$battery $percentage% $delim" +} + check_audio() { volume="`dwmaudio` $delim" @@ -22,11 +55,16 @@ check_battery() battery="`sysctl hw.acpi.battery | grep life | sed -E 's/.*: (.*)/\1%/'` $delim" } +battery_check +echo $battery + +exit + while true; do check_datetime check_weather check_audio - check_battery + battery_check xsetroot -name "$battery $weather $volume $datetime"; sleep 1; done |