diff --git a/modules/audio b/modules/audio index 0783d13..05b1502 100755 --- a/modules/audio +++ b/modules/audio @@ -4,8 +4,7 @@ [[ "$BLOCK_BUTTON" == 1 ]] && LONG=true - -[[ "$BLOCK_BUTTON" == 2 ]] && amixer set $DEV toggle &> /dev/null +[[ "$BLOCK_BUTTON" == 3 ]] && amixer set $DEV toggle &> /dev/null amixer get $DEV | gawk -v LONG="$LONG" ' match($0, /\[([0-9]+)\%\] \[(on|off)\]/, matches) { @@ -39,7 +38,7 @@ amixer get $DEV | gawk -v LONG="$LONG" ' printf("▇\n▇\n") } else { printf("█\n█\n") - } + } } if (load < 75) { print("#04B431\n") diff --git a/modules/backlight b/modules/backlight index 08367a2..b1b3f7c 100755 --- a/modules/backlight +++ b/modules/backlight @@ -22,6 +22,7 @@ cat "$DIR/brightness" "$DIR/max_brightness" | gawk -v MODE="$MODE" -v LONG="$LON load = ( cbr / mbr ) * 100 if (LONG == "true") { printf("%d%\n", load) + printf("%d%\n", load) } else { if (load < 100 / 9) { printf("▁\n▁\n") diff --git a/modules/battery b/modules/battery index 2a34987..680f30d 100755 --- a/modules/battery +++ b/modules/battery @@ -9,7 +9,7 @@ if [[ "$BLOCK_INSTANCE" == "" ]]; then [[ -f "${BAT}uevent" ]] && BATS+="$BAT/uevent " done else - [[ -f "$DIR/BAT$BLOCK_INSTANCE/uevent" ]] && BATS="$DIR/BAT$BLOCK_INSTANCE/uevent" + [[ -f "$DIR/BAT$BLOCK_INSTANCE/uevent" ]] && BATS="$DIR/BAT$BLOCK_INSTANCE/uevent" fi if [[ "$BATS" == "" ]]; then @@ -23,7 +23,7 @@ cat $BATS | gawk -F '=' -v LONG="$LONG" ' efull = 0 enow = 0 status = "" - } + } /POWER_SUPPLY_STATUS=/ { if (status == "") { if ($2 == "Discharging") { @@ -45,7 +45,7 @@ cat $BATS | gawk -F '=' -v LONG="$LONG" ' printf("%s%d%\n", status, charge) } else { if (charge < 100 / 9) { - printf("\n") + printf("%s▁\n", status) } else if (charge < 100 / 9 * 2 ) { printf("%s▁\n", status) } else if (charge < 100 / 9 * 3 ) { @@ -62,7 +62,7 @@ cat $BATS | gawk -F '=' -v LONG="$LONG" ' printf("%s▇\n", status) } else { printf("%s█\n", status) - } + } } printf("%s%d\n", status, charge) if (charge > 25) { diff --git a/modules/cpu b/modules/cpu index 69661ed..9f00cd3 100755 --- a/modules/cpu +++ b/modules/cpu @@ -1,8 +1,8 @@ #!/bin/bash -[[ "$BLOCK_INSTANCE" =~ "long" ]] && LONG=true +[[ "$BLOCK_INSTANCE" =~ "long" || "$BLOCK_BUTTON" == 1 ]] && LONG=true -[[ "$BLOCK_BUTTON" == 1 ]] && i3-sensible-terminal -e htop +[[ "$BLOCK_BUTTON" == 2 ]] && i3-sensible-terminal -e htop top -bn1 | gawk -v LONG="$LONG" ' /^\%CPU/ { @@ -30,7 +30,7 @@ top -bn1 | gawk -v LONG="$LONG" ' printf("▇\n▇\n") } else { printf("█\n█\n") - } + } } if (load < 50) { print("#04B431\n") diff --git a/modules/ram b/modules/ram index b0af198..3a94041 100755 --- a/modules/ram +++ b/modules/ram @@ -1,8 +1,8 @@ #!/bin/bash -[[ "$BLOCK_BUTTON" == 1 ]] && i3-sensible-terminal -e htop +[[ "$BLOCK_BUTTON" == 2 ]] && i3-sensible-terminal -e htop -[[ "$BLOCK_INSTANCE" =~ "long" ]] && LONG=true +[[ "$BLOCK_INSTANCE" =~ "long" || "$BLOCK_BUTTON" == 1 ]] && LONG=true if [[ "$BLOCK_INSTANCE" =~ "ram" ]]; then TYPE='swap' diff --git a/modules/storage b/modules/storage index 22c1d9c..9c9d261 100755 --- a/modules/storage +++ b/modules/storage @@ -1,20 +1,48 @@ #!/bin/bash -df | gawk ' - /\/$/ { - free_storage=$4/1024^2 + +[[ "$BLOCK_BUTTON" == 1 ]] && LONG=true + +[[ "$BLOCK_BUTTON" == 3 ]] && i3-sensible-terminal -e ranger + +df | gawk -v LONG="$LONG" ' + /\/$/ { + free_storage = $4 / 1024^2 + load = gensub(/^([0-9]{1,3})%$/, "\\1", "g", $5) } END { - if (free_storage < 1) { - printf(" full \n") - printf("full\n") - exit 33 - } else if (free_storage > 5) { - printf("%.1f G\n", free_storage) - printf("%dG\n", free_storage) + if (LONG == "true") { + if (free_storage < 1) { + printf(" full \n") + printf("full\n") + exit 33 + } else if (free_storage > 5) { + printf("%.1f G\n", free_storage) + printf("%dG\n", free_storage) + } else { + printf("%.0f M\n", free_storage / 1024) + printf("%dM\n", free_storage / 1024) + } } else { - printf("%.0f M\n", free_storage / 1024) - printf("%dM\n", free_storage / 1024) + if (load < 100 / 9) { + printf("▁\n▁\n") + } else if (load < 100 / 9 * 2 ) { + printf("▁\n▁\n") + } else if (load < 100 / 9 * 3 ) { + printf("▂\n▂\n") + } else if (load < 100 / 9 * 4 ) { + printf("▃\n▃\n") + } else if (load < 100 / 9 * 5 ) { + printf("▄\n▄\n") + } else if (load < 100 / 9 * 6 ) { + printf("▅\n▅\n") + } else if (load < 100 / 9 * 7 ) { + printf("▆\n▆\n") + } else if (load < 100 / 9 * 8 ) { + printf("▇\n▇\n") + } else { + printf("█\n█\n") + } } if (free_storage > 20) { print("#04B431\n")