Control screen brightness when booting in EFI Mode with Linux 3.10 in MBP 6,2

Making Screen brightness to work in Linux 3.10

As you might know I’m trying to make work my Mac Book Pro 6,2 with Linux 3.10. One thing that didn’t work was screen brightness. I had already dealt with this settings when booting using Nvidia only and when booting with Intel in the Linux 3.2 days.

However the:

/sys/class/backlight/acpi_video0/

path was not changing the brightness. Something wrong was going here.

Well, finally, it seems that the Linux 3.10 handles pretty well the apple backlight even discerning if it has to deal with the Nvidia Graphics card or with the Intel Graphics card. I was put on the trail thanks to this apple_bl.c source code. At the end the module alias is:

mbp_nvidia_bl

So I decided to modprobe it but an error happened. This was the same error I had seen in dmesg around apple_bl line.

apple_bl: `1' invalid for parameter `use_gmux'

So what I needed to do was to remove that use_gmux parametre. You can find it explained in one of my former articles: Usar tarjeta intel integrada en Debian Unstable para MacBook Pro 6,2 .

I just edited the file:

/etc/modprobe.d/apple_bl.conf

and commented the line just in case I wanted to enable back screen brightness control when booting from 3.2 kernel. The optimal thing would be to add this extra parameter or not depending on Linux Kernel version but I think it’s not worth it.

Not after rebooting I was able to make the screen brightness to work.

Changing brightness manually

You only need to echo some value to:

/sys/class/backlight/gmux_backlight/brightness

which it’s a new path different from the two scripts that I have. Its maximum value is: 110400 which it’s also different from former values.

Script for changing gmux backlight brightness

We will just reuse some code from older scripts and adapt it the new max brightness. The filename is going to be:

/usr/local/bin/custom-backlight-macbookpro_gmux

and its contents will be:

#!/bin/bash

# Adapted from http://www.linuxquestions.org/questions/linux-laptop-and-netbook-25/script-to-set-up-brightness-of-backlight-in-xfce-903704/
# Script for changing backlight brightness in /sys/class/backlight/acpi_video0/brightness
# can take values 0-15, in real (my notebook) works only values 2-15

#IMPORTANT: you must have writing rights to /sys/.../brightness (I must solute it with visudo or something like that...)
#IMPORTANT: for proper work after reboot must exist directory .bright in your home directory and file last_bright in .bright directory 

#reads content of brightness and save it into variable

BRIGHTNESS_FILE="/sys/class/backlight/gmux_backlight/brightness"
BRIGHT_CONF_DIR="$HOME/.brightgmux"
LAST_BRIGHT_FILE="${BRIGHT_CONF_DIR}/last_bright"
BRIGHT=$(cat ${BRIGHTNESS_FILE})

while getopts "pmlhc" optname
 do
  case "$optname" in
   "p")
    #Add more brightness
    #BRIGHT++
    BRIGHT=$(($BRIGHT+7360))
    #protect mechanism (BRIGHT must be lower or equal to 15)
     if (($BRIGHT>110400))
     then
        BRIGHT=$((110400))
     fi
    ;;
   "m")
    #decrease brightness
    #BRIGHT--
    BRIGHT=$(($BRIGHT-7360))
    #protect mechanism (BRIGHT must be bigger or equal to 2)
     if (($BRIGHT<14720))
     then
        BRIGHT=$((14720))
     fi    
    ;;
   "l")
    echo "Loading last value of brightness."
    #Load last value, saved in file last_bright
    BRIGHT=$(cat ${LAST_BRIGHT_FILE})
    echo "Last value of brightness was: $BRIGHT"
    ;;
   "h")
     echo "Help: "
     echo "-p    Increase brightness"
     echo "-m    Decrease brightness"
     echo "-l    Load last brightness value"
     echo "-c N Set to custom value"
     echo "-h    This help"
     echo "Programmed by: ElectricZero"
     echo "Improved by: adrian15"
     exit 0;
     ;;
    "c")
     BRIGHT=$2
     if (($BRIGHT>110400))
     then
        BRIGHT=$((110400))
     fi

     if (($BRIGHT<14720))
     then
        BRIGHT=$((14720))
     fi
     ;;
    "?")
     echo "Unknown argument, try bright -h for help"
     exit 1;
     ;;
    *)
    # Should not occur
    echo "Unknown error while processing options"
    exit 2;
    ;;
  esac
done
echo "Brightness set on $BRIGHT"
#Save variable BRIGHT into file brightness
echo $BRIGHT > ${BRIGHTNESS_FILE}
#Save variable BRIGHT into file last_bright
if [ ! -d ${BRIGHT_CONF_DIR} ] ; then mkdir ${BRIGHT_CONF_DIR} ; fi
echo $BRIGHT > ${LAST_BRIGHT_FILE}

As I already did I also had to modify my main screen brightness script to use the three of the scripts I now have for screen brightness control.

Screen brightness control wrapper script

 

So the file:

custom-backlight-macbookpro_both

now has:

#!/bin/bash

NVIDIA_BL_BINARY="/usr/local/bin/custom-backlight-macbookpro_nvidia"
INTEL_BL_BINARY="/usr/local/bin/custom-backlight-macbookpro_intel"
GMUX_BL_BINARY="/usr/local/bin/custom-backlight-macbookpro_gmux"

while getopts "pmlhc" optname
 do
  case "$optname" in
   "p")
    #Add more brightness
    ${NVIDIA_BL_BINARY} -p
    ${INTEL_BL_BINARY} -p
    ${GMUX_BL_BINARY} -p
    ;;
   "m")
    #decrease brightness
    ${NVIDIA_BL_BINARY} -m
    ${INTEL_BL_BINARY} -m
    ${GMUX_BL_BINARY} -m
    ;;
   "l")
    echo "Loading last value of brightness."
    ${NVIDIA_BL_BINARY} -l
    ${INTEL_BL_BINARY} -l
    ${GMUX_BL_BINARY} -l
    ;;
   "h")
     echo "Help: "
     echo "-p    Increase brightness"
     echo "-m    Decrease brightness"
     echo "-l    Load last brightness value"
     echo "-c N Set to custom value"
     echo "-h    This help"
     echo "Programmed by: ElectricZero"
     echo "Improved by: adrian15"
     exit 0;
     ;;
    "c")
     BRIGHT=$2
     if (($BRIGHT>15))
     then
        BRIGHT=$((15))
     fi

     if (($BRIGHT<2))
     then
        BRIGHT=$((2))
     fi
    let INTELBRIGHT=${BRIGHT}*8800
    let GMUXBRIGHT=${BRIGHT}*7360
    ${NVIDIA_BL_BINARY} -c ${BRIGHT} 
    ${INTEL_BL_BINARY} -c ${INTELBRIGHT}
    ${GMUX_BL_BINARY} -c ${GMUXBRIGHT}
     ;;
    "?")
     echo "Unknown argument, try bright -h for help"
     exit 1;
     ;;
    *)
    # Should not occur
    echo "Unknown error while processing options"
    exit 2;
    ;;
  esac
done

So that’s it. Now screen brightness control should work as before. My former kde key bindings should now work as before.

Anuncios

Etiquetas: , , , , , ,

Una respuesta to “Control screen brightness when booting in EFI Mode with Linux 3.10 in MBP 6,2”

  1. Keyboard backlight brightness on Mac Book Pro 6,2 – Linux 3.10 | El blog de adrian15 Says:

    […] Super Grub Disk, GNU/Linux y cualquier otra cosa que se me antoje. « Control screen brightness when booting in EFI Mode with Linux 3.10 in MBP 6,2 […]

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s


A %d blogueros les gusta esto: