nan0s7 / nfancurve

A small and lightweight POSIX script for using a custom fan curve in Linux for those with an Nvidia GPU.
GNU General Public License v3.0
314 stars 57 forks source link

script on linux mint #16

Closed jankovicm1981 closed 5 years ago

jankovicm1981 commented 5 years ago

Hi, first of all thanks for great script, I can finally move my gpu render nodes to linux :) But I did run into an issue. Trying on linux mint 19.1 and running script gives me this:

./temp.sh: 7: ./temp.sh: Syntax error: "(" unexpected

On centos it was working fine but for some reason I have issues with centos on render nodes so proceeded with mint for now. \Any idea about this? Thank you

nan0s7 commented 5 years ago

Hey! Thanks for the positive words! Good to see you're finding it useful :D

I think that error is shell related, since there isn't anything obvious wrong on that line. What shell and what version of said shell are you using? As line 7 is the first line that introduces arrays into the script, which are famously different between many different shells; and are missing from old POSIX shells.

Right now, I recommend using Bash (you can force the script to use bash if you launch it like: bash temp.sh). However, if you are using Bash, then that's a good question.

I doubt it, but there could be an issue with how I've made the variable initialisations more compact by placing them all on the same line, although I've not seen an issue with that before.

If you are using a shell that isn't Bash or something similar to it, feel free to request a compatability update for it if you don't like using Bash at all. I've been planning on removing the arrays in a later version anyway, so I could work closer to the POSIX standard in a hope to make it more portable across systems.

jankovicm1981 commented 5 years ago

A bit of Linux noob here so versions and stuff not really familiar, so far just following instructions and understanding bits and pieces. But forcing bash with bash ./temp.sh worked perfectly!

Is there a way to force it like that for automation with that .desktop file as well?

nan0s7 commented 5 years ago

Oooh sure thing! Well I guess... welcome to the Linux club! :D

I'm sure you know a lot of this but I'll go over it a little anyway; Basically how you interact with a Linux computer is via the terminal emulator program (although now-adays a lot programs do the work for you), in which you interact with the "shell" (thus called the interactive shell :D ). Basically just a series of commands you can type in that do various things. There are different shells, although the most popular/common/default one is "Bash", which is what I wrote my script around because I knew most people would be familiar with it.

I guess in Linux Mint, the default shell is either not Bash, or the command ./ that you used to execute the script doesn't use Bash (or maybe just an unsupported version... could be anything really).

You can type echo $0 into any shell and it will give you the current shell you're using (so if you're using Bash, it'll say "bash"). I'd recommend looking up some tutorials on familiarising yourself with shells and basic scripting; it is one huge benefit Linux has over Windows, and can be used to do almost anything. Once you know the shell you're using, you can type the shell name, then --version and most of the time it'll tell you which version it is. For example, when I type bash --version it tells me I'm using version 5.0.2, amongst a lot of other information.

Anyway, in the .desktop file, you can simply use the same command (bash temp.sh) in the exec area. Although it can be a bit fussy with how you format that. Hopefully it works without much hassle, though.

If it turns out that you are using Bash anyway, there's likely some sort of configuration that the Linux Mint team have given you by default.

Sorry about the lengthy response. Hopefully I've helped a little xD

jankovicm1981 commented 5 years ago

Thanks for details, yes got some of those already but always good to cover missing parts.

I tried to echo $0 and it does say bash version: GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

trying yo update it: Reading package lists... Done Building dependency tree
Reading state information... Done bash is already the newest version (4.4.18-2ubuntu1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

But sh ./temp.sh gives that error and bash ./temp.sh works

I tried that in autofill but no luck... I used: [Desktop Entry] Name=GPU fan Control Type=Application Path=/home//Documents/nfancurve-master Exec=bash ./home//Documents/nfancurve-master/temp.sh

So in terminal bash ./temp.sh works but not in autostart. Also, I did use chmod +x on .desktop file and it is there and on in autostart programs list Thanks again for all the help. this is last piece of the puzzle and then I can move my small gpu render farm full to linux ;)

nan0s7 commented 5 years ago

Hmm yeah unfortunately Linux Mint prefers stability over the latest versions (well... that may not be unfortunate for you xD), but it should still work. Not entirely sure what's making it execute weirdly without specifying Bash specifically, though.

I tried making a .desktop file and I found that it works fine. However, you don't need the ./ when you run it explicitly with Bash.

For example: ./test.sh will execute whatever that file is bash test.sh will run the file as a script using the Bash shell

So your exec line should be: Exec=bash /home//Documents/nfancurve-master/temp.sh

Of course, adding back in your user name! :)

Hope that works!