LS-WVL Debian 安裝後選項

Triggerhappy 按鈕 

 apt install triggerhappy 

 監聽按鈕 

 thd --dump /dev/input/event* 

 建立關機功能 

 echo "SW_LID 0 poweroff" > /etc/triggerhappy/triggers.d/gpf.conf 

 修改 /lib/systemd/system/triggerhappy.service ，把ExecStart user的nobody改成root，不然無權限執行poweroff 

 ExecStart=/usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --socket /run/thd.socket --user root --deviceglob /dev/input/event* 

 重啟加載配置 

 systemctl daemon-reload

systemctl restart triggerhappy 

 即可按鈕實現關機 

 

 風扇控制 

 風扇狀態 /sys/class/thermal/cooling_device0/cur_state 

 CPU溫度 /sys/class/thermal/thermal_zone0/temp 

 安裝 smartmontools 

 apt install smartmontools 

 硬碟溫度 /usr/sbin/smartctl -a -d ata /dev/sda | grep -m 1 Temperature | awk '{print $10}' 

 風扇自動化腳本 

 #!/bin/bash

timestamp=$(date "+%Y-%m-%d %H:%M:%S")

# CPU溫度

cpu_temp=$(< /sys/class/thermal/thermal_zone0/temp)

cpu_temp=$(( cpu_temp / 1000 ))

# 硬碟溫度

hdd_temp=$(/usr/sbin/smartctl -a -d ata /dev/sda | grep -m 1 Temperature | awk '{print $10}')

echo "[$timestamp] CPU Temperature: ${cpu_temp}C"

echo "[$timestamp] HDD Temperature: ${hdd_temp}C"

# cpu偵測

if [ "$cpu_temp" -gt 60 ]; then

 echo 0 > /sys/class/thermal/cooling_device0/cur_state

elif [ "$cpu_temp" -gt 55 ]; then

 echo 1 > /sys/class/thermal/cooling_device0/cur_state

elif [ "$cpu_temp" -gt 50 ]; then

 echo 2 > /sys/class/thermal/cooling_device0/cur_state

elif [ "$cpu_temp" -lt 50 ]; then

 echo 3 > /sys/class/thermal/cooling_device0/cur_state

fi

# HDD溫度偵測

if [ "$hdd_temp" -gt 45 ]; then

 echo 0 > /sys/class/thermal/cooling_device0/cur_state

elif [ "$hdd_temp" -gt 40 ]; then

 echo 1 > /sys/class/thermal/cooling_device0/cur_state

elif [ "$hdd_temp" -gt 35 ]; then

 echo 2 > /sys/class/thermal/cooling_device0/cur_state

elif [ "$hdd_temp" -lt 35 ]; then

 echo 3 > /sys/class/thermal/cooling_device0/cur_state

fi

# 風扇狀態偵測

fan_state=$(< /sys/class/thermal/cooling_device0/cur_state)

echo "[$timestamp] FAN_State : ${fan_state}" 

 root@LS-WVL885:~# bash temp.sh 

[2025-08-23 11:47:00] CPU Temperature: 55C

[2025-08-23 11:47:00] HDD Temperature: 37C

[2025-08-23 11:47:00] FAN_State : 2

#狀態

0 高速

1 中速

2 低速

3 停止 

 使用CRONTAB每分鐘執行腳本並寫入LOG 

 * * * * * /bin/bash /root/temp.sh >> /root/temp.log 2>&1 

   

 LED控制 

 關閉LED藍燈 echo 0 > /sys/class/leds/linkstation\:blue\:power/brightness 

 開啟LED藍燈 echo 1 > /sys/class/leds/linkstation\:blue\:power/brightness