From 11f963804edb9823992df9540bbf1d87afd1935f Mon Sep 17 00:00:00 2001 From: koksnuss Date: Thu, 9 Aug 2018 18:43:59 +0200 Subject: [PATCH] towards new whatever! --- config | 10 +++++----- modules/backlight | 45 +++++++++++++++++++++------------------------ 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/config b/config index 7278da0..a669528 100644 --- a/config +++ b/config @@ -9,8 +9,8 @@ interval=5 label=☼ # label=☀,☼,✱,✲,✳,✴,✵,✺ signal=3 -instance=color -# instance=color,long +instance=color,long +# instance=color,bw,long # [iface] # label=iface @@ -18,7 +18,7 @@ instance=color [storage] label=⛁ # label=⛀,⛁,⛂,⛃ -interval=60 +# interval=60 # if you want to display ram and swap seperately, you can assign another [ram] module # with instance=ram or instance=swap @@ -31,13 +31,13 @@ instance=ram [cpu] label=☷ -instance=long +# instance=long interval=2 [temp] label=ϑ interval=2 -instance=long +# instance=long [ip] # label=ip diff --git a/modules/backlight b/modules/backlight index 78940ef..7092405 100755 --- a/modules/backlight +++ b/modules/backlight @@ -1,52 +1,49 @@ #!/bin/bash DIR="/sys/class/backlight" - -[[ "$BLOCK_INSTANCE" =~ "color" ]] && MODE="color" || MODE="bw" -[[ "$BLOCK_INSTANCE" =~ "long" || "$BLOCK_BUTTON" == 1 ]] && LONG=true +[[ "$BLOCK_INSTANCE" =~ "color" ]] && COLORS=True +[[ "$BLOCK_INSTANCE" =~ "long" || "$BLOCK_BUTTON" == 1 ]] && LONG=True if [[ -d "$DIR/acpi_video0" ]]; then DIR="$DIR/acpi_video0" elif [[ -d "$DIR/intel_backlight" ]]; then DIR="$DIR/intel_backlight" else - echo " no backlight " - echo "n/a" + printf "no backlight\nn/a\n" exit 33 fi -cat "$DIR/brightness" "$DIR/max_brightness" | gawk -v MODE="$MODE" -v LONG="$LONG" ' +BAR=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█") +COLOR=("#64bc01" "#77a601" "#8a9101" "#9d7b00" "#b06701" "#c45100" "#d63c00" "#e92700") +BW=("#565656" "#6d6d6d" "#848485" "#9c9c9c" "#b1b1b1" "#c7c7c7" "#dcdcdc" "#f5f5f6") + +cat "$DIR/brightness" "$DIR/max_brightness" | gawk -v BAR="${BAR[*]}" -v COLOR="${COLOR[*]}" -v BW="${BW[*]}" -v COLORS="$COLORS" -v LONG="$LONG" ' BEGIN { - bar[1] = "▁"; color[1] = "#64bc01"; bw[1] = "#565656" - bar[2] = "▂"; color[2] = "#77a601"; bw[2] = "#6d6d6d" - bar[3] = "▃"; color[3] = "#8a9101"; bw[3] = "#848485" - bar[4] = "▄"; color[4] = "#9d7b00"; bw[4] = "#9c9c9c" - bar[5] = "▅"; color[5] = "#b06701"; bw[5] = "#b1b1b1" - bar[6] = "▆"; color[6] = "#c45100"; bw[6] = "#c7c7c7" - bar[7] = "▇"; color[7] = "#d63c00"; bw[7] = "#dcdcdc" - bar[8] = "█"; color[8] = "#e92700"; bw[8] = "#f5f5f6" - step = 100 / length(bar) + split(BAR, bar, / /) + split(COLOR, color, / /) + split(BW, bw, / /) + interval = 100 / length(bar) } - NR==1 { cbr = $1 } - NR==2 { mbr = $1 } + NR == 1 { current_brightness = $1 } + NR == 2 { maximum_brightness = $1 } END { - load = ( cbr / mbr ) * 100 - if (LONG == "true") { - printf("%d%\n%d\n", load, load) + brightness = ( current_brightness / maximum_brightness ) * 100 + if (LONG) { + printf("%d%\n%d\n", brightness, brightness) } else { for (i in bar) { - if (load <= i * step) { + if (brightness <= i * interval) { printf("%s\n%s\n", bar[i], bar[i]) break } } } - for (i in color) { - if (load <= i * step) { - if (MODE == "color") { + for (i in bw) { + if (brightness <= i * interval) { + if (COLORS) { printf("%s\n", color[i]) } else { printf("%s\n", bw[i])