Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Macbook Pro Adjust Backlight and Brightness Defaults

  1. #11
    Join Date
    Mar 2012
    Location
    Near one of my computers
    Beans
    307
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Macbook Pro Adjust Backlight and Brightness Defaults

    Quote Originally Posted by stefprez View Post
    Sorry for the long delay! Here's my rc.local.

    Code:
    #$backlight_brightness range  0-82311
    echo $backlight_brightness > /sys/devices/virtual/backlight/apple_backlight/subsystem/gmux_backlight/brightness
    
    #$kbd_brightness range 0-255
    echo $kbd_brightness > /sys/class/leds/smc\:\:kbd_backlight/brightness
    
    echo 4 > /sys/devices/virtual/backlight/apple_backlight/subsystem/gmux_backlight/brightness
    
    exit 0
    When I enter "4" for X on the command you supplied, it dims my screen to almost off, which is what I would expect, however the rc.local doesn't seem to be doing this on boot or wake from sleep. Do I need to include a sudo su command or something in rc.local? Is there another reason why the screen is still defaulting to 1000 suns brightness possibly? Thanks for the help so far!
    What are those first two executed lines doing? The ones starting with 'echo $*_brightness'? You don't need 'sudo su' because when this script is run, it is run as root. The script should execute near the end of boot, when it enters runlevel 5 and sets up a multiuser graphical session.

    Try using this for your /etc/rc.local for now. Make sure to backup your current one if you want to save it.

    If you want to save it.
    Code:
    sudo mv /etc/rc.local /etc/rc.local.backup
    To move it back later.
    Code:
     sudo mv /etc/rc.local.backup /etc/rc.local
    Code:
    #!/bin/sh -e
    
    #$backlight_brightness range  0-82311
    #echo $backlight_brightness > /sys/devices/virtual/backlight/apple_backlight/subsystem/gmux_backlight/brightness
    
    #$kbd_brightness range 0-255
    #echo $kbd_brightness > /sys/class/leds/smc\:\:kbd_backlight/brightness
    
    echo 4 > /sys/devices/virtual/backlight/apple_backlight/subsystem/gmux_backlight/brightness
    
    exit 0
    Then reboot and see what happens.

    Here is mine, which works on my MBP 8,1, for comparison if you want.
    Code:
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    echo '5' > /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness
    echo '25' > /sys/devices/platform/applesmc.768/leds/smc::kbd_backlight/brightness
    
    exit 0
    Best of luck,
    Kopkins
    Last edited by Kopkins; September 5th, 2012 at 04:26 PM.

  2. #12
    Join Date
    Aug 2012
    Beans
    4

    Re: Macbook Pro Adjust Backlight and Brightness Defaults

    Quote Originally Posted by Kopkins View Post
    What are those first two executed lines doing? The ones starting with 'echo $*_brightness'? You don't need 'sudo su' because when this script is run, it is run as root. The script should execute near the end of boot, when it enters runlevel 5 and sets up a multiuser graphical session.

    Try using this for your /etc/rc.local for now. Make sure to backup your current one if you want to save it.

    If you want to save it.
    Code:
    sudo mv /etc/rc.local /etc/rc.local.backup
    To move it back later.
    Code:
     sudo mv /etc/rc.local.backup /etc/rc.local
    Code:
    #!/bin/sh -e
    
    #$backlight_brightness range  0-82311
    #echo $backlight_brightness > /sys/devices/virtual/backlight/apple_backlight/subsystem/gmux_backlight/brightness
    
    #$kbd_brightness range 0-255
    #echo $kbd_brightness > /sys/class/leds/smc\:\:kbd_backlight/brightness
    
    echo 4 > /sys/devices/virtual/backlight/apple_backlight/subsystem/gmux_backlight/brightness
    
    exit 0
    Then reboot and see what happens.

    Here is mine, which works on my MBP 8,1, for comparison if you want.
    Code:
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    echo '5' > /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness
    echo '25' > /sys/devices/platform/applesmc.768/leds/smc::kbd_backlight/brightness
    
    exit 0
    Best of luck,
    Kopkins
    I tried modifying rc.local to just include the echo line you specified, but still on boot it is at max brightness. Just thinking out loud here, is there some sort of user settings file that is overriding the rc.local command when I log on? All your help so far is much appreciated, though!

  3. #13
    Join Date
    Mar 2012
    Location
    Near one of my computers
    Beans
    307
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Macbook Pro Adjust Backlight and Brightness Defaults

    The rc.local file should be executed before login so you should be able to see the screen actually dim as the login screen appears. It would be before you actually login, so there are no user-specific files that could interfere. Here is something I used for a little while before I set everything in my rc.local.

    Create a new file and put this in it.
    Code:
    import dbus
    bus = dbus.SessionBus()
    
    proxy = bus.get_object('org.gnome.SettingsDaemon',
                           '/org/gnome/SettingsDaemon/Power')
    
    iface=dbus.Interface(proxy,dbus_interface='org.gnome.SettingsDaemon.Power.Screen')
    
    iface.SetPercentage(30)
    Save the file in your home directory as '.set_bright_lvl.py'

    The preceding '.' makes it a hidden file so you don't have to see it all the time. The '.py' extension makes it executed by python. Other than that, name it whatever you like. Assuming you saved it as ~/.set_bright_lvl.py open terminal and enter the following.
    Code:
    sudo chmod +x ~/.set_bright_lvl.py
    Go to your startup apps, and add a new one. Enter the path to your file.

    Log out and back in and the screen should be set to 30% brightness. The '30' in the end of the script dictates the percentage of screen brightness.

    Kopkins

  4. #14
    Join Date
    Oct 2011
    Location
    Canada
    Beans
    891
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Macbook Pro Adjust Backlight and Brightness Defaults

    Interesting....I have a 2012 13" Macbook Pro (non retina) and this seems to only work 50%. I can disable the keyboard backlight on boot but lowering screen brightness does NOT work. It still boots into 100% power even with the following rc.local:


    Code:
    #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing.  echo '3' > /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness echo '1' > /sys/devices/platform/applesmc.768/leds/smc::kbd_backlight/brightness  exit 0

    I wondered why and when I ran just the below command in terminal, I got the below;

    Code:
    sudo echo '5' > /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness
    (with and without the '#')

    Code:
    sudo echo '5' > /sys/devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/brightness: Permission denied
    Permission denied even with sudo?!
    Last edited by d4m1r; April 23rd, 2013 at 08:39 PM.
    613websites.com Budget Canadian Web Design and Hosting

  5. #15
    Join Date
    Oct 2011
    Location
    Canada
    Beans
    891
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Macbook Pro Adjust Backlight and Brightness Defaults

    Fix my own problem by just installing xbacklight...not sure why the above didn't work but it probably a bug. You can find xbacklight in the Ubuntu repo's (sudo apt-get install xbacklight) and you can find more info on it below;

    http://linux.die.net/man/1/xbacklight
    613websites.com Budget Canadian Web Design and Hosting

  6. #16
    Join Date
    Mar 2012
    Location
    Near one of my computers
    Beans
    307
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Macbook Pro Adjust Backlight and Brightness Defaults

    That's what I've ended up using. I created a simple script and modified the sudoers file. The echo thing won't work with sudo, because it needs root for the second half but not the first. So it would technically need to be
    Code:
    echo TEXT > sudo tee /path/to/file
    I modified the sudoers file and .bashrc to allow executing of the file backlight as root without a password. Then created an alias in ~/.bashrc
    Code:
    alias backlight='sudo backlight'
    Then the file script itself.
    Code:
    #!/bin/bash
    
    case $1 in
         low)
            xbacklight =20
            echo "$[((90 * 255) / 100) % 256]" > /sys/class/leds/smc\:\:kbd_backlight/brightness
            ;;
        med)
            xbacklight =50
            echo "$[((50 * 255) / 100) % 256]" > /sys/class/leds/smc\:\:kbd_backlight/brightness
            ;;
        high)
            xbacklight =70
            echo "$[((0 * 255) / 100) % 256]" > /sys/class/leds/smc\:\:kbd_backlight/brightness
            ;;
        max)
            xbacklight =100
            echo "$[((0 * 255) / 100) % 256]" > /sys/class/leds/smc\:\:kbd_backlight/brightness
            ;;
        *)
            echo $"Usage $0 {low|med|high|max}"
            exit 1
        
    esac
    
    exit
    Then have this file automatically run when you login. Don't forget to chmod +x
    Last edited by Kopkins; April 24th, 2013 at 03:33 AM.

Page 2 of 2 FirstFirst 12

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
  •