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",
|
"return-type": "json",
|
||||||
"exec": "~/.local/bin/fanstat",
|
"exec": "~/.local/bin/fanstat",
|
||||||
"interval": 1,
|
"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": "~/.local/bin/fanctl min",
|
||||||
"on-click-right": "~/.local/bin/fanctl max",
|
"on-click-right": "~/.local/bin/fanctl max",
|
||||||
"on-click-middle": "~/.local/bin/fanctl auto"
|
"on-click-double": "~/.local/bin/fanctl auto"
|
||||||
},
|
},
|
||||||
"custom/quit": {
|
"custom/quit": {
|
||||||
"format": " ",
|
"format": " ",
|
||||||
|
|||||||
+40
-4
@@ -1,4 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/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
|
# Function to check if a string is an integer
|
||||||
is_integer() {
|
is_integer() {
|
||||||
@@ -42,10 +46,42 @@ case $1 in
|
|||||||
tooltip="Auto"
|
tooltip="Auto"
|
||||||
class="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
|
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
|
nbfc set -f 0 1 -s "$1" # Execute nbfc with the provided integer value
|
||||||
text="$1"
|
text="custom"
|
||||||
tooltip="$1%"
|
tooltip="$1%"
|
||||||
class="custom"
|
class="custom"
|
||||||
else
|
else
|
||||||
@@ -56,7 +92,7 @@ case $1 in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Output text, tooltip, and class to statfile
|
# Output text, tooltip, and class to statfile
|
||||||
echo "text=$text" > ~/.local/bin/stats/fanstat
|
echo "textstat=$text" > ~/.local/bin/stats/fanstat
|
||||||
echo "tooltip=$(waybar_tooltip "$tooltip")" >> ~/.local/bin/stats/fanstat
|
echo "tooltipstat=$(waybar_tooltip "$tooltip")" >> ~/.local/bin/stats/fanstat
|
||||||
echo "class=$class" >> ~/.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
|
source ~/.local/bin/stats/fanstat
|
||||||
|
|
||||||
# Output the values in JSON format using printf
|
# 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
|
else
|
||||||
echo "{\"error\": \"File not found\"}"
|
echo "{\"error\": \"File not found\"}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
text=min
|
textstat=min
|
||||||
tooltip=30%
|
tooltipstat=30%
|
||||||
class=min
|
classstat=min
|
||||||
|
|||||||
Reference in New Issue
Block a user