Function keys for ASUS n56vm not working

I have installed Ubuntu 12.10 (64bits) (3.5.0-18 kernel) on an ASUS N56VM. Most Fn+Key are working except for:

  • brightness keys (Fn+F5/Fn+F6)
  • Fn+C - gamma keys
  • Fn+V - camera
  • Fn+Space - toggle speed

I really like, at least, to have the brightness keys working.

Can you help? Best Regards


$ dmesg | grep -i asus 
[    0.000000] DMI: ASUSTeK COMPUTER INC. N56VM/N56VM, BIOS N56VM.206 04/13/2012
[    0.000000] ACPI: RSDP 00000000cafcc000 00024 (v02 _ASUS_)
[    0.000000] ACPI: XSDT 00000000cafcc078 00074 (v01 _ASUS_ Notebook 01072009 AMI  00010013)
[    0.000000] ACPI: FACP 00000000cafdf858 000F4 (v04 _ASUS_ Notebook 01072009 AMI  00010013)
[    0.000000] ACPI: DSDT 00000000cafcc188 136CA (v02 _ASUS_ Notebook 00000013 INTL 20091112)
[    0.000000] ACPI: APIC 00000000cafdf950 00092 (v03 _ASUS_ Notebook 01072009 AMI  00010013)
[    0.000000] ACPI: FPDT 00000000cafdf9e8 00044 (v01 _ASUS_ Notebook 01072009 AMI  00010013)
[    0.000000] ACPI: ECDT 00000000cafdfa30 000C1 (v01 _ASUS_ Notebook 01072009 AMI. 00000005)
[    0.000000] ACPI: MCFG 00000000cafdfaf8 0003C (v01 _ASUS_ Notebook 01072009 MSFT 00000097)
[    0.000000] ACPI: SLIC 00000000cafdfb38 00176 (v01 _ASUS_ Notebook 01072009 ASUS 00000001)
[    0.000000] ACPI: HPET 00000000cafdfcb0 00038 (v01 _ASUS_ Notebook 01072009 AMI. 00000005)
[    0.000000] ACPI: BGRT 00000000cafe1090 00038 (v00 _ASUS_ Notebook 01072009 ASUS 00010013)
[    9.670500] asus_wmi: ASUS WMI generic driver loaded
[    9.671627] asus_wmi: Initialization: 0x1asus_wmi: BIOS WMI version: 7.9
[    9.671673] asus_wmi: SFUN value: 0x6a0877<6>[    9.672086] input: Asus WMI hotkeys as /devices/platform/asus-nb-wmi/input/input4
[    9.732438] Registered led device: asus::kbd_backlight
[    9.733242] asus_wmi: Backlight controlled by ACPI video driver

This solution for the FN Keys worked for me on

ubuntustudio 12.10 64bit [ASUS N56VM]

(I advice you I'm not an expert)

With a fresh install of ubuntustudio the keyboard backlight and display brightness fn keys [f3, f4, f5, f6] don't work to me, so I did:

1. Download and install: kernel 3.7.0-7 lowlatency

  • download these three files: 1) headers_all 2) headers 3) image (here you can find the download links)
  • from the terminal go in the directory where they have been downloaded and then install them with the following commands:

    sudo dpkg -i linux-lowlatency-headers-3.7.0-7_3.7.0-7.5_all.deb
    sudo dpkg -i linux-headers-3.7.0-7-lowlatency_3.7.0-7.5_amd64.deb
    sudo dpkg -i linux-image-3.7.0-7-lowlatency_3.7.0-7.5_amd64.deb
    
  • restart the system selecting in the grub this new kernel

So now (at least to me) the following fn key works: f2 [wirelss], f5 [brightenss down], f6 [brightness up], f7 [turn off screen], f10-f11-f12 [audio controls]

2. Write a script to get full permissions on the file we need to control

  • run the following commands [means: go to the folder /init.d -> create a file called asus-kbd_backlight.sh -> open it with gedit]

    cd /etc/init.d sudo touch asus-kbd_backlight.sh && gedit asus-kbd_backlight.sh
    
  • now copy this:

    /bin/chmod 777 /sys/class/leds/asus::kbd_backlight/brightness  
    

    and paste it in the file, save and close it

  • now go back to the terminal and write the following commands:

    sudo chmod 744 /etc/init.d/asus-kbd_backlight.sh
    sudo chown root:root /etc/init.d/asus-kbd_backlight.sh
    sudo ln -s /etc/init.d/fan-speed-init.sh /etc/rc2.d/S99asus-kbd_backlight.sh
    

