begin big refr
This commit is contained in:
parent
1caaa498b9
commit
8b7f7e1498
2
config
2
config
@ -9,7 +9,7 @@ interval=5
|
|||||||
label=☼
|
label=☼
|
||||||
# label=☀,☼,✱,✲,✳,✴,✵,✺
|
# label=☀,☼,✱,✲,✳,✴,✵,✺
|
||||||
signal=3
|
signal=3
|
||||||
instance=long
|
instance=long,color
|
||||||
# instance=color,bw,long
|
# instance=color,bw,long
|
||||||
|
|
||||||
# [iface]
|
# [iface]
|
||||||
|
@ -2,9 +2,29 @@
|
|||||||
[[ "$BLOCK_INSTANCE" =~ "long" || "$BLOCK_BUTTON" == 1 ]] && LONG=True
|
[[ "$BLOCK_INSTANCE" =~ "long" || "$BLOCK_BUTTON" == 1 ]] && LONG=True
|
||||||
|
|
||||||
BAR=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█")
|
BAR=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█")
|
||||||
|
INTERVAL=$((100 / ${#BAR[@]}))
|
||||||
COLOR=("#64bc01" "#77a601" "#8a9101" "#9d7b00" "#b06701" "#c45100" "#d63c00" "#e92700")
|
COLOR=("#64bc01" "#77a601" "#8a9101" "#9d7b00" "#b06701" "#c45100" "#d63c00" "#e92700")
|
||||||
BW=("#565656" "#6d6d6d" "#848485" "#9c9c9c" "#b1b1b1" "#c7c7c7" "#dcdcdc" "#f5f5f6")
|
BW=("#565656" "#6d6d6d" "#848485" "#9c9c9c" "#b1b1b1" "#c7c7c7" "#dcdcdc" "#f5f5f6")
|
||||||
|
|
||||||
source $HOME/.config/i3blocks/modules/${1}.sh
|
source $HOME/.config/i3blocks/modules/${1}.sh
|
||||||
|
|
||||||
|
# text
|
||||||
|
if [[ "$LONG" ]]; then
|
||||||
|
echo "$LONG_TEXT"
|
||||||
|
echo "$SHORT_TEXT"
|
||||||
|
else
|
||||||
|
for i in "${!BAR[@]}"; do
|
||||||
|
if [[ "$LOAD" -lt $((($i+1) * $INTERVAL)) ]]; then
|
||||||
|
echo "${BAR[$i]}"
|
||||||
|
echo "${BAR[$i]}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# colors
|
||||||
|
for i in "${!BW[@]}"; do
|
||||||
|
if [[ $LOAD -lt $((($i+1) * $INTERVAL)) ]]; then
|
||||||
|
[[ $COLORS ]] && echo "${COLOR[$i]}" || echo "${BW[$i]}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
@ -7,40 +7,9 @@ else
|
|||||||
printf "no backlight\nn/a\n"
|
printf "no backlight\nn/a\n"
|
||||||
exit 33
|
exit 33
|
||||||
fi
|
fi
|
||||||
|
CURRENT_BRIGHTNESS=$(cat "$DIR/brightness")
|
||||||
|
MAXIMUM_BRIGHTNESS=$(cat "$DIR/max_brightness")
|
||||||
|
|
||||||
cat "$DIR/brightness" "$DIR/max_brightness" | gawk -v BAR="${BAR[*]}" -v BW="${BW[*]}" -v COLORS="$COLORS" -v COLOR="${COLOR[*]}" -v LONG="$LONG" '
|
LOAD=$((CURRENT_BRIGHTNESS * 100 / MAXIMUM_BRIGHTNESS))
|
||||||
|
LONG_TEXT="${LOAD}%"
|
||||||
BEGIN {
|
SHORT_TEXT="${LOAD}"
|
||||||
split(BAR, bar, / /)
|
|
||||||
split(COLOR, color, / /)
|
|
||||||
split(BW, bw, / /)
|
|
||||||
interval = 100 / length(bar)
|
|
||||||
}
|
|
||||||
|
|
||||||
NR == 1 { current_brightness = $1 }
|
|
||||||
NR == 2 { maximum_brightness = $1 }
|
|
||||||
|
|
||||||
END {
|
|
||||||
load = ( current_brightness / maximum_brightness ) * 100
|
|
||||||
if (LONG) {
|
|
||||||
printf("%d%\n%d\n", load, load)
|
|
||||||
} else {
|
|
||||||
for (i in bar) {
|
|
||||||
if (load <= i * interval) {
|
|
||||||
printf("%s\n%s\n", bar[i], bar[i])
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i in bw) {
|
|
||||||
if (load <= i * interval) {
|
|
||||||
if (COLORS) {
|
|
||||||
printf("%s\n", color[i])
|
|
||||||
} else {
|
|
||||||
printf("%s\n", bw[i])
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'
|
|
||||||
|
Reference in New Issue
Block a user