You are not logged in.

#1 2015-01-31 20:22:28

Greenify
Member
Registered: 2015-01-31
Posts: 4

Location custom startup/resume script

I tried to figure it out using the search function but i couldnt get the answer i was looking for. After following the wiki and installing everything i needed to control my fan speed and so on, my fan keeps spinning very fast. I read many threads and the only thing that seemed to be working was forcing my fans with the code below. Now i used the search alot but i couldnt figure out how to add the code so it will run at boot and after resume from suspending. Is there anyone who can tell me how i can fix this?

# echo 0 > /sys/class/thermal/cooling_device3/cur_state
# echo 0 > /sys/class/thermal/cooling_device4/cur_state
# echo 0 > /sys/class/thermal/cooling_device5/cur_state
# echo 0 > /sys/class/thermal/cooling_device6/cur_state

/Edit: Typo.

Last edited by Greenify (2015-01-31 20:23:12)

Offline

#2 2015-01-31 21:34:11

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: Location custom startup/resume script

That might be what you're looking for: (it's well hidden, search for "rc.local" on that page)
https://wiki.archlinux.org/index.php/systemd
(it's well hidden, search for "rc.local" on that page)

You can write one of those systemd target things... or use ystemd-tmpfiles (if it works in your case)... or if it doesn't (this might be the best solution):

wiki wrote:

check whether the module has a parameter for the option you want to set with modinfo module and set this option with a config file in /etc/modprobe.d. Otherwise you will have to write a udev rule to set the appropriate attribute as soon as the device appears.

Offline

#3 2015-02-01 11:44:34

Greenify
Member
Registered: 2015-01-31
Posts: 4

Re: Location custom startup/resume script

I followed your advice and tried a few things to get it working. After i tried a few things more and found the following:

I did the following:

/usr/lib/systemd/system-sleep/fancontrol.sh

#!/bin/sh
case $1/$2 in
  pre/*)
    echo "Going to $2..."
    ;;
  post/*)
    echo "Waking up from $2..."
    echo 0 > /sys/class/thermal/cooling_device0/cur_state
    echo 0 > /sys/class/thermal/cooling_device1/cur_state
    echo 0 > /sys/class/thermal/cooling_device2/cur_state
    echo 0 > /sys/class/thermal/cooling_device3/cur_state
    echo 0 > /sys/class/thermal/cooling_device4/cur_state
    echo 0 > /sys/class/thermal/cooling_device5/cur_state
    echo 0 > /sys/class/thermal/cooling_device6/cur_state
    echo 0 > /sys/class/thermal/cooling_device7/cur_state
    echo 0 > /sys/class/thermal/cooling_device8/cur_state
    echo 0 > /sys/class/thermal/cooling_device9/cur_state
    echo 0 > /sys/class/thermal/cooling_device10/cur_state
    echo 0 > /sys/class/thermal/cooling_device11/cur_state
    echo 0 > /sys/class/thermal/cooling_device12/cur_state
    echo 0 > /sys/class/thermal/cooling_device13/cur_state
    ;;
esac

Now it is working when i resume from suspending. I dont know if it is the way to get it working, but it works. If it issnt, please give me a little bit of advice where i should put it. I will try and figure out how i can get it working on boot also and i will post my findings here.

Offline

#4 2015-02-02 07:53:47

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: Location custom startup/resume script

If you only need that on resume (not normal boot), that should be the right method.

Not sure if it's the right place though - I think you might not be supposed to change (/add) anything directly in /usr/lib/systemd and instead maybe copy it to /etc/systemd (?)... but I'm not sure if that applies to scripts like that, or might be confusing it with stuff in /usr/share -.-

*sigh* Well, I haven't really gotten around to figuring out systemd myself yet...  since your solution works, you can probably just keep it that way - just don't forget where you put that thing and why it might stop working (/ start making trouble) after some update (/a system migration / whatever changes) in the far future - so you're not totally lost when (/if) it happens (because that's a huge timewaster - I have to know it, I always put files in random places and forget about them until stuff breaks wink ).

Last edited by whoops (2015-02-02 07:56:48)

Offline

#5 2015-02-02 12:50:11

Greenify
Member
Registered: 2015-01-31
Posts: 4

Re: Location custom startup/resume script

whoops wrote:

If you only need that on resume (not normal boot), that should be the right method.

Eventually i want this to run on boot also, but im still searching how i must get it to work.

whoops wrote:

Not sure if it's the right place though - I think you might not be supposed to change (/add) anything directly in /usr/lib/systemd and instead maybe copy it to /etc/systemd (?)... but I'm not sure if that applies to scripts like that, or might be confusing it with stuff in /usr/share -.-

You got a good point there, ill look it up this week and post my findings here.

whoops wrote:

*sigh* Well, I haven't really gotten around to figuring out systemd myself yet...  since your solution works, you can probably just keep it that way - just don't forget where you put that thing and why it might stop working (/ start making trouble) after some update (/a system migration / whatever changes) in the far future - so you're not totally lost when (/if) it happens (because that's a huge timewaster - I have to know it, I always put files in random places and forget about them until stuff breaks wink ).

Lol big_smile. Ill create a document and ill put all my changes in there so it is easy to troubleshoot any problems then. Thanks again for your advice!

Offline

#6 2015-02-02 19:56:09

snakeroot
Member
Registered: 2012-10-06
Posts: 164

Re: Location custom startup/resume script

Greenify wrote:

Eventually i want this to run on boot also, but im still searching how i must get it to work.

The detail you need is in man 5 tmpfiles.d

Try creating a file named fan.conf in /etc/tmpfiles.d

Then edit it to add the following line:

w /sys/class/thermal/cooling_device*/cur_state - - - - "0"

This assumes you are trying to write to every single cooling_devicex file. If not, you'll need to modify the blob in the path.

Obviously, I'm not passing on the wisdom of shutting off any or all of your fans. It's your system: you break it you keep all the pieces.

Offline

#7 2015-02-02 20:16:47

nstgc
Member
Registered: 2014-03-17
Posts: 393

Re: Location custom startup/resume script

I have to do something like this for bcache at boot. I use tmpfiles.d and it works great.

Offline

#8 2015-02-02 22:16:47

Greenify
Member
Registered: 2015-01-31
Posts: 4

Re: Location custom startup/resume script

snakeroot wrote:
Greenify wrote:

Eventually i want this to run on boot also, but im still searching how i must get it to work.

The detail you need is in man 5 tmpfiles.d

Try creating a file named fan.conf in /etc/tmpfiles.d

Then edit it to add the following line:

w /sys/class/thermal/cooling_device*/cur_state - - - - "0"

This assumes you are trying to write to every single cooling_devicex file. If not, you'll need to modify the blob in the path.

Obviously, I'm not passing on the wisdom of shutting off any or all of your fans. It's your system: you break it you keep all the pieces.

I followed your advice and read the man pages of the tmpfiles.d and it seems that is exactly what im looking for. I have just tested it out and it works like a charm, thank you. As for forcing the fans to a state, the reason i do this is because no other method seems to work. CPU temperature wont pass 43 degrees when i use this laptop for normal tasks. When they are forced that is.

nstgc wrote:

I have to do something like this for bcache at boot. I use tmpfiles.d and it works great.

I agree, it works like a charm!

/Edit:

Greenify wrote:
whoops wrote:

Not sure if it's the right place though - I think you might not be supposed to change (/add) anything directly in /usr/lib/systemd and instead maybe copy it to /etc/systemd (?)... but I'm not sure if that applies to scripts like that, or might be confusing it with stuff in /usr/share -.-

You got a good point there, ill look it up this week and post my findings here.

This is what it says in the wiki:

Hooks in /usr/lib/systemd/system-sleep

An example of a custom sleep script:

/usr/lib/systemd/system-sleep/example.sh
#!/bin/sh
case $1/$2 in
  pre/*)
    echo "Going to $2..."
    ;;
  post/*)
    echo "Waking up from $2..."
    ;;
esac

Last edited by Greenify (2015-02-02 22:29:04)

Offline

Board footer

Powered by FluxBB