3. Write two other small shell scripts [thanks to this answer]

  • open a new file with a texteditor like gedit and write the following:

    #!/bin/bash
    echo 0 > /sys/class/leds/asus::kbd_backlight/brightness
    
  • save it as i.e. : asus-keysOff

  • open another new file with a texteditor and write the following:

    #!/bin/bash
    echo 3 > /sys/class/leds/asus::kbd_backlight/brightness
    
  • save it as i.e. : asus-keysOn

4. Assign these scripts to keyboard shortcuts

  • go on the Settings Manager -> Keyboard -> Application Shortcuts
  • add a new one, as Command choose the file asus-keysOn press Ok and in the next dialog box press the keys combination: fn+F3.
  • now to turn off again add a new shortcut, as Command choose the file asus-keysOff press Ok and in the next dialog box press the keys combination: fn+F4

5. Reboot and use the fn keys

It works only on/off with no gradual levels [it should work with four levels: 0-1-2-3...] but it works.

hope this could be of help


This is an addendum to the comprehensive answer of kuus, thanks for that.

A1. Kernel

His solution worked for me on the standard quetzal kernel (3.5.0).

A2. Write a script to get full permissions on the file we need to control (can be packed into single command)

Can be abbreviated into a single (though longish) command, basically added a chmod 744 asus_kbd_backlight.sh to be able to echo the text into it.

sudo touch /etc/init.d/asus_kbd_backlight.sh && \
sudo chmod 777 /etc/init.d/asus_kbd_backlight.sh && \
sudo echo /bin/chmod 777 "/sys/class/leds/asus::kbd_backlight/brightness" > /etc/init.d/asus_kbd_backlight.sh && \
sudo chmod 744 /etc/init.d/asus_kbd_backlight.sh && \
sudo chown root:root /etc/init.d/asus_kbd_backlight.sh && \
sudo ln -s /etc/init.d/asus_kbd_backlight.sh /etc/rc2.d/S99asus_kbd_backlight.sh

A reboot is necessary to set the permissions. However they can be set manually by simply calling.

/bin/chmod 777 "/sys/class/leds/asus::kbd_backlight/brightness"

A3. Write two other small shell scripts (can be packed into single command with step-wise brightness control)

I wrote a somewhat more convenient single script to support stepwise increase/decrease of keyboard backlight brightness.

Usage is:

asus_kbd_backlight.sh [-d] (up|down)

Script is:

#!/bin/bash

kbdSysPath="/sys/class/leds/asus::kbd_backlight"
bPot="$kbdSysPath/brightness"
crtB=`cat $bPot`
maxB=`cat "$kbdSysPath/max_brightness"`

if [ $1 = "-d" ]; then
  isDebug=true;
  drctn=$2
else
  drctn=$1
fi

function dbg () { [ $isDebug ] && echo $1; }
function setNewB () {
  dbg "setting new brightness: $newcrtB"
  dbg "$1 > $bPot"
  echo $1 > $bPot
}

dbg "current brightness: $crtB; maximum Brightness: $maxB"

if [ $drctn = "up" ]
then
  if [ $maxB -gt $crtB ]
  then
    newcrtB=$((crtB+1))
    setNewB $newcrtB
  else
    dbg "already at maximum $crtB"
  fi
elif [ $drctn = "down" ]
then
  if [ $crtB -gt 0 ]
  then
    newcrtB=$((crtB-1))
    setNewB $newcrtB
  else
    dbg "already at minimum: $crtB"
  fi
else
  echo "Usage: asus_kbd_backlight [-d] (up|down)
  -d    output debug statements
  up    increase brightness by 1 until maximum value is reached
  down  decrease brightness by 1 until 0 (assumed to be minimum value)"
fi

A4. Assign the script to keyboard shortcuts (KDE-specific)

Custom Shortcuts -> Edit -> New -> Global Shorcut -> Command/URL

For each shortcut go to the Trigger tab and set Fn+F3/F4

For each shortcut go to the Action tab and specify the command to call, either

/path/to/asus_kbd_backlight.sh up

or

/path/to/asus_kbd_backlight.sh down