First commit: Publish project as open source.

This commit is contained in:
Keyitdev
2026-07-28 12:52:19 +02:00
commit cc51c61859
27 changed files with 2995 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
#compdef asus-fan-control-ec
_asus-fan-control-ec() {
local state
local -a commands globals
commands=(
'set:set PWM duty 0-255, or -1 to hand control back to the EC'
'setp:set duty in percent, or -1 for the same release'
'curve:run the fan curve daemon'
'fan-speed:show control mode and fan speeds'
'fan-info:full state plus channel validation'
'temps-info:show both temperatures with their addresses'
'help:show usage'
'version:show model, EC version and project info'
)
globals=(
'--cmd-port[command port]:port:'
'--data-port[data port]:port:'
'--gap[delay after each write, seconds]:seconds:'
'--verbose[trace every port write]'
)
_arguments -C $globals '1: :->command' '*:: :->args'
case $state in
command)
_describe -t commands 'command' commands
;;
args)
case $words[1] in
set|setp)
_arguments $globals \
'--fan[act on one fan only]:index:(0 1)' \
'--retries[write attempts before giving up]:count:' \
'--no-verify[write and exit without reading back]' \
'--order[order of the mode and duty writes]:order:(mode-first duty-first)'
;;
curve)
_arguments $globals \
'--config[curve file]:file:_files' \
'--interval[seconds between ticks]:seconds:' \
'--hysteresis[degrees of resistance to stepping down]:degrees:' \
'--panic-temp[force 100 percent at or above]:degrees:' \
'--sensor[which temperature drives the curve]:sensor:(cpu board max)' \
'--retries[write attempts per change]:count:' \
'--order[order of the mode and duty writes]:order:(mode-first duty-first)' \
'--once[one tick, then exit without releasing]' \
'--dry-run[print the parsed curve and exit]' \
'--silent[suppress the periodic line]'
;;
*)
_arguments $globals
;;
esac
;;
esac
}
_asus-fan-control-ec "$@"
+64
View File
@@ -0,0 +1,64 @@
_asus_fan_control_ec()
{
local cur prev cmd word i skip
local commands="set setp curve fan-speed fan-info temps-info help version"
local globals="--cmd-port --data-port --gap --verbose"
local valued="--cmd-port --data-port --gap --fan --retries --order --config --interval --hysteresis --panic-temp --sensor"
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case "$prev" in
--order)
COMPREPLY=( $(compgen -W "mode-first duty-first" -- "$cur") )
return ;;
--sensor)
COMPREPLY=( $(compgen -W "cpu board max" -- "$cur") )
return ;;
--config)
COMPREPLY=( $(compgen -f -- "$cur") )
return ;;
--fan)
COMPREPLY=( $(compgen -W "0 1" -- "$cur") )
return ;;
--cmd-port|--data-port|--gap|--retries|--interval|--hysteresis|--panic-temp)
return ;;
esac
cmd=""
skip=0
for (( i=1; i < COMP_CWORD; i++ )); do
word="${COMP_WORDS[i]}"
if [ "$skip" = 1 ]; then
skip=0
continue
fi
case " $valued " in
*" $word "*)
skip=1
continue ;;
esac
case " $commands " in
*" $word "*)
cmd="$word"
break ;;
esac
done
if [ -z "$cmd" ]; then
COMPREPLY=( $(compgen -W "$commands $globals" -- "$cur") )
return
fi
case "$cmd" in
set|setp)
COMPREPLY=( $(compgen -W "--fan --retries --no-verify --order $globals" -- "$cur") ) ;;
curve)
COMPREPLY=( $(compgen -W "--config --interval --hysteresis --panic-temp --sensor --retries --order --once --dry-run --silent $globals" -- "$cur") ) ;;
*)
COMPREPLY=( $(compgen -W "$globals" -- "$cur") ) ;;
esac
}
complete -F _asus_fan_control_ec asus-fan-control-ec