Results 1 to 2 of 2

Thread: Brightness control command which requires root permission in a script

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Beans
    19

    Brightness control command which requires root permission in a script

    Hi all,

    I would like to ask for help regarding automatically run command as root. I need to run below command line in a terminal to set brightness for the sake of my sensitive eyes.

    setpci -s 00:02.0 F4.B=15

    I tried to make it as a script but not working. This is first time though.
    #! /bin/sh
    sudo -s "my password" <- to login as root
    setpci -s 00:02.0 F4.B=15 <- since I gained root, run the command right away.
    exit 0 <- let system know script is finished

    However, setpci command required root permission. What I am doing now so is that as soon as xwindow loads open a terminal window then login as root and then type the setpci command. I am seeking a way to make these steps automate itself after finishing boot up. I have been exploring google since lunch time because of it(roughly 10hours). However, I could not find a solution for it yet. I am novice in a boot camp of LINUX. It would be great that give me explicit instructions as much you can. I much appreciate it!

    Best wishes,
    Evan S

  2. #2
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: Brightness control command which requires root permission in a script

    You can add an entry to your sudoers file so that the setpci command can be run without prompting for a password.

    First run the following commands to open the sudoers file for editing...
    Code:
    sudo -i
    EDITOR=nano visudo
    Now add the following line to the bottom of the file replacing username with your actual username.
    Code:
    username ALL=(ALL) NOPASSWD: /usr/bin/setpci
    Hit CTRL+x and save the file and then exit your root shell.

    You should now be able to run 'sudo setpci -s 00:02.0 F4.B=15' without being prompted for a password, so just add the command to your startup applications using the 'Startup Applications' application.
    Last edited by Cheesemill; March 26th, 2013 at 06:54 PM.
    Cheesemill

Tags for this Thread

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
  •