Skip to content

Commit

Permalink
add suspend hooks to stop fans on sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
emrebicer committed Oct 22, 2022
1 parent e701d44 commit 3fbe39d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"strategyOnDischarging" : "",
"batteryChargingStatusPath" : "",
"strategies": {
"sleep": {
"fanSpeedUpdateFrequency": 5,
"movingAverageInterval": 40,
"speedCurve": [
{ "temp": 0, "speed": 0 }
]
},
"lazyest": {
"fanSpeedUpdateFrequency": 5,
"movingAverageInterval": 40,
Expand Down
4 changes: 4 additions & 0 deletions fanctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def strategyLiveUpdate(self):
strategy = fp.read()
fp.seek(0)
fp.truncate

if strategy == "defaultStrategy":
strategy = self.config["defaultStrategy"]

if strategy in self.config["strategies"]:
self.setStrategy(self.config["strategies"][strategy])
else:
Expand Down
20 changes: 19 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if [ "$1" = "remove" ]; then
ectool --interface=lpc autofanctrl # restore default fan manager
rm /usr/local/bin/ectool
rm -rf /home/$(logname)/.config/fw-fanctrl
rm /usr/lib/systemd/system-sleep/fw-fanctrl-suspend

echo "fw-fanctrl has been removed successfully from system"
elif [ -z $1 ]; then
Expand Down Expand Up @@ -56,6 +57,23 @@ ExecStart=/usr/bin/python3 /usr/local/bin/fw-fanctrl --config /home/$(logname)/.
WantedBy=multi-user.target
EOF

# create suspend hooks
echo "Creating suspend hooks"

sudo cat > /lib/systemd/system-sleep/fw-fanctrl-suspend << EOF
#!/bin/sh
case \$1 in
pre) runuser -l $(logname) -c "fw-fanctrl sleep" ;;
post) runuser -l $(logname) -c "fw-fanctrl defaultStrategy" ;;
esac
EOF

# make the suspend hook executable
sudo chmod +x /lib/systemd/system-sleep/fw-fanctrl-suspend

# restart daemon, enable and start service
echo "Reloading daemon and enabling service"
sudo systemctl daemon-reload
Expand All @@ -67,4 +85,4 @@ else
echo "Unknown command $1"
exit
fi
exit 0
exit 0

0 comments on commit 3fbe39d

Please sign in to comment.