Results 1 to 4 of 4

Thread: Script Question374 days old

  1. #1
    Wizard of Lore Mod Alakazam's Avatar
    Join Date
    Aug 2001
    Location
    In the Keep
    Posts
    14,760
    Threads
    6157

    Awards Showcase

    Real Name
    Zammy
    Local Date
    05-21-2013
    Local Time
    09:44 PM

    Script Question

    Long story short, I wrote a script to automate turning up my fan on the GPU, however this is my first attempt at doing this. From doing some reading, I should put the script in either "/usr/bin" or "usr/sbin", it doesn't seem to matter to the folks on Google, hehe, that's why I'm asking you gurus.

    Also, from reading some man pages, I'll need to change permissions and make it executable. Which way would be better if I even have it close to right. I want the Misses to be able to invoke the script but not write to it.

    Code:
    chmod a+x /usr/bin/nvidia_script.sh
    OR

    Code:
    chmod 755 /usr/bin/nvidia_script.sh

    Next up is to figure out how to keybind the script using Cinnamon in Mint 12, google hasn't been very helpful the little bit I did poke around.

  2. #2
    Hell's Very Own Grogan's Avatar
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    23,097
    Threads
    2409

    Awards Showcase

    Real Name
    Hugh Jorgen
    Local Date
    05-21-2013
    Local Time
    09:44 PM
    I would put it in /usr/bin for the simple reason it's more likely to be in the PATH regardless of how you gain root privileges. (If you just used "su" without the hyphen to make it a login shell, root's variables may not be processed on some distros, including redsplat based)

    If it's to be executed by users, then certainly it should be in /usr/bin (or /bin, or /usr/local/bin... anywhere in the user's PATH). I'm starting to remember that changing fan speeds didn't need root privileges with the Nvidia driver, but it's foggy.

    Binaries in the sbin directories are there only because they are binaries that root only can execute. The sbin directories are only in root's PATH variable. The decision to put them there is purely arbitrary and often just goes by tradition. It serves the purpose of not having the programs in a user's path so they won't try to execute them and get an error. Whoopee doo. There are many programs in bin and /usr/bin and friends that you need root privileges to use too. In fact many programs in sbin directories allow users to perform certain functions like querying, if a user types the path to them.

    As for changing permissions, I tend to use the octal method because it's the one I'm used to. "chmod 755 /usr/bin/nvidia_script.sh" will do what you want. It will set all the bits the way you want them to be. Whereas "+x" will only add the executable permission to whatever possible abomination it might already be.

    Both methods have their uses, depending on the situation. For example, say you have a directory that you want to change permissions recursively on. You want files to have rw-r--r--. You can't just go "chmod -R 644 directoryname" or you'll make it so nobody can enter subdirectories. In that case "chmod -R a+r directoryname" would safely add the bits to make the files readable by all. You could also do something like "chmod -R u+rw,go+r directoryname" if you want to make sure the owner has write permissions on everything.

    As for the key bindings, what is it you wish to do here? Only turn the fan up at certain times, or have it adjusted to the desired setting all the time? Keybindings would be good for the former, and executing your script in, say /etc/rc.d/rc.local would be appropriate for the latter. That's what I used to do when I had that space heater Nvidia card, invoke nvclock commands from there. (You can add a line that executes your script, which can contain whatever commands you want. Things in that file execute after all the other init scripts have been processed and they run with root privileges. It's quite handy)

    I'm sorry, I'm not familiar with what you're using, so I can't help with the key bindings. I'm sure you'll find it by poking around. If not, then someone needs a good five minutes of bitchslapping by an angry user.

  3. #3
    Wizard of Lore Mod Alakazam's Avatar
    Join Date
    Aug 2001
    Location
    In the Keep
    Posts
    14,760
    Threads
    6157

    Awards Showcase

    Real Name
    Zammy
    Local Date
    05-21-2013
    Local Time
    09:44 PM

    Thanks for the info Grogan, what I want to do is really simple but I think I'm making it hard. I used to use nvclock to set the fan speed once the desktop came up but now it won't work in the last 2 distros I've tried. I had to resort to using "coolbits" "5" in the Device section of xorg.conf in order to have access to the fan control in the Nvidia control panel.

    Once the CP is open it takes six clicks and 2 scrooling moves to put the fan speed up to about 70% which is just about right for my graphics card, right around 48-50C. The script I wrote using the xdotool program as a basis works fine, I just want to invoke it after the DT comes up with a key combo.

    I've moved the script to /usr/bin and did chmod 755 as you directed, now I've got to figure out how to keybind it, time is running short for today though. I hope I answered your questions.

    Another thought just came to me, is it possible to put the script in the dsktop startup section and have it automagically run a few seconds after the DT loads?

  4. #4
    Hell's Very Own Grogan's Avatar
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    23,097
    Threads
    2409

    Awards Showcase

    Real Name
    Hugh Jorgen
    Local Date
    05-21-2013
    Local Time
    09:44 PM
    Yep, you could put a .desktop file that runs your script in the Autostart directory. (I think they have to be .desktop files)

    I mean, right click and make a new shortcut and configure it to run your script. (The shortcut will be a .desktop file)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •