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=☀,☼,✱,✲,✳,✴,✵,✺
|
||||
signal=3
|
||||
instance=long,color
|
||||
# instance=color,bw,long
|
||||
instance=color
|
||||
# instance=color,bw
|
||||
|
||||
# [iface]
|
||||
# label=iface
|
||||
|
||||
[storage]
|
||||
label=⛁
|
||||
# [storage]
|
||||
# label=⛁
|
||||
# label=⛀,⛁,⛂,⛃
|
||||
# interval=60
|
||||
|
||||
@ -24,20 +24,17 @@ label=⛁
|
||||
# with instance=ram or instance=swap
|
||||
[ram]
|
||||
label=⚟
|
||||
# instance=long
|
||||
instance=ram
|
||||
# [ram]
|
||||
# instance=swap
|
||||
|
||||
[cpu]
|
||||
label=☷
|
||||
# instance=long
|
||||
interval=2
|
||||
|
||||
[temp]
|
||||
label=ϑ
|
||||
interval=2
|
||||
# instance=long
|
||||
|
||||
[ip]
|
||||
# label=ip
|
||||
|
@ -1,6 +1,19 @@
|
||||
# click interactions
|
||||
[[ "$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
|
||||
BAR=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█")
|
||||
@ -11,8 +24,9 @@ BW=("#565656" "#6d6d6d" "#848485" "#9c9c9c" "#b1b1b1" "#c7c7c7" "#dcdcdc" "#f5f5
|
||||
# get $LOAD, $LONG_TEXT and $SHORT_TEXT
|
||||
source $HOME/.config/i3blocks/modules/${1}.sh
|
||||
|
||||
|
||||
# text
|
||||
if [[ "$LONG" || "$LONG_TEXT" == "off" ]]; then
|
||||
if [[ "$LONG" = true || "$LONG_TEXT" == "off" ]]; then
|
||||
echo "$LONG_TEXT"
|
||||
echo "$SHORT_TEXT"
|
||||
else
|
||||
|
@ -11,7 +11,6 @@ if [[ $(amixer get $DEV) =~ \[([0-9]+)\%\][[:space:]]\[(on|off)\] ]]; then
|
||||
else
|
||||
LONG_TEXT="off"
|
||||
SHORT_TEXT="X"
|
||||
EXIT=True
|
||||
fi
|
||||
else
|
||||
LONG_TEXT="no audio source"
|
||||
|
@ -1,5 +1,5 @@
|
||||
# start firefox
|
||||
[[ "$BLOCK_BUTTON" == 3 ]] && firefox
|
||||
[[ "$BLOCK_BUTTON" == 2 ]] && firefox
|
||||
|
||||
# get interface
|
||||
if [[ -n "$BLOCK_INSTANCE" ]]; then
|
||||
|
@ -1,6 +1,6 @@
|
||||
[[ "$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 {
|
||||
split(BAR, bar, / /)
|
||||
|
@ -1,42 +1,11 @@
|
||||
[[ "$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" '
|
||||
|
||||
BEGIN {
|
||||
split(BAR, bar, / /)
|
||||
split(COLOR, color, / /)
|
||||
split(BW, bw, / /)
|
||||
interval = 100 / length(bar)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
'
|
||||
SENSORS=$(sensors *-isa-*)
|
||||
if [[ $SENSORS =~ Package[^\+]*\+([0-9]{1,3})[^\+]*\+([0-9]{1,3}) ]]; then
|
||||
TEMP="${BASH_REMATCH[1]}"
|
||||
HIGH="${BASH_REMATCH[2]}"
|
||||
TRESHOLD=40
|
||||
LOAD=$((($TEMP - $TRESHOLD) * 100 / ($HIGH - $TRESHOLD)))
|
||||
LONG_TEXT="$(($LOAD + $TRESHOLD))°C"
|
||||
SHORT_TEXT="$((${LOAD} + ${TRESHOLD}))"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user