Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Nvidia GPU Fan Tweaker Script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
szpko
n00b
n00b


Joined: 24 Apr 2014
Posts: 9

PostPosted: Thu Apr 24, 2014 2:29 pm    Post subject: Nvidia GPU Fan Tweaker Script Reply with quote

...

Last edited by szpko on Fri Aug 01, 2014 2:12 pm; edited 10 times in total
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2693
Location: The Peanut Gallery

PostPosted: Thu Apr 24, 2014 7:29 pm    Post subject: Reply with quote

Ugh ancient and absolutely typical of most distros: we call that kind of script "bashish", since it has a /bin/bash shebang, but is written for sh, only it relies on some bashisms, and doesn't even know clean sh. The use of eval is totally unnecessary. Personally I'd rewrite it for pure sh:
Code:
#!/bin/sh
current_speed=$(nvidia-settings -t -q '[fan:0]/GPUCurrentFanSpeed') || exit
 
case $1 in
   up) new_speed=$((current_speed + 10))
      [ 100 -lt "$new_speed" ] && new_speed=100
;; down) new_speed=$((current_speed - 10))
      [ 35 -gt "$new_speed" ] && new_speed=35
;; *) exit 1
esac
exec nvidia-settings -a '[gpu:0]/GPUFanControlState=1' -a "[fan:0]/GPUCurrentFanSpeed=$new_speed"

I'm not sure it's such a good idea for the user to manually set the fan speed, mind; the batch scan looked more useful. But you could use the above with /bin/sh symlinked to any shell conformant to POSIX, /bin/bb or dash for example, as well as bash.

If you're not going to exit from the first command if it fails, then move the checks of range below the case statement; but I would, even if you decide to use: || exit 0 (though exit status is typically useful to other components.) The exit status of the last command run (or in this case we exec for efficiency) will be the exit status of the script. If you don't want that, remove the exec and add exit 0 to end (though again, I'd question the validity of that.)
Back to top
View user's profile Send private message
szpko
n00b
n00b


Joined: 24 Apr 2014
Posts: 9

PostPosted: Fri Apr 25, 2014 1:49 am    Post subject: Reply with quote

...

Last edited by szpko on Fri Aug 01, 2014 2:13 pm; edited 1 time in total
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2693
Location: The Peanut Gallery

PostPosted: Sat Apr 26, 2014 7:58 pm    Post subject: Reply with quote

You're welcome, szpko; only it's not a "Bash script" any more, is it? ;) I'd edit the title/subject of OP and s/Bash/nvidia, as well as first line.

BTW, you shouldn't use unquoted globbing chars in script (unless you are trying to glob), however unlikely a match is; '[abc]' is a one-of char match in shell, when unquoted, and a string when it has '..' (or ".." but if it's literal, single-quoting is better afaic.) '*' and '?' are the other two to watch out for (as well ofc as spaces, and most punctuation, but not '.' or '/'.)

Didn't mean that there's no valid reason to tweak the fan speed; just that I'd be more interested in it being automatic. I didn't know nvidia default to 10% speed; I assumed it just varies with temperature. I have always got on with nvidia on Linux, so I'm curious now.

Thanks for putting in the legwork to find out more about it all, and taking the time to document.
Back to top
View user's profile Send private message
szpko
n00b
n00b


Joined: 24 Apr 2014
Posts: 9

PostPosted: Sun Apr 27, 2014 1:51 am    Post subject: Reply with quote

...

Last edited by szpko on Fri Aug 01, 2014 2:13 pm; edited 1 time in total
Back to top
View user's profile Send private message
Chiitoo
l33t
l33t


Joined: 28 Feb 2010
Posts: 874
Location: Here and Away Again

PostPosted: Sun Apr 27, 2014 2:17 am    Post subject: ><)))°€ Reply with quote

Some cool bits indeed you've got there. ^^

Thanks for sharing!

steveL wrote:
Didn't mean that there's no valid reason to tweak the fan speed; just that I'd be more interested in it being automatic. I didn't know nvidia default to 10% speed; I assumed it just varies with temperature. I have always got on with nvidia on Linux, so I'm curious now.

For what it's worth, mine seems to default to 40, and I can't set it lower than 30, at least not via the nvidia-settings GUI.

I don't seem to have any sort of automagic happening (at least not within the temps I try to keep it, that's around 60°C at most... due to the noise levels it puts out, though I think it has gone beyond 70°C when I forget to adjust the speed; perhaps it would start fanning up beyond that, but I've not tested). So, I have to fiddle with coolbits to gain access (even though the fan tool-tip says one should never have to enable it).

Normally I set it down to 30, or let it be at 40-50 when I have things going that make heat happen. Sometimes even 60! At 100 it gets just silly.

This is with an Asus (EN)GTX 275.
_________________
Kind Regards,
~ The Noob Unlimited ~

Sore wa sore, kore wa kore.
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 2693
Location: The Peanut Gallery

PostPosted: Mon Apr 28, 2014 2:51 pm    Post subject: Reply with quote

Heh I didn't even know about coolbits, and really must explore that GUI a bit more.. ;)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum