From fcfd1eb70c9eb351f53bf1c5cf569d5c565c09b3 Mon Sep 17 00:00:00 2001 From: koksnuss Date: Tue, 14 Aug 2018 01:01:20 +0200 Subject: [PATCH] cleanup --- config | 11 ++--------- modules/abstract.sh | 27 +++++++++++++-------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/config b/config index 2d36f75..d3b568e 100644 --- a/config +++ b/config @@ -40,20 +40,13 @@ interval=2 label=⎋ interval=once -# if you have more than one batteries attached to your device and ou like +# if you have more than one batteries attached to your device and you like # to see the single state of BATx where x is the number of your battery in # /sys/class/power_supply/BATx you can use the instance=x command [battery] label=~ # label=battery -# █ -# ▉ -# ▊ -# ▋ -# ▌ -# ▍⎋⚡ -# ▎⌨⌨ -# ▏⟠, ⟰, ⟱, ⟲, ⟳, ⤋, ⤊ +# ⟠, ⟰, ⟱, ⟲, ⟳, ⤋, ⤊,⎋,⚡,⌨,⌨ # [battery] # instance=1 interval=60 diff --git a/modules/abstract.sh b/modules/abstract.sh index 04c44f9..33c9ad4 100755 --- a/modules/abstract.sh +++ b/modules/abstract.sh @@ -1,5 +1,10 @@ -# click interactions -## toggle long and short preview +BARV=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█") +BARH=("▏" "▎" "▍" "▌" "▋" "▊" "▉" "█") +INTERVAL=$((100 / ${#BARV[@]})) +COLOR=("#64bc01" "#77a601" "#8a9101" "#9d7b00" "#b06701" "#c45100" "#d63c00" "#e92700") +BW=("#565656" "#6d6d6d" "#848485" "#9c9c9c" "#b1b1b1" "#c7c7c7" "#dcdcdc" "#f5f5f6") + +# toggle long and short preview STATE="${HOME}/.config/i3blocks/modules/${1}-${BLOCK_INSTANCE}.long" COLORS="${HOME}/.config/i3blocks/modules/${1}-${BLOCK_INSTANCE}.color" if [[ "$BLOCK_BUTTON" == 1 ]]; then @@ -14,7 +19,7 @@ else [[ -f "$STATE" ]] && LONG=true || LONG=false fi -## toggle color and black/white mode +# toggle color and black/white mode if [[ "$BLOCK_BUTTON" == 3 ]]; then if [[ -f "$COLORS" ]]; then rm $COLORS @@ -27,16 +32,10 @@ else [[ -f "$COLORS" ]] && COLORS=true || COLORS=false fi -# global variables -BAR=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█") -INTERVAL=$((100 / ${#BAR[@]})) -COLOR=("#64bc01" "#77a601" "#8a9101" "#9d7b00" "#b06701" "#c45100" "#d63c00" "#e92700") -BW=("#565656" "#6d6d6d" "#848485" "#9c9c9c" "#b1b1b1" "#c7c7c7" "#dcdcdc" "#f5f5f6") - # get $LOAD, $LONG_TEXT and $SHORT_TEXT source $HOME/.config/i3blocks/modules/${1}.sh -# text +# print text if [[ "$LOAD" = false && "$LONG" = false ]]; then echo $SHORT_TEXT echo $SHORT_TEXT @@ -44,16 +43,16 @@ elif [[ "$LONG" = true || $LONG_TEXT =~ off ]]; then echo "$LONG_TEXT" echo "$SHORT_TEXT" else - for i in "${!BAR[@]}"; do + for i in "${!BARV[@]}"; do if [[ "$LOAD" -lt $((($i+1) * $INTERVAL)) ]]; then - echo "${BAR[$i]}" - echo "${BAR[$i]}" + echo "${BARV[$i]}" + echo "${BARV[$i]}" break fi done fi -# colors +# 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]}"