arc-addons/sensors/all/usr/bin/arc-sensors.sh
AuxXxilium 0c9b4f1d9b tree: update
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
2024-11-20 11:00:55 +01:00

73 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
if ! command -v perl &>/dev/null; then
echo "install Perl ..."
synopkg install_from_server Perl
fi
if ! command -v perl &>/dev/null; then
echo "Perl not found"
exit 1
fi
modprobe -q hwmon-vid
modprobe -q it87
modprobe -q adt7470
modprobe -q adt7475
modprobe -q nct6683
modprobe -q nct6775
modprobe -q coretemp
modprobe -q k10temp
echo 'Y' | sensors-detect --auto >"/tmp/sensors.log"
grep -oE 'Driver\s*:\s*\w+' "/tmp/sensors.log" | awk -F': ' '{print $2}'
sensors
echo "$@" | grep -qw "\-f" && rm -f /etc/fancontrol
if [ ! -f /etc/fancontrol ]; then
# Or use pwmconfig to generate /etc/fancontrol interactively.
local DEVPATH DEVNAME FCTEMPS FCFANS MINTEMP MAXTEMP MINSTART MINSTOP
local CORETEMP="$(find "/sys/devices/platform/" -name "temp1_input" | grep -E 'coretemp|k10temp' | sed -n -e 's|.*/\(hwmon.*\/temp1_input\).*|\1|p')"
for P in $(find "/sys/devices/platform/" -name "temp1_input"); do
D="$(echo "${P}" | sed -n -e 's|.*/\(devices/platform/[^/]*\)/.*|\1|p')"
I="$(echo "${P}" | sed -n -e 's|.*hwmon\([0-9]\).*|\1|p')"
DEVPATH="${DEVPATH} hwmon${I}=${D}"
DEVNAME="${DEVNAME} hwmon${I}=$(cat /sys/${D}/*/*/name)"
for F in $(find "/sys/${D}" -name "fan[0-9]_input"); do
local IDX="$(echo "${F}" | sed -n -e 's|.*fan\([0-9]\)_input|\1|p')"
FCTEMPS="${FCTEMPS} hwmon${I}/pwm${IDX}=${CORETEMP}"
FCFANS="${FCFANS} hwmon${I}/pwm${IDX}=hwmon${I}/fan${IDX}_input"
MINTEMP="${MINTEMP} hwmon${I}/pwm${IDX}=30"
MAXTEMP="${MAXTEMP} hwmon${I}/pwm${IDX}=70"
MINSTART="${MINSTART} hwmon${I}/pwm${IDX}=150"
MINSTOP="${MINSTOP} hwmon${I}/pwm${IDX}=50"
done
i=$((i + 1))
done
DEST="/etc/fancontrol"
{
echo "# Configuration file generated by pwmconfig, changes will be lost"
echo "INTERVAL=10"
echo "DEVPATH=$(echo ${DEVPATH})"
echo "DEVNAME=$(echo ${DEVNAME})"
echo "FCTEMPS=$(echo ${FCTEMPS})"
echo "FCFANS=$(echo ${FCFANS})"
echo "MINTEMP=$(echo ${MINTEMP})"
echo "MAXTEMP=$(echo ${MAXTEMP})"
echo "MINSTART=$(echo ${MINSTART})"
echo "MINSTOP=$(echo ${MINSTOP})"
} >"${DEST}"
fi
killall fancontrol
fancontrol &
exit 0