refractor plus additional click and long string functions

This commit is contained in:
koksnuss 2018-05-31 00:29:13 +02:00
parent 4b9d064b32
commit 492abcf744
6 changed files with 52 additions and 24 deletions

View File

@ -4,8 +4,7 @@
[[ "$BLOCK_BUTTON" == 1 ]] && LONG=true [[ "$BLOCK_BUTTON" == 1 ]] && LONG=true
[[ "$BLOCK_BUTTON" == 3 ]] && amixer set $DEV toggle &> /dev/null
[[ "$BLOCK_BUTTON" == 2 ]] && amixer set $DEV toggle &> /dev/null
amixer get $DEV | gawk -v LONG="$LONG" ' amixer get $DEV | gawk -v LONG="$LONG" '
match($0, /\[([0-9]+)\%\] \[(on|off)\]/, matches) { match($0, /\[([0-9]+)\%\] \[(on|off)\]/, matches) {
@ -39,7 +38,7 @@ amixer get $DEV | gawk -v LONG="$LONG" '
printf("▇\n▇\n") printf("▇\n▇\n")
} else { } else {
printf("█\n█\n") printf("█\n█\n")
} }
} }
if (load < 75) { if (load < 75) {
print("#04B431\n") print("#04B431\n")

View File

@ -22,6 +22,7 @@ cat "$DIR/brightness" "$DIR/max_brightness" | gawk -v MODE="$MODE" -v LONG="$LON
load = ( cbr / mbr ) * 100 load = ( cbr / mbr ) * 100
if (LONG == "true") { if (LONG == "true") {
printf("%d%\n", load) printf("%d%\n", load)
printf("%d%\n", load)
} else { } else {
if (load < 100 / 9) { if (load < 100 / 9) {
printf("▁\n▁\n") printf("▁\n▁\n")

View File

@ -9,7 +9,7 @@ if [[ "$BLOCK_INSTANCE" == "" ]]; then
[[ -f "${BAT}uevent" ]] && BATS+="$BAT/uevent " [[ -f "${BAT}uevent" ]] && BATS+="$BAT/uevent "
done done
else 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 fi
if [[ "$BATS" == "" ]]; then if [[ "$BATS" == "" ]]; then
@ -23,7 +23,7 @@ cat $BATS | gawk -F '=' -v LONG="$LONG" '
efull = 0 efull = 0
enow = 0 enow = 0
status = "" status = ""
} }
/POWER_SUPPLY_STATUS=/ { /POWER_SUPPLY_STATUS=/ {
if (status == "") { if (status == "") {
if ($2 == "Discharging") { if ($2 == "Discharging") {
@ -45,7 +45,7 @@ cat $BATS | gawk -F '=' -v LONG="$LONG" '
printf("%s%d%\n", status, charge) printf("%s%d%\n", status, charge)
} else { } else {
if (charge < 100 / 9) { if (charge < 100 / 9) {
printf("\n") printf("%s▁\n", status)
} else if (charge < 100 / 9 * 2 ) { } else if (charge < 100 / 9 * 2 ) {
printf("%s▁\n", status) printf("%s▁\n", status)
} else if (charge < 100 / 9 * 3 ) { } else if (charge < 100 / 9 * 3 ) {
@ -62,7 +62,7 @@ cat $BATS | gawk -F '=' -v LONG="$LONG" '
printf("%s▇\n", status) printf("%s▇\n", status)
} else { } else {
printf("%s█\n", status) printf("%s█\n", status)
} }
} }
printf("%s%d\n", status, charge) printf("%s%d\n", status, charge)
if (charge > 25) { if (charge > 25) {

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/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" ' top -bn1 | gawk -v LONG="$LONG" '
/^\%CPU/ { /^\%CPU/ {
@ -30,7 +30,7 @@ top -bn1 | gawk -v LONG="$LONG" '
printf("▇\n▇\n") printf("▇\n▇\n")
} else { } else {
printf("█\n█\n") printf("█\n█\n")
} }
} }
if (load < 50) { if (load < 50) {
print("#04B431\n") print("#04B431\n")

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/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 if [[ "$BLOCK_INSTANCE" =~ "ram" ]]; then
TYPE='swap' TYPE='swap'

View File

@ -1,20 +1,48 @@
#!/bin/bash #!/bin/bash
df | gawk '
/\/$/ { [[ "$BLOCK_BUTTON" == 1 ]] && LONG=true
free_storage=$4/1024^2
[[ "$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 { END {
if (free_storage < 1) { if (LONG == "true") {
printf(" full \n") if (free_storage < 1) {
printf("full\n") printf(" full \n")
exit 33 printf("full\n")
} else if (free_storage > 5) { exit 33
printf("%.1f G\n", free_storage) } else if (free_storage > 5) {
printf("%dG\n", free_storage) 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 { } else {
printf("%.0f M\n", free_storage / 1024) if (load < 100 / 9) {
printf("%dM\n", free_storage / 1024) 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) { if (free_storage > 20) {
print("#04B431\n") print("#04B431\n")