From 1a59351a8706c1a5d119dc1ce1670482305820b8 Mon Sep 17 00:00:00 2001 From: koksnuss Date: Tue, 14 Aug 2018 22:21:21 +0200 Subject: [PATCH] fix audio; add reverse color support --- config | 9 ++------- modules/abstract.sh | 21 +++++++++++++++------ modules/battery.sh | 1 + 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/config b/config index d3b568e..96e88e5 100644 --- a/config +++ b/config @@ -9,10 +9,8 @@ interval=5 label=☼ # label=☀,☼,✱,✲,✳,✴,✵,✺ signal=3 -# instance=color # [iface] -# label=iface # [storage] # label=⛁ @@ -36,7 +34,6 @@ label=ϑ interval=2 [ip] -# label=ip label=⎋ interval=once @@ -45,18 +42,16 @@ interval=once # /sys/class/power_supply/BATx you can use the instance=x command [battery] label=~ -# label=battery -# ⟠, ⟰, ⟱, ⟲, ⟳, ⤋, ⤊,⎋,⚡,⌨,⌨ +# label=⟠, ⟰, ⟱, ⟲, ⟳, ⤋, ⤊,⎋,⚡,⌨,⌨ +interval=60 # [battery] # instance=1 -interval=60 [audio] label=◍ # label=♩,♪,♫,♬ signal=1 interval=once -# instance=color # separator_block_width=0 [audio] label=◎ diff --git a/modules/abstract.sh b/modules/abstract.sh index 33c9ad4..1383651 100755 --- a/modules/abstract.sh +++ b/modules/abstract.sh @@ -32,7 +32,7 @@ else [[ -f "$COLORS" ]] && COLORS=true || COLORS=false fi -# get $LOAD, $LONG_TEXT and $SHORT_TEXT +# get $LOAD, $LOAD_REVERSE, $LONG_TEXT and $SHORT_TEXT source $HOME/.config/i3blocks/modules/${1}.sh # print text @@ -53,8 +53,17 @@ else fi # print colors or black/white -for i in "${!BW[@]}"; do - if [[ $LOAD -lt $((($i+1) * $INTERVAL)) ]]; then - [[ "$COLORS" = true ]] && echo "${COLOR[$i]}" || echo "${BW[$i]}" - fi -done +if [[ "$LOAD" = false ]]; then + echo "${BW[4]}" +else + for i in "${!BW[@]}"; do + if [[ $LOAD -lt $((($i+1) * $INTERVAL)) ]]; then + if [[ "$REVERSE_COLOR" = true ]]; then + u=$((${#BW[@]}-$i)) + [[ "$COLORS" = true ]] && echo "${COLOR[$u]}" || echo "${BW[$u]}" + else + [[ "$COLORS" = true ]] && echo "${COLOR[$i]}" || echo "${BW[$i]}" + fi + fi + done +fi diff --git a/modules/battery.sh b/modules/battery.sh index 5b570b4..eb8feb9 100644 --- a/modules/battery.sh +++ b/modules/battery.sh @@ -18,5 +18,6 @@ while read -r LINE; do done <<< $(cat $BATS) LOAD=$((${ENERGY_NOW} * 100 / ${ENERGY_FULL})) +REVERSE_COLOR=true LONG_TEXT="$STATUS$LOAD%" SHORT_TEXT="$STATUS$LOAD"