diff --git a/config b/config index e443219..9ae5850 100644 --- a/config +++ b/config @@ -38,15 +38,15 @@ label=⎋ # /sys/class/power_supply/BATx you can use the instance=x command [battery] # label=battery -# label=⚡ +# label=~ # ▁▂▃▄▅▆▇█ # █ # ▉ # ▊ # ▋ # ▌ -# ▍⎋ -# ▎⌨ +# ▍⎋⚡ +# ▎⌨⌨ # ▏⟠, ⟰, ⟱, ⟲, ⟳, ⤋, ⤊, # [battery] # instance=1 diff --git a/modules/battery b/modules/battery index 0596594..585e7f3 100755 --- a/modules/battery +++ b/modules/battery @@ -2,6 +2,8 @@ DIR="/sys/class/power_supply" +[[ "$BLOCK_BUTTON" == "1" ]] && LONG=true || LONG=false + if [[ "$BLOCK_INSTANCE" == "" ]]; then for BAT in $DIR/BAT*/; do [[ -f "${BAT}uevent" ]] && BATS+="$BAT/uevent " @@ -16,7 +18,7 @@ if [[ "$BATS" == "" ]]; then exit 33 fi -cat $BATS | gawk -F '=' ' +cat $BATS | gawk -F '=' -v LONG="$LONG" ' BEGIN { efull = 0 enow = 0 @@ -24,13 +26,10 @@ cat $BATS | gawk -F '=' ' } /POWER_SUPPLY_STATUS=/ { if (status == "") { - status = $2 - if (status == "Discharging") { + if ($2 == "Discharging") { status = "" - } else if (status == "Charging") { + } else if ($2 == "Charging") { status = "⚡" - } else { - status = "" } } } @@ -42,7 +41,30 @@ cat $BATS | gawk -F '=' ' } END { charge = enow / efull * 100 - printf("%s%d%\n", status, charge) + + if (LONG == "false") { + if (charge < 100 / 9) { + printf("\n") + } else if (charge < 100 / 9 * 2 ) { + printf("%s▁\n", status) + } else if (charge < 100 / 9 * 3 ) { + printf("%s▂\n", status) + } else if (charge < 100 / 9 * 4 ) { + printf("%s▃\n", status) + } else if (charge < 100 / 9 * 5 ) { + printf("%s▄\n", status) + } else if (charge < 100 / 9 * 6 ) { + printf("%s▅\n", status) + } else if (charge < 100 / 9 * 7 ) { + printf("%s▆\n", status) + } else if (charge < 100 / 9 * 8 ) { + printf("%s▇\n", status) + } else { + printf("%s█\n", status) + } + } else { + printf("%s%d%\n", status, charge) + } printf("%s%d\n", status, charge) if (charge > 25) { print("#04B431\n")