This commit is contained in:
koksnuss 2018-08-14 01:01:20 +02:00
parent c6681e4cd2
commit fcfd1eb70c
2 changed files with 15 additions and 23 deletions

11
config
View File

@ -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

View File

@ -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]}"