You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
53 lines
1.1 KiB
6 years ago
|
#!/usr/bin/env bash
|
||
|
set -o errexit
|
||
6 years ago
|
set -o pipefail
|
||
6 years ago
|
|
||
|
main() {
|
||
6 years ago
|
if [[ -f "${1}" ]]; then
|
||
|
exec 1>"${1}"
|
||
6 years ago
|
shift
|
||
6 years ago
|
fi
|
||
|
|
||
6 years ago
|
if [[ -f /etc/default/thinkfan-confgen ]]; then
|
||
|
source /etc/default/thinkfan-confgen
|
||
|
fi
|
||
|
|
||
6 years ago
|
: "${THINKFAN_LOWER_BOUND:=30}"
|
||
|
: "${THINKFAN_STEP:=4}"
|
||
|
|
||
|
printf '# thinkfan-confgen created %s\n' "$(date -u)"
|
||
|
printf '# THINKFAN_LOWER_BOUND=%s\n' "${THINKFAN_LOWER_BOUND}"
|
||
|
printf '# THINKFAN_STEP=%s\n\n' "${THINKFAN_STEP}"
|
||
6 years ago
|
|
||
6 years ago
|
find /sys -type f -name 'temp*_input' | while read -r line; do
|
||
5 years ago
|
if [[ "${line}" =~ thinkpad_hwmon ]]; then
|
||
|
continue
|
||
|
fi
|
||
6 years ago
|
printf 'hwmon %s\n' "${line}"
|
||
|
done
|
||
|
|
||
|
printf '\ntp_fan /proc/acpi/ibm/fan\n\n'
|
||
|
|
||
|
local halfstep="$((THINKFAN_STEP / 2))"
|
||
|
local cur="${THINKFAN_LOWER_BOUND}"
|
||
|
|
||
|
for level in 0 1 2 3 4 5 6 7; do
|
||
|
if [[ "${level}" == 0 ]]; then
|
||
|
printf '(0, 0, %s)\n' "${cur}"
|
||
|
continue
|
||
|
fi
|
||
|
|
||
|
if [[ "${level}" == 7 ]]; then
|
||
|
printf '(7, %s, 32767)\n' "$((cur - halfstep))"
|
||
|
continue
|
||
|
fi
|
||
|
|
||
|
printf '(%s, %s, %s)\n' \
|
||
|
"${level}" "$((cur - halfstep))" "$((cur + THINKFAN_STEP))"
|
||
|
|
||
|
cur="$((cur + THINKFAN_STEP))"
|
||
6 years ago
|
done
|
||
|
}
|
||
|
|
||
|
main "${@}"
|