Posts Tagged ‘mbp 6.2’

Mac Book Pro 6,2 fans setup on Linux 3.10 and Debian Unstable

julio 28, 2013

Once again trying to setup my system so that I can use Linux 3.10 without too much hassle. Now it’s the turn for the fans. Since I used Linux 3.10 I noticed the fans were more noisy than before.

So in order to add fan setup first you need to install macfanctld from mactel-support ppa. I used the raring version.

So I’ve added the:

 /etc/apt/sources.list.d/mactel.list

file so that their contents are:

 deb http://ppa.launchpad.net/mactel-support/ppa/ubuntu raring main

. This way I can install macfanctld with:

 apt-get update
 apt-get install macfanctld

and as I don’t want to get more problems when apt-get dist-upgrading I just disable the new repo by commenting the line.

Now I noticed that the fan setup was still noisy. Finally I found at Ubuntu Linux en un macbook pro a working setup that was not so noisy.

Basically what you have to do is edit:

/etc/macfanctl.conf

and make sure that you replace these lines:

temp_avg_floor: 55 #45
temp_avg_ceiling: 65 #55

temp_TC0P_floor: 55 #50
temp_TC0P_ceiling: 65 #58

temp_TG0P_floor: 55 #50
temp_TG0P_ceiling: 65 #58

Once you have edited you only have to restart macfanctl daemon just like:

service macfanctld restart

and the noise gets down (if your laptop is cold enough of course).

Keyboard backlight brightness on Mac Book Pro 6,2 – Linux 3.10

julio 28, 2013

In the past I didn’t manage to make Keyboard backlight to work. It wasn’t turned on at all. When I updated to two or three months ago Debian Unstable the Keyboard backlight began to work at 100%. It was annoying but I didn’t want to waste my time in that.

Now I have invested some time on controlling that brightness. The article is mainly based on Ubuntu explanation on how to use Keyboard backlight without using pommed. Their zenity based script that let you choose the prefered brightness didn’t convince me.

So based on former screen brightness control script here there is a new one.

Its filename is:

/usr/local/bin/custom-keyboardlight-macbookpro

and its content is:

#!/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/leds/smc::kbd_backlight/brightness"
BRIGHT_CONF_DIR="$HOME/.keyboardbright"
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+17))
    #protect mechanism (BRIGHT must be lower or equal to 15)
     if (($BRIGHT>255))
     then
        BRIGHT=$((255))
     fi
    ;;
   "m")
    #decrease brightness
    #BRIGHT--
    BRIGHT=$(($BRIGHT-17))
    #protect mechanism (BRIGHT must be bigger or equal to 2)
     if (($BRIGHT<0))
      then         BRIGHT=$((0))
      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>255))
         then
           BRIGHT=$((255))
         fi

     if (($BRIGHT<0))      
     then         
       BRIGHT=$((0))      
     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 you might see there are some changes. Now I don’t mind having a 0 value because I actually want the keyboard not to bright at all. That’s different from an screen when you don’t want to miss it as a turned off one or non working one.

I have modified the script as always so that with only 15 types I can go from turned off to turned on at maximum brightness.

Then we need sudo so that we can run it as normal user.

So we edit sudo with the command:

sudoedit /etc/sudoers

so that we add:

normaluser ALL= NOPASSWD:/usr/local/bin/custom-keyboardlight-macbookpro

to it.

Now in my case as I use KDE I needed to setup its shortcuts to use it.

  • Preferences
  • Shortcuts and gestures
  • Custom Shortcuts

 

Then:

  • Right click and select New group which we will name: Keyboard brightness

Now we are going to setup the Increase Keyboard brightness shortcut.

  • Right click on Keyboard brightness
  • New
  • Global shortcut
  • Order / Url

so that we inform:

  • Name of the shorcut: Increase Keyboard brightness
  • Launcher tab: Short cut. I click on None and then I type “Increase keyboard brightness” button.
  • Action tab. Order / Url: sudo /usr/local/bin/custom-keyboardlight-macbookpro -p

Now we are going to setup the Decrease Keyboard brightness shortcut.

  • Right click on Keyboard brightness
  • New
  • Global shortcut
  • Order / Url

so that we inform:

  • Name of the shorcut: Decrease Keyboard brightness
  • Launcher tab: Short cut. I click on None and then I type “Decrease keyboard brightness” button.
  • Action tab. Order / Url: sudo /usr/local/bin/custom-keyboardlight-macbookpro -m

 

Now we just nee to make sure they are activated so that both of these shortcuts have ticks on them.

 

And that’s it you can control Keyboard brightness from your keyboard.

I think that I might even run: /usr/local/bin/custom-keyboardlight-macbookpro -p at kde start so that old keyboard value persists. Why? Because the default value is the backlight being on 100% while I prefer it to be turned off.

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

julio 28, 2013

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.

BCM5974 trackpad with Linux Kernel 3.10

julio 27, 2013

As you might know I was using a patched Linux Kernel 3.2 so that my integrated Intel card was used as default. So, here’s the strange thing, although I’m not setting up BCM5974 through xorg.conf (because there’s no xorg.conf file) it seems that booting into the system by Linux Kernel 3.2 or Linux Kernel 3.10 has different behaviour.

When using Linux Kernel 3.10 if I want to right-click I need to tap with two fingers but these two fingers need to be very close one from another. The same thing happens when you want to paste some text, that is middle click. You need to tap with three fingers and these three fingers need to be very close.