added scroll up to increase/scroll down to decrease for waybar fan module
This commit is contained in:
@@ -123,9 +123,12 @@
|
||||
"return-type": "json",
|
||||
"exec": "~/.local/bin/fanstat",
|
||||
"interval": 1,
|
||||
"smooth-scrolling-threshold": 5,
|
||||
"on-scroll-up": "~/.local/bin/fanctl incr",
|
||||
"on-scroll-down": "~/.local/bin/fanctl decr",
|
||||
"on-click": "~/.local/bin/fanctl min",
|
||||
"on-click-right": "~/.local/bin/fanctl max",
|
||||
"on-click-middle": "~/.local/bin/fanctl auto"
|
||||
"on-click-double": "~/.local/bin/fanctl auto"
|
||||
},
|
||||
"custom/quit": {
|
||||
"format": " ",
|
||||
|
||||
+40
-4
@@ -1,4 +1,8 @@
|
||||
#!/bin/bash
|
||||
if [ -f ~/.local/bin/fanctl ]; then
|
||||
# Read the values of text, class, and tooltip
|
||||
source ~/.local/bin/stats/fanstat
|
||||
fi
|
||||
|
||||
# Function to check if a string is an integer
|
||||
is_integer() {
|
||||
@@ -42,10 +46,42 @@ case $1 in
|
||||
tooltip="Auto"
|
||||
class="auto"
|
||||
;;
|
||||
incr)
|
||||
if [[ $tooltipstat != "Auto" ]]; then
|
||||
new_tooltipstat="${tooltipstat%?}"
|
||||
new_speed=$(( $new_tooltipstat + 10))
|
||||
if [[ $new_speed -lt 100 ]]; then
|
||||
nbfc set -f 0 1 -s $new_speed
|
||||
text="custom"
|
||||
tooltip="$new_speed%"
|
||||
class="custom"
|
||||
else
|
||||
text=$textstat
|
||||
tooltip="$tooltipstat"
|
||||
class=$classstat
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
decr)
|
||||
if [[ $tooltipstat != "Auto" ]]; then
|
||||
new_tooltipstat="${tooltipstat%?}"
|
||||
new_speed=$(( $new_tooltipstat - 10))
|
||||
if [[ $new_speed -gt 0 ]]; then
|
||||
nbfc set -f 0 1 -s $new_speed
|
||||
text="custom"
|
||||
tooltip="$new_speed%"
|
||||
class="custom"
|
||||
else
|
||||
text=$textstat
|
||||
tooltip="$tooltipstat"
|
||||
class=$classstat
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if is_integer "$1"; then # Check if argument is an integer
|
||||
nbfc set -f 0 1 -s "$1" # Execute nbfc with the provided integer value
|
||||
text="$1"
|
||||
text="custom"
|
||||
tooltip="$1%"
|
||||
class="custom"
|
||||
else
|
||||
@@ -56,7 +92,7 @@ case $1 in
|
||||
esac
|
||||
|
||||
# Output text, tooltip, and class to statfile
|
||||
echo "text=$text" > ~/.local/bin/stats/fanstat
|
||||
echo "tooltip=$(waybar_tooltip "$tooltip")" >> ~/.local/bin/stats/fanstat
|
||||
echo "class=$class" >> ~/.local/bin/stats/fanstat
|
||||
echo "textstat=$text" > ~/.local/bin/stats/fanstat
|
||||
echo "tooltipstat=$(waybar_tooltip "$tooltip")" >> ~/.local/bin/stats/fanstat
|
||||
echo "classstat=$class" >> ~/.local/bin/stats/fanstat
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ if [ -f ~/.local/bin/fanctl ]; then
|
||||
source ~/.local/bin/stats/fanstat
|
||||
|
||||
# Output the values in JSON format using printf
|
||||
printf '{"text": "%s", "tooltip": "%s", "class": "%s"}\n' "$text" "$tooltip" "$class"
|
||||
printf '{"text": "%s", "tooltip": "%s", "class": "%s"}\n' "$textstat" "$tooltipstat" "$classstat"
|
||||
else
|
||||
echo "{\"error\": \"File not found\"}"
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
text=min
|
||||
tooltip=30%
|
||||
class=min
|
||||
textstat=min
|
||||
tooltipstat=30%
|
||||
classstat=min
|
||||
|
||||
Reference in New Issue
Block a user