From 647ec8656fc37e05f955729b61582c394e99de40 Mon Sep 17 00:00:00 2001 From: koksnuss Date: Sun, 19 Aug 2018 19:43:21 +0200 Subject: [PATCH] fix reverse color mode and break after the interesting output has been printed --- modules/abstract.sh | 13 +++++++++++-- modules/ip.sh | 1 - 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/abstract.sh b/modules/abstract.sh index 1383651..57e93fd 100755 --- a/modules/abstract.sh +++ b/modules/abstract.sh @@ -32,6 +32,14 @@ else [[ -f "$COLORS" ]] && COLORS=true || COLORS=false fi +# variables to define +# LOAD -- The percentage of something provided like LOAD=67 which meas 76% +# LONG_TEXT -- Text to display in case LONG=True +# SHORT_TEXT -- Text to display in case LONG=True and the i3 status bar +# runs out of space +# REVERSE_COLOR -- Set this to True if the colors should be selected in +# reverse orer for a given load +# # get $LOAD, $LOAD_REVERSE, $LONG_TEXT and $SHORT_TEXT source $HOME/.config/i3blocks/modules/${1}.sh @@ -52,18 +60,19 @@ else done fi -# print colors or black/white +# print font color 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)) + u=$((${#BW[@]}-$i-1)) [[ "$COLORS" = true ]] && echo "${COLOR[$u]}" || echo "${BW[$u]}" else [[ "$COLORS" = true ]] && echo "${COLOR[$i]}" || echo "${BW[$i]}" fi + break fi done fi diff --git a/modules/ip.sh b/modules/ip.sh index 67ffb7c..da8b622 100644 --- a/modules/ip.sh +++ b/modules/ip.sh @@ -7,7 +7,6 @@ else IF=$(ip route | awk '/^default/ { print $5 ; exit }') fi -# check if network interface exists or is empty if [[ -z "$IF" || ! -d "/sys/class/net/$IF" ]]; then printf "$IF not found\nn/a\n" exit 33