addfeature: ermanent toggle of long and short preview; fix backlight and temp; fix audio click interaction
This commit is contained in:
parent
a08b5431a6
commit
b27f490fa6
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.state
|
11
config
11
config
@ -9,14 +9,14 @@ interval=5
|
|||||||
label=☼
|
label=☼
|
||||||
# label=☀,☼,✱,✲,✳,✴,✵,✺
|
# label=☀,☼,✱,✲,✳,✴,✵,✺
|
||||||
signal=3
|
signal=3
|
||||||
instance=long,color
|
instance=color
|
||||||
# instance=color,bw,long
|
# instance=color,bw
|
||||||
|
|
||||||
# [iface]
|
# [iface]
|
||||||
# label=iface
|
# label=iface
|
||||||
|
|
||||||
[storage]
|
# [storage]
|
||||||
label=⛁
|
# label=⛁
|
||||||
# label=⛀,⛁,⛂,⛃
|
# label=⛀,⛁,⛂,⛃
|
||||||
# interval=60
|
# interval=60
|
||||||
|
|
||||||
@ -24,20 +24,17 @@ label=⛁
|
|||||||
# with instance=ram or instance=swap
|
# with instance=ram or instance=swap
|
||||||
[ram]
|
[ram]
|
||||||
label=⚟
|
label=⚟
|
||||||
# instance=long
|
|
||||||
instance=ram
|
instance=ram
|
||||||
# [ram]
|
# [ram]
|
||||||
# instance=swap
|
# instance=swap
|
||||||
|
|
||||||
[cpu]
|
[cpu]
|
||||||
label=☷
|
label=☷
|
||||||
# instance=long
|
|
||||||
interval=2
|
interval=2
|
||||||
|
|
||||||
[temp]
|
[temp]
|
||||||
label=ϑ
|
label=ϑ
|
||||||
interval=2
|
interval=2
|
||||||
# instance=long
|
|
||||||
|
|
||||||
[ip]
|
[ip]
|
||||||
# label=ip
|
# label=ip
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
# click interactions
|
# click interactions
|
||||||
[[ "$BLOCK_INSTANCE" =~ "color" ]] && COLORS=True
|
[[ "$BLOCK_INSTANCE" =~ "color" ]] && COLORS=True
|
||||||
[[ "$BLOCK_INSTANCE" =~ "long" || "$BLOCK_BUTTON" == 1 ]] && LONG=True
|
## toggle long and short preview
|
||||||
|
STATE="${HOME}/.config/i3blocks/modules/${1}.state"
|
||||||
|
if [[ "$BLOCK_BUTTON" == 1 ]]; then
|
||||||
|
if [[ -f "$STATE" ]]; then
|
||||||
|
rm $STATE
|
||||||
|
LONG=false
|
||||||
|
else
|
||||||
|
touch $STATE
|
||||||
|
LONG=true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
[[ -f "$STATE" ]] && LONG=true || LONG=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# global variables
|
# global variables
|
||||||
BAR=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█")
|
BAR=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█")
|
||||||
@ -11,8 +24,9 @@ BW=("#565656" "#6d6d6d" "#848485" "#9c9c9c" "#b1b1b1" "#c7c7c7" "#dcdcdc" "#f5f5
|
|||||||
# get $LOAD, $LONG_TEXT and $SHORT_TEXT
|
# get $LOAD, $LONG_TEXT and $SHORT_TEXT
|
||||||
source $HOME/.config/i3blocks/modules/${1}.sh
|
source $HOME/.config/i3blocks/modules/${1}.sh
|
||||||
|
|
||||||
|
|
||||||
# text
|
# text
|
||||||
if [[ "$LONG" || "$LONG_TEXT" == "off" ]]; then
|
if [[ "$LONG" = true || "$LONG_TEXT" == "off" ]]; then
|
||||||
echo "$LONG_TEXT"
|
echo "$LONG_TEXT"
|
||||||
echo "$SHORT_TEXT"
|
echo "$SHORT_TEXT"
|
||||||
else
|
else
|
||||||
|
@ -11,7 +11,6 @@ if [[ $(amixer get $DEV) =~ \[([0-9]+)\%\][[:space:]]\[(on|off)\] ]]; then
|
|||||||
else
|
else
|
||||||
LONG_TEXT="off"
|
LONG_TEXT="off"
|
||||||
SHORT_TEXT="X"
|
SHORT_TEXT="X"
|
||||||
EXIT=True
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
LONG_TEXT="no audio source"
|
LONG_TEXT="no audio source"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# start firefox
|
# start firefox
|
||||||
[[ "$BLOCK_BUTTON" == 3 ]] && firefox
|
[[ "$BLOCK_BUTTON" == 2 ]] && firefox
|
||||||
|
|
||||||
# get interface
|
# get interface
|
||||||
if [[ -n "$BLOCK_INSTANCE" ]]; then
|
if [[ -n "$BLOCK_INSTANCE" ]]; then
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[[ "$BLOCK_BUTTON" == 2 ]] && i3-sensible-terminal -e ranger
|
[[ "$BLOCK_BUTTON" == 2 ]] && i3-sensible-terminal -e ranger
|
||||||
|
|
||||||
df | gawk -v BAR="${BAR[*]}" -v BW="${BW[*]}" -v COLORS="$COLORS" -v COLOR="${COLOR[*]}" -v LONG="$LONG" '
|
df -l | gawk -v BAR="${BAR[*]}" -v BW="${BW[*]}" -v COLORS="$COLORS" -v COLOR="${COLOR[*]}" -v LONG="$LONG" '
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
split(BAR, bar, / /)
|
split(BAR, bar, / /)
|
||||||
|
@ -1,42 +1,11 @@
|
|||||||
[[ "$BLOCK_BUTTON" == 2 ]] && i3-sensible-terminal -e htop
|
[[ "$BLOCK_BUTTON" == 2 ]] && i3-sensible-terminal -e htop
|
||||||
|
|
||||||
sensors *-isa-* | awk -v BAR="${BAR[*]}" -v BW="${BW[*]}" -v COLORS="$COLORS" -v COLOR="${COLOR[*]}" -v LONG="$LONG" '
|
SENSORS=$(sensors *-isa-*)
|
||||||
|
if [[ $SENSORS =~ Package[^\+]*\+([0-9]{1,3})[^\+]*\+([0-9]{1,3}) ]]; then
|
||||||
BEGIN {
|
TEMP="${BASH_REMATCH[1]}"
|
||||||
split(BAR, bar, / /)
|
HIGH="${BASH_REMATCH[2]}"
|
||||||
split(COLOR, color, / /)
|
TRESHOLD=40
|
||||||
split(BW, bw, / /)
|
LOAD=$((($TEMP - $TRESHOLD) * 100 / ($HIGH - $TRESHOLD)))
|
||||||
interval = 100 / length(bar)
|
LONG_TEXT="$(($LOAD + $TRESHOLD))°C"
|
||||||
}
|
SHORT_TEXT="$((${LOAD} + ${TRESHOLD}))"
|
||||||
|
fi
|
||||||
match($0, /^Package[^\+]*\+([0-9]{1,3})[^\+]*\+([0-9]{1,3})/, matches) {
|
|
||||||
temp = matches[1]
|
|
||||||
high = matches[2]
|
|
||||||
step = high / 8
|
|
||||||
treshold = 40
|
|
||||||
load = (temp - treshold) / (high - treshold) * 100
|
|
||||||
}
|
|
||||||
|
|
||||||
END {
|
|
||||||
if (LONG) {
|
|
||||||
printf("%d°C\n%d°C\n", temp, temp)
|
|
||||||
} 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