# How to get extra functional keys to work?

## muebi

Hi, 

I have a Lenovo Thinkpad which has quite a few additional functional keys. Can anybody guide me how the get these keys working in Gentoo?

Many thanks!Last edited by muebi on Sat Nov 22, 2008 4:33 pm; edited 1 time in total

----------

## dmpogo

 *muebi wrote:*   

> Hi, 
> 
> I have a Lenovo Thinkpad which has quite a few additional functional keys. Can anybody guide me how the get these keys working in Gentoo?
> 
> Many thanks!

 

I have a Lenovo X300 and made then all work (basically - acpi handling thourhg acpid, but some differently).

What model do you have ?

I can guide you, but when I am not at work.

----------

## muebi

Lenovo Thinkpad W500.

Thanks!

----------

## dmpogo

Ok,

Part I

1)  first of all you need to compile the kernel with  'thinkpad_acpi" module enabled

It is  in

Device Drivers -> Misc -> ThinkPad ACPI Laptop extras

You don't need Verbose Debug, and Video Output Control options, but you may select for now NVRAM support (although I hope it

will not be needed).

1a)  Choose to compile "video" module  in the regular acpi configuration

2) emerge acpid

3) Then run in the terminal acpi_listen  and press different buttons.   Record which one generate acpi events. Those will be Fn cominbations

'Thnikpad' Button, probably hardware radio switch,   Brightness key.

Most probably NOT Multimedia keys or volume keys.

These we will handle through acpid daemon, I'll give you the scripts (there are many online as well)

Part II

Multimedia and volume keys most probably generate regular key events that should be bound to appropriate symbols either

a) by choosing appropriate keyboard model in xorg.conf or in your desktop manager keyboard configuration or

 if some still do not work by

b) binding them manually with xmodmad

My xorg.conf reads

```

Section "InputDevice"

        Identifier "MyKeyboard"

        Driver      "kbd"

        

       Option       "XkbRules"  "xorg"

       Option       "XkbModel   "thinkpad60"

....

EndSection

```

and this choice of model makes all multimedia keys work.   To be exact, it makes them bound to appropriate symbols,

which you can check running 'xev' in the terminal and pressing the keys (with mouse in special window).  

Whether the symbols are reacted to by the application is a different matter.

This is for start,  please report on the progress.[/code]

----------

## albright

 *Quote:*   

> I have a Lenovo X300

 

Sorry this is off topic, but I'm just wondering how you

like the x300 and how well does gentoo install/run on it?

looks like a fantastic machine  :Smile: 

----------

## dmpogo

 *albright wrote:*   

>  *Quote:*   I have a Lenovo X300 
> 
> Sorry this is off topic, but I'm just wondering how you
> 
> like the x300 and how well does gentoo install/run on it?
> ...

 

Well, X301 is better  :Smile: 

Gentoo is essentially perfect,   both install (with some custom steps) and run.  

It does of course have intel graphics, which 3D performance is not stellar (with current support in  a state of flux)

but I use it for work,  not for gaming, so I don't care that much how good 3D is.

My main criteria was first of all weight (give decent size and 13'' widescreen works better for me than 12'' standard) and 

quiteness.    Battery life is great. I have opted for an extra battery in place of DVD-RW, and have 5.5 hours runtime.

So I'm totally happy with it as a travelling companion.

One thing is that CPU is perhaps a bit underpowered (1.2 Mhz core 2 duo), but this what X301 mostly improves on.

Plus I believe X301 comes with DVI video out, the feature I long for a while in PC's

Since it was paid by the grant I would have gone for X301 if it was today.

----------

## muebi

dmpogo, 

1) I recompiled the kernel with thinkpad_acpi built in the kernel, installed it and booted into the new kernel.

1a) I am not sure what you mean here. I am also following the Gentoo acpi guide a bit where I compiled the following:

   Power management options  --->

   [*] Power Management support                                    

   [*]   Power Management Debug Support                        

   [ ]     Verbose Power Management debugging                  

   [*] Suspend/resume event tracing                                  

   [*] Suspend to RAM and standby                                  

   [ ]   Test suspend/resume and wakealarm during bootup          

   [*] Hibernation (aka 'suspend to disk')                         

    ()    Default resume partition                                   

   [*] ACPI (Advanced Configuration and Power Interface) Support -->

       --- ACPI (Advanced Configuration and Power Interface) Support

         [*]   Deprecated /proc/acpi files                                

         [*]   Deprecated power /proc/acpi directories                 

         [*]   Future power /sys interface                                 

         [*]   Deprecated /proc/acpi/event support                       

        <*>   AC Adapter                                                 

        <*>   Battery                                                    

        <*>   Button                                                     

        <*>   Video                                                     

        <*>   Fan    

        <*>   Processor                                                 

        <*>     Thermal Zone

2) I emerged acpi which worked.

3) I can run acpi_listen but nothing seems to happen... No reaction or output if I press any of the function keys.

----------

## muebi

dmpogo,

So far I only got the thinkpad light working with Fn + PgUp and the brightness control of the display. These things worked after emerging xmodmap and tpb. However, it would be nice to have the little screen popping up such as in Ubuntu when the brightness control buttons are pressed. Do you know how that works? I also not sure if the sound control buttons are working yet. These are little gray ones next to the ThinkVantage button.

----------

## dmpogo

1) Can you show me the output of "dmesg | grep thinkpad"

2) Please get rid of tpb for now (or do not run it)

3) If you launch acpi_listen, what happens when

     a) You press brightness key (Fn-Home ?)

     b) Fn-F4 

     c) Fn-F7 

Fn-PgUp (light) is usually handled in hardware and need no settings

----------

## muebi

dmpogo, 

thanks for your help.

1) dmesg | grep thinkpad gives:

[    0.575724] thinkpad_acpi: ThinkPad ACPI Extras v0.21

[    0.575856] thinkpad_acpi: http://ibm-acpi.sf.net/

[    0.575986] thinkpad_acpi: ThinkPad BIOS 6FET43WW (1.13 ), EC 7VHT12WW-1.01

[    0.576120] thinkpad_acpi: Lenovo ThinkPad W500, model 4061A97

[    0.577396] thinkpad_acpi: radio switch found; radios are enabled

[    0.577823] thinkpad_acpi: This ThinkPad has standard ACPI backlight brightness control, supported by the ACPI video driver

[    0.578048] thinkpad_acpi: Disabling thinkpad-acpi brightness events by default...

[    0.595072] thinkpad_acpi: Lenovo BIOS switched to ACPI backlight control mode

[    0.595294] thinkpad_acpi: standard ACPI backlight interface available, not loading native one...

2) I did emerge --unmerge tpb to get rid of tpb

3) acpi_listen gives:

a) Fn + Home: 

video LCD0 00000086 00000000

video LCD0 00000086 00000000

b) Fn + F4:

ibm/hotkey HKEY 00000080 00001004

c) Fn + F7:

ibm/hotkey HKEY 00000080 00001007

----------

## dmpogo

Very good ! You do have ACPI events, why did you say nothing happen when you press function keys ?

Try all of them now !  And then we get to the scripts.

BTW, you can change xorg.conf as I suggested at the same time and see with xev what symbols they generate.

----------

## muebi

Should I add your suggested InputDevice section or replace mine with it?

I cannot run xev in the terminal. Do I need to emerge a certain package for this command to work?

I get and ACPI event on all Fn + keys.  :Smile: 

----------

## dmpogo

 *muebi wrote:*   

> Should I add your suggested InputDevice section or replace mine with it?
> 
> I cannot run xev in the terminal. Do I need to emerge a certain package for this command to work?
> 
> I get and ACPI event on all Fn + keys. 

 

Yes, xev is a separate (small package), do 'emerge xev'

In input devices the relevant line is kyeboard model 'thinkpad60'   replace what you have by it.

If you have nothing, insert what I gave.

Regarding ACPI buttons - great that they work.   Here is what you need to do to utilize them

1) in the directory /etc/acpi/events you have a file named 'default'. I created 3 more files

/etc/acpi/events/ibm

```
event=ibm/hotkey

action=/etc/acpi/ibm.sh %e

```

/etc/acpi/events/lidbtn

```

event=button/lid

action=/etc/acpi/lidbtn.sh

```

/etc/acpi/events/video

```

event=video

action=/etc/acpi/video.sh %e

```

Create them.   The first file redirects all events that come with 'ibm' tag to be handled by /etc/acpi/ibm.sh script,

the second handles closing the lid, and the thrid - brightness buttons (but did you say britness keys work for you already ?)

2) Then in /etc/acpi   (one level above the /etc/acpi/event) I have the following script.  Create then, and then I'll explain what they do

and we discuss customization

/etc/acpi/ibm.sh

```

#!/bin/sh

# Specific signal handling

THINKPAD_ACPI_DIR=/sys/devices/platform/thinkpad_acpi

X_USER=`who | sed -ne "s/^\([^[:space:]]*\)[[:space:]]*:0.*/\1/p"`

if [ -n "$X_USER" ]; then

   export DISPLAY=":0.0"

   export XAUTHORITY=/home/${X_USER}/.Xauthority

fi

function x_info () {

   if [ -n "$XAUTHORITY" ]; then

           echo $1 | osd_cat -d 3 -p bottom -A center -o -50 -s 2 -c $2 -f  -adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1

        fi

}

case $4 in

   00001002)

           su $X_USER -c 'alock -bg shade:shade=20 -cursor theme:name=xtr -auth pam'

      ;;

   00001004) 

      # Fn-F4 suspends to RAM (standard)

      # loaded thinkpad_acpi always captures Fn-F4, even masked  

      /usr/sbin/hibernate-ram

      ;;

   00001005) 

      # Fn-F5 toggles bluetooth radio (standard)

      # On toggle auto loads driver (hotplug ??), off leaves it

      # Services are currently untouched

      if [ `cat ${THINKPAD_ACPI_DIR}/bluetooth_enable` == 1 ] ; then

         echo 0 > ${THINKPAD_ACPI_DIR}/bluetooth_enable

      elif [ `cat ${THINKPAD_ACPI_DIR}/hotkey_radio_sw` == 1 ] ; then

      # we enable radio only if "hard" switch is on

         echo 1 >  ${THINKPAD_ACPI_DIR}/bluetooth_enable

      fi

      ;;      

   00001006)

      # Fn-F6 starts-stops wireless services (NON-standard)

      # In my network config wlan stop comes with disabling radio

      status=`/etc/init.d/net.wlan0 status` 

      status=${status#* status:}

      if   [ $status == started ] ; then

           /etc/init.d/net.wlan0 stop   

      elif [ $status == stopped ] ; then

           if [ `cat ${THINKPAD_ACPI_DIR}/hotkey_radio_sw` == 1 ] ; then

           /etc/init.d/net.wlan0 start   

           fi

      elif [ $status == inactive ] ; then

           # This perhaps can arise if there are no AP's

           # this is why I do not restart automatically

           # May do it when understand wpa_supplicant better

           message="No AP's or WLAN may have hanged. Restart manually, perhaps reinserting iwl4965"

           x_info "$message" red

           logger "$message"

      fi

      ;;

   00001007)

      # Fn-F7 cycles through monitors (standard)

      /usr/local/sbin/thinkpad-fn-f7 toggle

      ;;

   00001008)

      # Fn-F8 switches touchpad on and off (standard)

      if synclient -l | grep -q TouchpadOff[^[:alnum:]]*0 ; then

         synclient TouchpadOff=1

         status="TouchPad OFF"

      else

         synclient TouchpadOff=0

         status="TouchPad ON"

      fi

      x_info "$status" green

      ;;

   0000100c)

      # Fn-F12 hibernates (standard)

      /usr/sbin/hibernate

      ;;

   00001014)

      # Fn-Space zoom application (standard)

           su $X_USER -c 'vmg &'

      ;;

   00007000)

      # Hard radio switch off (standard)

      if [ `cat  ${THINKPAD_ACPI_DIR}/hotkey_radio_sw` == 0 ] ; then

          status=`/etc/init.d/net.wlan0 status` 

         status=${status#* status:}

         /etc/init.d/net.wlan0 stop   

         echo 0 >  ${THINKPAD_ACPI_DIR}/bluetooth_enable

      fi

      ;;

esac   

```

/etc/acpi/lidbtn.sh

```
#!/bin/bash

lid_state=/proc/acpi/button/lid/LID/state

test -e $lid_state || exit 0

if cat $lid_state | grep closed > /dev/null

  then echo "lid closed -> suspending"

   /usr/sbin/hibernate-s2both

else echo "lid opened -> resuming"

fi

```

/etc/acpi/video.sh

```

#!/bin/sh

acpi_video_dir=/sys/devices/virtual/backlight/acpi_video1

case $3 in

   00000086) 

       echo $(( `cat ${acpi_video_dir}/brightness` + 1 )) >  ${acpi_video_dir}/brightness

      ;;

   00000087) 

       echo $(( `cat ${acpi_video_dir}/brightness` - 1 )) >  ${acpi_video_dir}/brightness

      ;;      

esac   

```

and modified  /etc/acpi/default

```

#!/bin/sh

# /etc/acpi/default.sh

# Default acpi script that takes an entry for all actions

set $*

group=${1%%/*}

action=${1#*/}

device=$2

id=$3

value=$4

log_unhandled() {

   logger "ACPI event unhandled: $*"

}

case "$group" in

   button)

      case $action in

         power)

            /sbin/shutdown -h -t 5 now

            ;;

         # if your laptop doesnt turn on/off the display via hardware

         # switch and instead just generates an acpi event, you can force

         # X to turn off the display via dpms.  note you will have to run

         # 'xhost +local:0' so root can access the X DISPLAY.

         #lid)

         #   xset dpms force off

         #   ;;

         *)   log_unhandled $* ;;

      esac

      ;;

   ac_adapter)

      case "$value" in

         # Add code here to handle when the system is unplugged

         # (maybe change cpu scaling to powersave mode).  For

         # multicore systems, make sure you set powersave mode

         # for each core!

         *0)

            #/etc/acpi/power_level.sh battery

            ;;

         # Add code here to handle when the system is plugged in

         # (maybe change cpu scaling to performance mode).  For

         # multicore systems, make sure you set performance mode

         # for each core!

         *1)

            #/etc/acpi/power_level.sh ac

            ;;

         *)   log_unhandled $* ;;

      esac

      ;;

#   *)   log_unhandled $* ;;

esac

```

Last edited by dmpogo on Fri Nov 28, 2008 12:36 am; edited 2 times in total

----------

## muebi

dmpogo, 

I emerged the xev program. It gives something like this if I move armound with my mouse.

MotionNotify event, serial 31, synthetic NO, window 0x2400001,

    root 0x3a, subw 0x2400002, time 3577816213, (36,39), root:(1228,425),

    state 0x0, is_hint 0, same_screen YES

MotionNotify event, serial 31, synthetic NO, window 0x2400001,

    root 0x3a, subw 0x2400002, time 3577816229, (40,19), root:(1232,405),

    state 0x0, is_hint 0, same_screen YES

EnterNotify event, serial 31, synthetic NO, window 0x2400001,

    root 0x3a, subw 0x0, time 3577816245, (44,3), root:(1236,389),

    mode NotifyNormal, detail NotifyInferior, same_screen YES,

    focus NO, state 0

KeymapNotify event, serial 31, synthetic NO, window 0x0,

    keys:  58  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

LeaveNotify event, serial 31, synthetic NO, window 0x2400001,

    root 0x3a, subw 0x0, time 3577816253, (44,-5), root:(1236,381),

    mode NotifyNormal, detail NotifyNonlinear, same_screen YES,

    focus NO, state 0

I am not sure if this helped to get the sound-control buttons to work...

The section InputDevice of my xorg.conf file looks like this now:

Section "InputDevice"

    Identifier     "Generic Keyboard"

    Driver         "kbd"

    Option         "XkbRules" "xorg"

    Option         "XkbModel" "thinkpad60"

    Option         "XkbLayout" "us"

EndSection

Do you recommend thinkpad60 for a thinkpad W500 or should I put here something different?

And yes, the brightness buttons already worked before changing xorg.conf.Last edited by muebi on Tue Nov 25, 2008 8:23 pm; edited 2 times in total

----------

## muebi

ACPI:

dmpogo, I copy and pasted all the scripts you suggested. I am happy to hear how they work and how to customize them...

Just by curiosity: Should the sh scripts be made executable with chmod? I also wondered why the %e is missing in your second post regarding /etc/acpi/events/lidbtn. Is is correct like that?

----------

## dmpogo

 *muebi wrote:*   

> ACPI:
> 
> dmpogo, I copy and pasted all the scripts you suggested. I am happy to hear how they work and how to customize them...
> 
> Just by curiosity: Should the sh scripts be made executable with chmod? I also wondered why the %e is missing in your second post regarding /etc/acpi/events/lidbtn. Is is correct like that?

 

Yes, shell scripts in /etc/acpi    should be made executable, sorry !

%e is not needed in that script.  it is a shortcut to pass the details of the acpi event to the script (exact codes that you see with acpi_listen),scr

but for lid it is sufficient to know that it is closed/open (more over closed and open does not generate different codes).

Ok, now the questions is what do you want.   What my scripts have now is

in ibm.sh

Fn-F2     - locks the screen with 'alock'.   alock should be installed independently.  Try it if it works !

Fn-F3     - currently unused  (it is marked with 'battery' on my keyboard, so something like force into battery mode may be appropriate)

Fn-F4     - suspend to RAM

Fn-F5     - Siwthces on/off Bluetooth. Currently just hardware radio, since I have not bluetooth devices to set up all services

Fn-F6     - switches on/off  wifi.    This function I use very often and like it.  I do not start wifi on boot, only when required, and then I use Fn-F6

               bonus - any user, not only root can start net.wlan0 service with this keys.

Fn-F7    - toggle internal/external monitors (as icon suggests). It uses separate script, which I have not given you yet (minor modification

              from the one I found on the web)

Fn-F8    - toggles touchpad on and off - try it right now ! (if you have synpatics-like touchpad)

Fn-F9    - suppose to be undock, but I have no dock, unused

Fn-10

Fn-11    - unused

Fn-F12   - hibernate (to disk). I use it very often

The last case is

Hard radio switch on the back - I currently handle it through ACPI events, rather than RFKILL (which I need to understand better)

For suspend/hibernation I use  tuxonice kernel patches and hibernate-script-1.97-r4.    hibernate script works also with in kernel hibernate methods.

Install it, you'll need it

------

lidbtn.sh

This script does the following.  It suspends system to RAM AND writes hibernate image to disk.  So when you open the lid, the

system is resumed from RAM,   but if it runs out of battery (you closed a lid and forgot about it for a week, RAM is still powered in suspend),

you can resume from disk as if after hibernation.    It  uses my own addition to hibernate scripts called /usr/sbin/hibernate-s2both.

It is very trivial but relies on minor modification to hibernate scripts.   If you decide to set hibernation on your machine, we'll go into it.

-----

video.sh

Does just backlight brightness up and down (Fn-Home,   Fn-End)

-----

default.sh

this currently just reacts on power button (on my machine if you press and hold power button, it generates ACPI event after 2-3 sec, and then after 4-5 sec hard shutdowns, the script captures acpi event and calls for shutdown).

Other uses in this file are not active right now.

This is all I have for ACPI governed buttons, 

Not yet handled are blue ThinkVantage button and Fn-Space (zoom screen). For the latter what I have in the script does not work.

So, what do you want to set up ?

----------

## muebi

dmpogo, 

all right. I made the scripts in the /etc/acpi executable. I tried out Fn + F2 (the lock button) after emerging alock but nothing happend. The same story for all other Fn + combinations. I guess there is still something I did wrong. Can you help me?

What do I need to compile into the kernel to get hibernate working?

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> all right. I made the scripts in the /etc/acpi executable. I tried out Fn + F2 (the lock button) after emerging alock but nothing happend. The same story for all other Fn + combinations. I guess there is still something I did wrong. Can you help me?
> 
> What do I need to compile into the kernel to get hibernate working?

 

show me the output of

1) ls -l /etc/acpi/events

2) ls -l /etc/acpi

and

tail /var/log/daemon.log   (if you are using sysklogd)

just after you pressed the button.

I hope you have started acpid daemon ?

/etc/init.d/acpid start

----------

## muebi

dmpogo, 

ls -l /etc/acpi/events gives:

-rw-r--r-- 1 root root 124 Nov 22 16:45 a-ac-aticonfig

-rw-r--r-- 1 root root 132 Nov 22 16:45 a-lid-aticonfig

-rw-r--r-- 1 root root 663 Nov 22 13:37 default

-rw-r--r-- 1 root root  44 Nov 25 21:08 ibm

-rw-r--r-- 1 root root  45 Nov 25 21:08 lidbtn

-rw-r--r-- 1 root root  62 Nov 23 17:03 lm_ac_adapter

-rw-r--r-- 1 root root  58 Nov 23 17:03 lm_battery

-rw-r--r-- 1 root root  58 Nov 23 17:03 lm_lid

-rw-r--r-- 1 root root  70 Nov 22 13:08 pmg_ac_adapter

-rw-r--r-- 1 root root  67 Nov 22 13:08 pmg_battery

-rw-r--r-- 1 root root  41 Nov 25 21:09 video

ls -l /etc/acpi

drwxr-xr-x 2 root root 4096 Nov 23 17:03 actions

-rwxr-xr-x 1 root root 1684 Nov 22 16:45 ati-powermode.sh

-rw-r--r-- 1 root root 1443 Nov 25 21:13 default

-rwxr-xr-x 1 root root 1214 Nov 22 13:37 default.sh

drwxr-xr-x 2 root root 4096 Nov 25 21:09 events

-rwxr-xr-x 1 root root 3041 Nov 25 21:11 ibm.sh

-rwxr-xr-x 1 root root  238 Nov 25 21:11 lidbtn.sh

-rwxr-xr-x 1 root root  316 Nov 25 21:12 video.sh

Acpid is added to the default runlevel and has been started at startup.

I have syslog as far as I know.

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> ls -l /etc/acpi/events gives:
> 
> -rw-r--r-- 1 root root 124 Nov 22 16:45 a-ac-aticonfig
> ...

 

so get me tail /var/log/daemon.log    just after you press Fn-F2

----------

## caspar

Hello dmpogo.

Thank your for the great script. It works nearly flawlessly on my t400. However I adjusted and added some parts.

1. Lock of current X-Session:

I changed your alock-command to the following KDE dbus call which locks the KDE-Session with the configured KDE-Screensaver. This works for me with KDE 4.1.3.

```

su $X_USER -c 'dbus-send --session --dest=org.freedesktop.ScreenSaver \

           --type=method_call --print-reply /ScreenSaver \

           org.freedesktop.ScreenSaver.Lock'

```

Furthermore I noticed that if you copy-paste your script,

```

su $X_USER -c 'alock -bg shade:shade=20 -cursor theme:name=xtr -

auth pam' 

```

ends up in two lines, which makes the alock command unusable. The whole command should be placed in one line. Maybe this is the problem with your setup muebi?

2. Additional Events added:

```

   00001009)

      # Fn-F9 should make the IBM-Thinkpad ready for Undocking

      ;;   

   00001018)

      # ThinkVantage currently does nothing

      ;;

   00006030)

      # Dock/Undock event currently does nothing (the one at the docking station; not sure about this one)

      ;; 

```

@muebi

Maybe the script does not work for you because your notebook produces different event ids. You can easily verify the IDs with the 'acpi_listen'-command as root. Execute it and press the key combinations afterwards. You should see output like 'ibm/hotkey HKEY 00000080 00001009' for each key combination. The last number column ist the number which has to be placed into dmpogo's scripts before a bracket.

Hope this helps..

Furthermore a question remains:

I saw that you use a "/usr/local/sbin/thinkpad-fn-f7 toggle" script in your posted script. Is there a chance that you post that in here, too?

Thanks for your great work.

Regards,

caspar

----------

## dmpogo

caspar:

Thanks  for using it - the credit goes to many people I picked up pieces from !

I did notice that the lines are cut during the paste, and while posting tried to correct them by hand, but, as you found, missed some.

thnikpad-fn7 script is really not my at all, so I should take no credits.  One thing is, I pulled X setup from the original, and has all Xauthority settings in my ibm.sh

The script relies on the fact that your Virtual in xorg.conf is set so that the space for the other monitor is in horizontal direction (i.e say to the left) 

of the LCD

i.e like    Virtual   2048x786 for a pair of 1024x768   screens       

Note comment out line in the 'mirror' function - I did not settle on what is best, depends whethere external monitor is same size,

larger or smaller LCD.

So here it is, be careful with wrapped lines.

/usr/local/sbin/thinkpad-fn-f7

```

#!/bin/bash

# External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"

EXTERNAL_OUTPUT="VGA"

INTERNAL_OUTPUT="LVDS"

EXTERNAL_LOCATION="left"

  

case "$EXTERNAL_LOCATION" in

     left|LEFT)

                EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"

               ;;

     right|RIGHT)

                EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"

               ;;

     top|TOP|above|ABOVE)

                EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"

               ;;

     bottom|BOTTOM|below|BELOW)

                EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"

               ;;

     *)

                EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"

               ;;

esac

# Figure out current state

INTERNAL_STATE=$( xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")

EXTERNAL_STATE=$( xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")

 

if [ -z "$INTERNAL_STATE" ]; then

     STATE="external"

elif [ -z "$EXTERNAL_STATE" ]; then

     STATE="internal"

else

     INTERNAL_STATE=$(echo $INTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")

     EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")

     if [ "$INTERNAL_STATE" = "$EXTERNAL_STATE" ]; then

           STATE="mirror"

     else

           STATE="both"

     fi

fi

function screen_external(){

       xrandr --output $INTERNAL_OUTPUT --off

       xrandr --output $EXTERNAL_OUTPUT --auto

}

function screen_internal(){

       xrandr --output $EXTERNAL_OUTPUT --off

       xrandr --output $INTERNAL_OUTPUT --auto

}

function screen_mirror(){

       xrandr --output $INTERNAL_OUTPUT --auto

#       xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT

       xrandr --output $EXTERNAL_OUTPUT --auto

}

function screen_both(){

       xrandr --output $INTERNAL_OUTPUT --auto

       xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION

}

function screen_toggle(){

       case "$STATE" in

             internal)

                     screen_mirror

                     ;;

               mirror)

                     screen_external

                     ;;

             external)

                     screen_internal

                     ;;

                 *)

                     screen_internal

                     ;;

        esac

}

# What should we do?

DO="$1"

if [ -z "$DO" ]; then

      if [ $(basename $0) = "thinkpad-fn-f7" ]; then

           DO="toggle"

      fi

fi

    

case "$DO" in

      toggle)

              screen_toggle

              ;;

    internal)

              screen_internal

              ;;

    external)

              screen_external

              ;;

      mirror)

         screen_mirror

         ;;

   both)

         screen_both

         ;;

      status)

              echo "Current Fn-F7 state is: $STATE"

              echo

              echo "Attached monitors:"

              xrandr | grep "\Wconnected" | sed "s/^/ /"

              ;;

        *)

              echo "usage: $0 <command>" >&2

              echo >&2

              echo "  commands:" >&2

              echo "          status" >&2

              echo "          internal" >&2

              echo "          external" >&2

              echo "          mirror" >&2

              echo "          both" >&2

              echo "          toggle" >&2

              echo >&2

              ;;

esac

```

----------

## muebi

dmpogo, 

tail /var/log/messages gives the following after pressing Fn + F2:

Nov 28 10:26:08 aitken acpid: action exited with status 127

Nov 28 10:26:08 aitken acpid: executing action "/etc/acpi/default.sh ibm/hotkey HKEY 00000080 00001002"

Nov 28 10:26:08 aitken logger: ACPI event unhandled: ibm/hotkey HKEY 00000080 00001002

Nov 28 10:26:08 aitken acpid: action exited with status 0

Nov 28 10:26:08 aitken acpid: completed event "ibm/hotkey HKEY 00000080 00001002

----------

## caspar

 *muebi wrote:*   

> dmpogo, 
> 
> tail /var/log/messages gives the following after pressing Fn + F2:
> 
> Nov 28 10:26:08 aitken acpid: action exited with status 127
> ...

 

Please read my post.

Regards,

caspar

----------

## dmpogo

 *caspar wrote:*   

>  *muebi wrote:*   dmpogo, 
> 
> tail /var/log/messages gives the following after pressing Fn + F2:
> 
> Nov 28 10:26:08 aitken acpid: action exited with status 127
> ...

 

muebi,   you cat your acpid log a bit too short. It shows only the lines that the handling went to 'default.sh'.

There should be also lines  with  executing action /etc/acpi/ibm.sh    I guess they were above, and it is that action that

```

Nov 28 10:26:08 aitken acpid: action exited with status 127

```

which indicate that ibm.sh exited with error code while handling this (exit code must be zero for success)

caspar was right finding a syntax error in Fn-F2 handling which appeared when I  paste the ibm.sh.    I have corrected it in the original post above.

Please correct it and redo Fn-F2. 

If alock is still not working, post something like 15 last lines of the log, to see if it went to process ibm.sh at all

----------

## muebi

dmpogo and caspar, 

thanks for your imput Fn + F2 works now. I can lock the screen. The reason really was the alock line as you discovered.

Can you explain what I need to get the hibernate working. I could not entirely follow you from your above post.

I still have a problem with my audio control keys. They do not seem to work.

Is there a way to get the laptop to shutdown when the lid is closed?

Are there any control panels which one could make pop up such as in Ubuntu when e.g. the brightness or sound keys are pressed - just for visualization? 

Sorry for the many questions!

----------

## dmpogo

 *muebi wrote:*   

> dmpogo and caspar, 
> 
> thanks for your imput Fn + F2 works now. I can look the screen. 
> 
> 

 

Great, so the basic functionality is there.

 *Quote:*   

> 
> 
> Can you explain what I need to get the hibernate working. I could not entirely follow you from your above post.
> 
> 

 

And you could not, since it was never explained  :Smile:  ,   We'll do it

 *Quote:*   

> 
> 
> I still have a problem with my audio control keys. They do not seem to work.
> 
> 

 

This is a different story, as a first step make sure you have keyboard model "thinkpad60" in xorg.conf

 *Quote:*   

> 
> 
> Is there a way to get the laptop to shutdown when the lid is closed?
> 
> 

 

This is easy, and can be done right away.  Go to /etc/acpi/lidbtn.sh

and replace 

/usr/sbin/hibernate-s2both

by

/sbin/shutdown -h now

you can also kill echo lines.    Try it, and then we get to audio keys and hibernation (I'm a bit busy at work now)

----------

## muebi

dmpogo, 

shutdown at lid close works. I am ready for the other stuff  :Smile: 

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> shutdown at lid close works. I am ready for the other stuff 

 

OK, let us work on hibernate.

1. In any case it is useful to have  "hibernate-script" .  Install this package

2. There are 3 methods to do hibernation (and hibernate-script work with all of them)

    a)  In-kernel one, sysfs-based 

    b) tuxonice - a fork of kernel-based one, known before as suspend2

    c) User space one,   ususpend

The easiest one to setup is the first.   Many people swear by tuxonice and it is the one I use. However it requires patching the kernel, and 

it essentialy replaces the functuanality of in-kernel modules by enhanced one (there is an option to keep both system in parallel)

I have no experience with userspace ususpend,  and I am suspiciious about userspace tools in such matter.

So what should we do ? Your choice.   The tuxonice patching of the kernel is not difficult if you use 2.6.25-27 kernels, but i don't know if the paches for .28 already exist, and then everytime you update the kernel you need to remember to patch it.  But in my experience it works great.

----------

## muebi

dmpogo, 

I guess I would prefer the kernel version. My current kernel is 2.6.27.6

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> I guess I would prefer the kernel version. My current kernel is 2.6.27.6

 

OK, check

cat /sys/power/state

Do you have this file,   does cat read  'mem disk' ?

if yes, run 

hibernate-ram

did it go to sleep ? (press power button SHORTLY  to wake up)

----------

## caspar

[quote="dmpogo"] *muebi wrote:*   

> dmpogo, 
> 
> So what should we do ? Your choice.   The tuxonice patching of the kernel is not difficult if you use 2.6.25-27 kernels, but i don't know if the paches for .28 already exist, and then everytime you update the kernel you need to remember to patch it.  But in my experience it works great.

 

You do not need to patch the kernel yourself. Simply merge "tuxonice-sources" on gentoo. They contain the current tuxonice patchset.

Regards, caspar.

----------

## dmpogo

[quote="caspar"] *dmpogo wrote:*   

>  *muebi wrote:*   dmpogo, 
> 
> So what should we do ? Your choice.   The tuxonice patching of the kernel is not difficult if you use 2.6.25-27 kernels, but i don't know if the paches for .28 already exist, and then everytime you update the kernel you need to remember to patch it.  But in my experience it works great. 
> 
> You do not need to patch the kernel yourself. Simply merge "tuxonice-sources" on gentoo. They contain the current tuxonice patchset.
> ...

 

Unfortunately they are at 2.6.24 for stable and 2.6.26 ~amd64.   

2.6.26 would not be too bad,  but it would involve step down for muebi.

----------

## caspar

[quote="dmpogo"] *caspar wrote:*   

>  *dmpogo wrote:*    *muebi wrote:*   dmpogo, 
> 
> So what should we do ? Your choice.   The tuxonice patching of the kernel is not difficult if you use 2.6.25-27 kernels, but i don't know if the paches for .28 already exist, and then everytime you update the kernel you need to remember to patch it.  But in my experience it works great. 
> 
> You do not need to patch the kernel yourself. Simply merge "tuxonice-sources" on gentoo. They contain the current tuxonice patchset.
> ...

 

Also true.

I was a longterm user of tuxonice but switched to suspend for compliance with pm-utils. Anyway.. Each solutions has its assets and drawbacks. Tuxonice in combination with hibernate-script can e.g. use framebuffer devices for a fancier hibernation and pm-suspend (with suspend) can be called directly from kpowersave etc. 

It's your choice. That's the advantage of linux  :Smile: .

Have a nice weekend.

caspar

----------

## muebi

dmpogo, 

hibernate-ram worked. It went to sleep. However, when I try to wake it up (press power shortly) it seems to reanimate but the screen stays dark...

BTW, I don't like the idea of downgrading my kernel since I need it to get many other things working.

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> hibernate-ram worked. It went to sleep. However, when I try to wake it up (press power shortly) it seems to reanimate but the screen stays dark...
> 
> BTW, I don't like the idea of downgrading my kernel since I need it to get many other things working.

 

OK, first of all we know that suspend and hibernation is compiled into the kernel.   Bost mem and disk exists in /sys/power/state, right ?

There are some config files in /etc/hibernate to  play with.

But first of all:   

1) go to console,    try hibernate-ram - did it came back ?

2) if no, stop  /etc/init.d/xdm stop,     did it work  now ?

3) if no, stop network (especially wireless and bluetooth) service, try again 

4) if no, unload wireless and network modules, try 

let me know the results

----------

## muebi

dmpogo, 

in principle I think it works. The problem is that the screen stays black after wake-up no matter what I do or from where I execute the hibernate-ram command.

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> in principle I think it works. The problem is that the screen stays black after wake-up no matter what I do or from where I execute the hibernate-ram command.

 

This is not right, OK, let us edit a bit /etc/hibernate/hibernate.conf

In top section, have

Distribution gentoo

lower find and have set

### hardware_tweaks

IbmAcpi yes

try now.

also, see that logging is on,  and post the content of /var/log/hibernate.log after the attempt

----------

## muebi

dmpogo,

maybe I missed something but this is how it looks at the moment:

# hibernate.conf is split into separate configuration files.

#

# Each file is tried in the order below, until an available suspend

# method is found.

#

# Options specific to a particular suspend method should be placed in the

# appropriate configuration file (suspend2.conf, ususpend.conf, disk.conf

# or ram.conf).

# Options common to all suspend methods should be placed in common.conf.

#

# See hibernate.conf(5) for help on the configuration items.

TryMethod suspend2.conf

TryMethod disk.conf

TryMethod ram.conf

----------

## dmpogo

 *muebi wrote:*   

> dmpogo,
> 
> maybe I missed something but this is how it looks at the moment:
> 
> # hibernate.conf is split into separate configuration files.
> ...

 

sorry, I meant /etc/hinbernate/common.conf

----------

## muebi

dmpogo, 

I modified the file but the problem remains  :Sad: . This is how it looks at the moment:

# Configuration options common for suspending to disk or RAM.

# Options are not case sensitive.

#

# See hibernate.conf(5) for help on the configuration items.

##############################################################################

### Some global settings

##############################################################################

Verbosity 0

LogFile /var/log/hibernate.log

LogVerbosity 1

# LogTimestamp yes

# AlwaysForce yes

# AlwaysKill yes

# HibernateVT 15

Distribution gentoo

# XDisplay :0

##############################################################################

### Scriptlets

###   Scriptlets provide support for doing all sorts of things before and after

###   suspending. The defaults settings here should work for most people, but

###   you may wish to edit these to taste. Consult "hibernate -h" for help on

###   the configuration settings.

##############################################################################

### bootsplash

## If you use bootsplash, also enabling SwitchToTextMode is recommended if

## you use X, otherwise you may end up with a garbled X display.

# Bootsplash on

# BootsplashConfig /etc/bootsplash/default/config/bootsplash-1024x768.cfg

### clock

SaveClock restore-only

### devices

# IncompatibleDevices /dev/dsp /dev/video*

### diskcache

# DisableWriteCacheOn /dev/hda

### fbsplash (enable SwitchToTextMode if you use this)

# FBSplash on

# FBSplashTheme suspend2

### filesystems

# Unmount /nfsshare /windows /mnt/sambaserver

# UnmountFSTypes smbfs nfs

# UnmountGraceTime 1

# Mount /windows

### grub

# ChangeGrubMenu yes

# GrubMenuFile /boot/grub/menu.lst

# AlternateGrubMenuFile /boot/grub/menu-suspended.lst

# BackupGrubMenuFile /boot/grub/menu.lst.hibernate.bak

# see http://bugs.debian.org/317479

# RemountXFSBoot yes

### hardware_tweaks

IbmAcpi yes

# RadeonTool yes

# Runi915resolution yes

# FullSpeedCPU yes

### lilo

# EnsureLILOResumes yes

### lock (generally you only want one of the following options)

## For console you need vlock available.

## For x you need xscreensaver-command-command available.

## For gnome you need gnome-screensaver-command available.

## For kde you need dcop, kscreensaver available.

## For XAuto you need xautolock available.

## For Xtr you need xtrlock available.

# LockConsoleAs root

# LockXScreenSaver yes

# LockGnomeScreenSaver yes

# LockKDE yes

# LockXLock yes

# LockXAutoLock yes

# LockXtrLock yes

### misclaunch

# OnSuspend 20 echo "Good night!"

# OnResume 20 echo "Good morning!"

### modules

# UnloadModules snd_via82cxxx usb-ohci

# UnloadAllModules yes

UnloadBlacklistedModules yes

LoadModules auto

# LoadModulesFromFile /etc/modules

### modules-gentoo

# GentooModulesAutoload yes

### network

# DownInterfaces eth0

# UpInterfaces auto

### networkmanager

# EnableNMReconnect yes

### pause_audio

# MuteAudio yes

# PauseAudio yes

### pcmcia

# EjectCards yes

### programs

# IncompatiblePrograms xmms

### services

# RestartServices laptop_mode anacron

# StopServices alsasound

# StartServices aumix

### vbetool

# EnableVbetool yes

# RestoreVbeStateFrom /var/lib/vbetool/vbestate

# VbetoolPost yes

# RestoreVCSAData yes

### xhacks

SwitchToTextMode yes

# UseDummyXServer yes

# DummyXServerConfig xorg-dummy.conf

### xstatus

## This can be set to gnome, kde or x:

## For gnome you need zenity available.

## For kde you need dcop, kstart, kdialog available.

## For x you need to have xosd OR xmessage available.

# XStatus gnome

# XmessageDisable yes

# XSuspendText Preparing to suspend...

# XResumeText Resuming from suspend...

## When using XStatus x, and you have xosd installed:

# XosdSettings --font '-misc-fixed-medium-r-semicondensed--*-120-*-*-c-*-*-*' --colour=Green --shadow 1 --pos b$

### xbacklight

# BackLight yes

### gaim

## You need to have dbus, gaim_remote available.

# LogoutGaim yes

# GaimRestoreStatus yes

# GaimLogoutMessage Hibernating

# GaimLoginMessage Back from hibernation

----------

## dmpogo

Ok, I need two things

1) cat /proc/modules

2) cat /var/log/hibernate.log 

after suspend cycle.

----------

## dmpogo

Also, what framebuffer are you using, if any (vesafb, intelfb, uvesafb) ?

And, after you get your screen on after resume, does it look like other things resumed all right ? I.e is it only backlight not coming back ?

----------

## muebi

dmpogo, 

I have compiled all modules in the kernel.

cat /proc/modules gives:

fglrx 2070024 0 - Live 0xffffffffa0000000 (P)

In my xorg.cong I have the following:

Section "Module"

    Load           "dbe"

    Load           "extmod"

    Load           "fbdevhw"

    Load           "glx"

    Load           "record"

    Load           "freetype"

    Load           "type1"

EndSection

cat /var/log/hibernate.log gives:

Starting suspend at Mon Dec 1 21:51:56 CET 2008

hibernate-ram: [01] Executing CheckLastResume ... 

hibernate-ram: [01] Executing CheckRunlevel ... 

hibernate-ram: [01] Executing LockFileGet ... 

hibernate-ram: [01] Executing NewKernelFileCheck ... 

hibernate-ram: [10] Executing EnsureSysfsPowerStateCapable ... 

hibernate-ram: [11] Executing XHacksSuspendHook1 ... 

hibernate-ram: [12] Executing IbmAcpiStartSuspend ... 

hibernate-ram: [59] Executing RemountXFSBootRO ... 

hibernate-ram: [89] Executing SaveKernelModprobe ... 

hibernate-ram: [91] Executing ModulesUnloadBlacklist ... 

hibernate-ram: [91] Executing ModulesUnloadBlacklist ... 

hibernate-ram: [95] Executing XHacksSuspendHook2 ... 

hibernate-ram: [98] Executing CheckRunlevel ... 

hibernate-ram: [99] Executing DoSysfsPowerStateSuspend ... 

hibernate-ram: Activating sysfs power state mem ...

hibernate-ram: [90] Executing ModulesLoad ... 

hibernate-ram: [89] Executing RestoreKernelModprobe ... 

hibernate-ram: [85] Executing XHacksResumeHook2 ... 

hibernate-ram: [70] Executing ClockRestore ... 

hibernate-ram: [70] Executing ClockRestore ... 

hibernate-ram: [59] Executing RemountXFSBootRW ... 

hibernate-ram: [12] Executing IbmAcpiEndResume ... 

hibernate-ram: [11] Executing XHacksResumeHook1 ... 

hibernate-ram: [01] Executing NoteLastResume ... 

hibernate-ram: [01] Executing LockFilePut ... 

Resumed at Mon Dec 1 21:52:16 CET 2008

Yes, it looks like other things resume all right just the backlight is not coming back.

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> I have compiled all modules in the kernel.
> 
> cat /proc/modules gives:
> ...

 

That's not good. Some subsystems are known not to hibernate well, and one should usually have then as modules to get

hibernation robust (especially hibernation to disk, which we have not tried yet).

I would strongly advice to recompile as modules

1) wireless   (iwlagn ?)

2) network   (e1000, e1000e ?? )

3) bluetooth  (everything related to it, bluetooth, btusb, )

4) usb         (uhci_hcd, ehci_hcd)

5) usb camera if yo have built in one (uvcvideo ?) 

6) thinkpad_acpi

I usually have all sound as modules, but I did not find it critical for hibernation.

When I was asking about framebuffer, the question was what runs your console.

Could you tell me what parameters the boot line in /boot/grub/grub.conf has ?

----------

## muebi

do you mean this:

title Gentoo Linux, kernel test 64bit with ALSA, ACPI, CDROM

root (hd0,0)

kernel /kernel-test_64_alsa_acpi_cdrom root=/dev/sda4

----------

## dmpogo

 *muebi wrote:*   

> do you mean this:
> 
> title Gentoo Linux, kernel test 64bit with ALSA, ACPI, CDROM
> 
> root (hd0,0)
> ...

 

That's the one.   Nothing else on

kernel /kernel-test_64_alsa_acpi_cdrom root=/dev/sda4

right ?

----------

## muebi

dmpogo, 

I have a few other kernels as well but this is the one where I got most of my hardware working.

----------

## m_gustafsson

Sorry to interrupt, but I have one issue when trying to follow your discussion.

I don't get any readings when pressing FN Home and FN End when running acpi_listen, all other function keys seem to be ok. This was working before I upgraded to the 2.6.26-r3 kernel from a 2.6.25 kernel.

Do you have any ideas on what the reason behind that problem could be?

Many thanks.

----------

## dmpogo

 *m_gustafsson wrote:*   

> Sorry to interrupt, but I have one issue when trying to follow your discussion.
> 
> I don't get any readings when pressing FN Home and FN End when running acpi_listen, all other function keys seem to be ok. This was working before I upgraded to the 2.6.26-r3 kernel from a 2.6.25 kernel.
> 
> Do you have any ideas on what the reason behind that problem could be?
> ...

 

Are these supposed to be brightness keys on your laptop ?

if yes, do you have ACPI_VIDEO enabled in kernel ?

what does  

```

gunzip -c  /proc/config.gz | grep VIDEO   

```

give ?

----------

## m_gustafsson

Yes, those are the brightness keys.

I have the THINKPAD_ACPI_VIDEO enabled, but not ACPI_VIDEO:

```
# gunzip -c  /proc/config.gz | grep VIDEO

# CONFIG_ACPI_VIDEO is not set

CONFIG_THINKPAD_ACPI_VIDEO=y

# CONFIG_IEEE1394_VIDEO1394 is not set

# CONFIG_VIDEO_DEV is not set

# CONFIG_VIDEO_MEDIA is not set

CONFIG_VIDEO_OUTPUT_CONTROL=m

CONFIG_VIDEO_SELECT=y

```

Should I try with ACPI_VIDEO as well?

----------

## dmpogo

 *m_gustafsson wrote:*   

> Yes, those are the brightness keys.
> 
> I have the THINKPAD_ACPI_VIDEO enabled, but not ACPI_VIDEO:
> 
> ```
> ...

 

You should, and you can disable THINKPAD_ACPI_VIDEO.

If both are compiled,  THINKPAD_ACPI_VIDEO will be disabled on boot anyway, with a note in dmesg that ACPI_VIDEO is much prefered.

Even kernel config help says that VIDEO support in THINKPAD_ACPI often does not work and one should use ACPI_VIDEO if at all possible.

You should also check that 

CONFIG_LCD_CLASS_DEVICE=m

CONFIG_BACKLIGHT_CLASS_DEVICE=y

are enabled (but ACPI_VIDEO option will not even appear without them)

----------

## m_gustafsson

 *Quote:*   

> You should, and you can disable THINKPAD_ACPI_VIDEO.
> 
> If both are compiled, THINKPAD_ACPI_VIDEO will be disabled on boot anyway, with a note in dmesg that ACPI_VIDEO is much prefered.
> 
> Even kernel config help says that VIDEO support in THINKPAD_ACPI often does not work and one should use ACPI_VIDEO if at all possible.
> ...

 

I changed my kernel, and now it looks like:

```
# CONFIG_THINKPAD_ACPI_VIDEO is not set

CONFIG_ACPI_VIDEO=m

CONFIG_LCD_CLASS_DEVICE=y

CONFIG_BACKLIGHT_CLASS_DEVICE=y
```

Don't know if it matters that I missed to change CONFIG_LCD_CLASS_DEVICE to a module?

Anyway, now acpi_listen reacts to the brightness keys, but I also noticed that the key mappings now differ quite much from before. This is what I see now (nothing on the other keys):

```
F4 button/sleep SLPB 00000080 00000004

F5 nothing but it affects the Bluetooth led

F7 video VID 00000080 00000000

End video LCD0 00000087 00000000

Home video LCD0 00000086 00000000
```

While previous I saw (like described in an earlier post by muebi):

```
F1 ibm/hotkey HKEY 00000080 00001001

F2 ibm/hotkey HKEY 00000080 00001002

F3 ibm/hotkey HKEY 00000080 00001003

F4 ibm/hotkey HKEY 00000080 00001004

F5 ibm/hotkey HKEY 00000080 00001005

F6 ibm/hotkey HKEY 00000080 00001006

F7 ibm/hotkey HKEY 00000080 00001007

F8 ibm/hotkey HKEY 00000080 00001008

F9 ibm/hotkey HKEY 00000080 00001009

F10 nothing

F11 ibm/hotkey HKEY 00000080 0000100b

F12 ibm/hotkey HKEY 00000080 0000100c

F Home nothing

F End nothing
```

I guess that this change does not matter, as I just have to adjust in the scripts for those new values.

Brightness adjustments does not work, but I guess that is due to that my brightness file, used in /etc/acpi/video.sh is located in a different place than the path used in the script:

```
# find / -iname brightness

/proc/acpi/video/VID1/CRT0/brightness

/proc/acpi/video/VID1/LCD0/brightness

/proc/acpi/video/VID/CRT0/brightness

/proc/acpi/video/VID/LCD0/brightness

/sys/class/backlight/acpi_video0/brightness

/sys/class/backlight/acpi_video1/brightness

/sys/class/leds/mmc0/brightnes
```

I will try them out to see if anyone of them might work.

And by the way, "hibernate" now works   :Very Happy: 

When trying "hibernate-ram" I think I see the same problem as muebi, it goes to sleep but cannot be brought up again. Then it just stops with a black screen and the moon led flashing. 

Many thanks for your support   :Very Happy:  I will try not to interrupt your discussion again, sorry for this.

----------

## muebi

m_gustafsson, 

yes, I have the same problem with hibernate-ram than you. It's good that I am not the only one with this problem. Maybe we can solve this problem together.

----------

## dmpogo

 *m_gustafsson wrote:*   

>  *Quote:*   You should, and you can disable THINKPAD_ACPI_VIDEO.
> 
> If both are compiled, THINKPAD_ACPI_VIDEO will be disabled on boot anyway, with a note in dmesg that ACPI_VIDEO is much prefered.
> 
> Even kernel config help says that VIDEO support in THINKPAD_ACPI often does not work and one should use ACPI_VIDEO if at all possible.
> ...

 

Well, you have disabled ALL thinkpad_acpi (or have not loaded it). You should have disabled only VIDEO option of THINKPAD_ACPI module.

Moon led flashing means it is suspended, you should press power button to bring it back (but not for too long so as not to power down the machine)

----------

## m_gustafsson

muebi wrote:

 *Quote:*   

> yes, I have the same problem with hibernate-ram than you. It's good that I am not the only one with this problem. Maybe we can solve this problem together.

 

Good idea   :Very Happy: 

dmpogo wrote:

 *Quote:*   

> Well, you have disabled ALL thinkpad_acpi (or have not loaded it). You should have disabled only VIDEO option of THINKPAD_ACPI module. 

 

Ok, I think that I am a bit confused about modules etc. Anyway, I added thinkpad_acpi and thinkpad into /etc/modules.autoload.d/kernel-2.6.

Now the function keys seem to be there again:

```
$ acpi_listen 

ibm/hotkey HKEY 00000080 00001001

ibm/hotkey HKEY 00000080 00001002

ibm/hotkey HKEY 00000080 00001003

ibm/hotkey HKEY 00000080 00001004

ibm/hotkey HKEY 00000080 00001005

ibm/hotkey HKEY 00000080 00001006

ibm/hotkey HKEY 00000080 00001007

ibm/hotkey HKEY 00000080 00001008

ibm/hotkey HKEY 00000080 00001009

ibm/hotkey HKEY 00000080 0000100b

ibm/hotkey HKEY 00000080 0000100c

video LCD0 00000086 00000000

ibm/hotkey HKEY 00000080 00005010

video LCD0 00000087 00000000

ibm/hotkey HKEY 00000080 00005010
```

FN+Home and FN+End now generates two printouts, e.g. for FN+Home I get video LCD0 00000086 00000000

and ibm/hotkey HKEY 00000080 00005010.

I then tried:

```
# hibernate-ram
```

The computer then stops, with the "moon" lit (not flashing).

When pressing the power button it starts but hangs with black screen and the moon flashing.

```
# cat /var/log/hibernate.log

...

Starting suspend at Fri Dec 5 08:29:40 CET 2008

hibernate-ram: [01] Executing CheckLastResume ... 

hibernate-ram: [01] Executing CheckRunlevel ... 

hibernate-ram: [01] Executing LockFileGet ... 

hibernate-ram: [01] Executing NewKernelFileCheck ... 

hibernate-ram: [10] Executing EnsureSysfsPowerStateCapable ... 

hibernate-ram: [11] Executing XHacksSuspendHook1 ... 

hibernate-ram: [12] Executing IbmAcpiStartSuspend ... 

hibernate-ram: [20] Executing MiscLaunchAuxFunc1 ... 

Executing echo "Good night!"...

Good night!

hibernate-ram: [20] Executing MiscLaunchAuxFunc3 ... 

Executing echo "Good night!"...

Good night!

hibernate-ram: [59] Executing RemountXFSBootRO ... 

hibernate-ram: [61] Executing NMSuspend ... 

hibernate-ram: [89] Executing SaveKernelModprobe ... 

hibernate-ram: [91] Executing LockGnomeScreensaver ... 

hibernate-ram: [91] Executing ModulesUnloadBlacklist ... 

hibernate-ram: [91] Executing ModulesUnloadBlacklist ... 

hibernate-ram: [95] Executing XHacksSuspendHook2 ... 

hibernate-ram: [98] Executing CheckRunlevel ... 

hibernate-ram: [99] Executing DoSysfsPowerStateSuspend ... 

hibernate-ram: Activating sysfs power state mem ...
```

When trying hibernate the computer hangs with black screen and moon flashing.

```
# hibernate
```

```
# cat /var/log/hibernate.log

...

Starting suspend at Fri Dec 5 08:36:16 CET 2008

hibernate: [01] Executing CheckLastResume ... 

hibernate: [01] Executing CheckRunlevel ... 

hibernate: [01] Executing LockFileGet ... 

hibernate: [01] Executing NewKernelFileCheck ... 

hibernate: [10] Executing EnsureSysfsPowerStateCapable ... 

hibernate: [11] Executing XHacksSuspendHook1 ... 

hibernate: [12] Executing IbmAcpiStartSuspend ... 

hibernate: [20] Executing MiscLaunchAuxFunc1 ... 

Executing echo "Good night!"...

Good night!

hibernate: [20] Executing MiscLaunchAuxFunc3 ... 

Executing echo "Good night!"...

Good night!

hibernate: [59] Executing RemountXFSBootRO ... 

hibernate: [61] Executing NMSuspend ... 

hibernate: [89] Executing SaveKernelModprobe ... 

hibernate: [91] Executing LockGnomeScreensaver ... 

hibernate: [91] Executing ModulesUnloadBlacklist ... 

hibernate: [91] Executing ModulesUnloadBlacklist ... 

hibernate: [95] Executing XHacksSuspendHook2 ... 

hibernate: [98] Executing CheckRunlevel ... 

hibernate: [99] Executing DoSysfsPowerStateSuspend ... 

hibernate: Activating sysfs power state disk ...
```

I tried to tweak some of the settings in /etc/hibernate/common.conf, but with no success.

```
# cat /etc/hibernate/common.conf 

# Configuration options common for suspending to disk or RAM.

# Options are not case sensitive.

# 

# See hibernate.conf(5) for help on the configuration items.

##############################################################################

### Some global settings

##############################################################################

Verbosity 0

LogFile /var/log/hibernate.log

LogVerbosity 1

# LogTimestamp yes

# AlwaysForce yes

# AlwaysKill yes

# HibernateVT 15

Distribution gentoo

# XDisplay :0

##############################################################################

### Scriptlets

###   Scriptlets provide support for doing all sorts of things before and after

###   suspending. The defaults settings here should work for most people, but

###   you may wish to edit these to taste. Consult "hibernate -h" for help on

###   the configuration settings.

##############################################################################

### bootsplash

## If you use bootsplash, also enabling SwitchToTextMode is recommended if

## you use X, otherwise you may end up with a garbled X display.

# Bootsplash on

# BootsplashConfig /etc/bootsplash/default/config/bootsplash-1024x768.cfg

### clock

SaveClock restore-only

### devices

# IncompatibleDevices /dev/dsp /dev/video*

### diskcache

# DisableWriteCacheOn /dev/hda

### fbsplash (enable SwitchToTextMode if you use this)

# FBSplash on

# FBSplashTheme suspend2

### filesystems

# Unmount /nfsshare /windows /mnt/sambaserver

# UnmountFSTypes smbfs nfs

# UnmountGraceTime 1

# Mount /windows

### grub

# ChangeGrubMenu yes

# GrubMenuFile /boot/grub/menu.lst

# AlternateGrubMenuFile /boot/grub/menu-suspended.lst

# BackupGrubMenuFile /boot/grub/menu.lst.hibernate.bak

# see http://bugs.debian.org/317479

# RemountXFSBoot yes

### hardware_tweaks

IbmAcpi yes

# RadeonTool yes

# Runi915resolution yes

# FullSpeedCPU yes

### lilo

# EnsureLILOResumes yes

### lock (generally you only want one of the following options)

## For console you need vlock available.

## For x you need xscreensaver-command-command available.

## For gnome you need gnome-screensaver-command available.

## For kde you need dcop, kscreensaver available.

## For XAuto you need xautolock available.

## For Xtr you need xtrlock available.

# LockConsoleAs root

# LockXScreenSaver yes

LockGnomeScreenSaver yes

# LockKDE yes

# LockXLock yes

# LockXAutoLock yes

# LockXtrLock yes

### misclaunch

OnSuspend 20 echo "Good night!"

OnResume 20 echo "Good morning!"

### modules

# UnloadModules snd_via82cxxx usb-ohci

# UnloadAllModules yes

UnloadBlacklistedModules yes

LoadModules auto

# LoadModulesFromFile /etc/modules

### modules-gentoo

GentooModulesAutoload yes

### network

#DownInterfaces eth0

#DownInterfaces eth1

#UpInterfaces auto

### networkmanager

EnableNMReconnect yes

### pause_audio

# MuteAudio yes

# PauseAudio yes

### pcmcia

# EjectCards yes

### programs

# IncompatiblePrograms xmms

### services

# RestartServices laptop_mode anacron

# StopServices alsasound

# StartServices aumix

### vbetool

# EnableVbetool yes

# RestoreVbeStateFrom /var/lib/vbetool/vbestate

# VbetoolPost yes

# RestoreVCSAData yes

### xhacks

SwitchToTextMode yes

# UseDummyXServer yes

# DummyXServerConfig xorg-dummy.conf

### xstatus

## This can be set to gnome, kde or x:

## For gnome you need zenity available.

## For kde you need dcop, kstart, kdialog available.

## For x you need to have xosd OR xmessage available.

# XStatus gnome

# XmessageDisable yes

# XSuspendText Preparing to suspend...

# XResumeText Resuming from suspend...

## When using XStatus x, and you have xosd installed:

# XosdSettings --font '-misc-fixed-medium-r-semicondensed--*-120-*-*-c-*-*-*' --colour=Green --shadow 1 --pos bottom --align center --offset 50

### xbacklight

# BackLight yes

### gaim

## You need to have dbus, gaim_remote available.

# LogoutGaim yes

# GaimRestoreStatus yes

# GaimLogoutMessage Hibernating

# GaimLoginMessage Back from hibernation
```

----------

## dmpogo

Typically, if the hibernate does not work, it is the question of some harware sybsytem hanging.  The solution is usually to compile the drivers for these subsystems as modules and instruct the hibernate script to unload those modules before the hibernation and, perhaps, load them 

back on resume.

Classical modules that sometimes do not hibernate well are usb (ehci_hcd, uhci_hcd/ohci_hcd), perhaps bluetooth, wifi and wired network,

and sometimes video driver (if there is a kernel module associtate with it, like for nvidia).

hibenrate script has a rather extensive infrastructure to do that

```

### modules

# UnloadModules snd_via82cxxx usb-ohci

# UnloadAllModules yes

UnloadBlacklistedModules yes

LoadModules auto

# LoadModulesFromFile /etc/modules 

```

here you have

UnloadBlacklistedModules - there is a whole file with the list of modules known to cause troubles within specified range of kernels.

                                                  look into blacklist file to see what is there

UnloadModules -  list of modules you want to unload, in the order of their unload.  I have ehci_hcd and uhci_hcd here

LoadModulesAuto   - load back on resume the modules that were unloaded on suspend

On my thinkpad X300 I found that bluetooth did not hibernate too well if radio active before suspend and ehci_hcd was giving the problems.   I am contemplaiting including iwlagn (it used to be on blacklist) but it does not affect resume for me, just the wireless itself is

sometimes (1 out of 10 times) stuck on resume.

There is possibility that wired network e1000(e) can cause trouble

But the first step is to ensure that  these subsystems are compiled as modules.  Only then you have freedom to play with them

Then you can instruct the hibernate to unload all of them (you can start even with UnloadAllModules yes) and if that makes suspend work,  narrow down which exactly is giving a problem and trim your list.  (It is better at the end not to unload modules unnecessary, since it takes time, and may not bring the system exactly to original state)

The other possble problems stem from X windows. I don't have them, but I'm using intel embedded graphics which does not require

special kernel module.    I heard about problems with nvidia and ati proprietary drivers.   Include them into module unload list.

X own problems is usually cured by enabling switch to VT console before hibernation (in the script). But these can be easily check

just attempting hibernate from the VT console.

hibernate script also have infrastructure to stop services on hibernate.  I actually do stop both net.wlan0 and net.eth0

(this is how I resolved some issues I had with wired ethernet), but on resume I automatically bring back only net.eth0

(In general I try not to bring back wlan0 automatically whether on boot or on resume - only when I know I need wireless)Last edited by dmpogo on Fri Dec 05, 2008 5:26 pm; edited 1 time in total

----------

## dmpogo

 *Quote:*   

> 
> 
> The computer then stops, with the "moon" lit (not flashing).
> 
> When pressing the power button it starts but hangs with black screen and the moon flashing
> ...

 

You know what, I wonder if your power button is mapped to 'suspend'  rather than to 'power-off'.

Check your BIOS settings.

----------

## m_gustafsson

Thanks for your efforts   :Very Happy: 

I have read through your answers and will take a look at them once I finish work   :Confused: 

One short question though...

You said:

 *Quote:*   

> You know what, I wonder if your power button is mapped to 'suspend' rather than to 'power-off'.
> 
> Check your BIOS settings.

 

I have not checked my BIOS yet, but I was just thinking of the setting in Gnome, i.e. in System->Preferences->Power management.

Does the settings on the general tab matter in this case? I have "When the power button is pressed" set to "Ask me"...

----------

## dmpogo

 *m_gustafsson wrote:*   

> Thanks for your efforts  
> 
> I have read through your answers and will take a look at them once I finish work  
> 
> One short question though...
> ...

 

It is a pure specultation on my part.   What made me think is that solid and flashing moon signify two different states of the system.

I don't have manual nor my laptop handy - but it would be good if checked what they are.   Perhaps  suspend/standby ?

So there is something that puts the system into another state.  It is either someting in resume process, or your manual input,

the only which was pressing the button. Could it have send a conflicting signal besides wakeup ?

I would not think if gnome settings had time to kick in when you have not even got your screen, since it probably just captures 

ACPI event from power button, but who knows (maybe it comes before the screen or backlight is not getting up by some other reason) ? So my first guess was the BIOS level, and BIOSes usually do have this option to choose power button behaviour.

When I press a power button for resume, I get white led on the button lid, some flashing of other lights. Do you get it before the moon gets into blinking mode ?

----------

## m_gustafsson

When I press the power button after hibernate-ram (the moon is lit) the power on, and battery button is lit and the moon starts blinking. 

There is no setting in my BIOS for the power button. I have a Thinkpad X60s (at least I did not find it).

The manual says that when the moon is lit the computer is in standby mode and when the moon is blinking the computer is entering standby mode or hibernation mode, or is resuming normal operation.

----------

## dmpogo

 *m_gustafsson wrote:*   

> When I press the power button after hibernate-ram (the moon is lit) the power on, and battery button is lit and the moon starts blinking. 
> 
> There is no setting in my BIOS for the power button. I have a Thinkpad X60s (at least I did not find it).
> 
> The manual says that when the moon is lit the computer is in standby mode and when the moon is blinking the computer is entering standby mode or hibernation mode, or is resuming normal operation.

 

Ah, so it is never resumes.   Back to module story

----------

## m_gustafsson

Unfortunately I will not be home this weekend, so I will have to wait till Monday before I can do any tests with modules.

Maybe muebi can continue Saturday and Sunday   :Smile: 

----------

## m_gustafsson

I walked through the modules listed among the blacklisted to find the ones I had compiled into my kernel and moved them to modules.

The only one that I found was "forcedeth".

After recompiling my kernel it looks like hibernate works, but hibernate-ram is still not ok.

Anyway, I think this is good enough for me...  :Smile: 

----------

## audiodef

I don't have a Thinkpad but I emerged some thinkpad-specific stuff on a Dell when trying to get some MM buttons working. 

app-laptop/thinkpad and such, I think. Maybe that will help. And maybe kmilo.

----------

## dmpogo

 *m_gustafsson wrote:*   

> I walked through the modules listed among the blacklisted to find the ones I had compiled into my kernel and moved them to modules.
> 
> The only one that I found was "forcedeth".
> 
> After recompiling my kernel it looks like hibernate works, but hibernate-ram is still not ok.
> ...

 

Let me come back from a trip and we'll have a look

----------

## dmpogo

I see there is a new 2.6.27 kernel with 'fix regression with suspend/resume' in ChangeLog

----------

## m_gustafsson

Ok, then that will maybe solve my problems.

I am running Gentoo-sources and will wait until the 2.6.27 is considered stable before I update (using 2.6.26-r3 today). 

I know that I am a bit of a coward, but I am using this computer in my daily work at office...

----------

## muebi

Hi, 

I wondered if anybody succeeded with the Fn+F7 buttons in order to use an external monitor. At the moment I can't use mine and I guess it may because nothing is happening with Fn+F7 so far. Can anybody provide me with a working script or advice how to set things up?

----------

## dmpogo

 *muebi wrote:*   

> Hi, 
> 
> I wondered if anybody succeeded with the Fn+F7 buttons in order to use an external monitor. At the moment I can't use mine and I guess it may because nothing is happening with Fn+F7 so far. Can anybody provide me with a working script or advice how to set things up?

 

Yes, I have it working, but it still sometimes require manual play with resolution when using external projector (some of them require 

to set external monitor resolution, I did not yet find way to do it automatically for arbitrary settings.

I have the followign script, which does the toggle

/usr/local/sbin/thinkpad-fn7

```

#!/bin/bash

# External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"

EXTERNAL_OUTPUT="VGA"

INTERNAL_OUTPUT="LVDS"

EXTERNAL_LOCATION="left"

  

case "$EXTERNAL_LOCATION" in

     left|LEFT)

                EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"

               ;;

     right|RIGHT)

                EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"

               ;;

     top|TOP|above|ABOVE)

                EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"

               ;;

     bottom|BOTTOM|below|BELOW)

                EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"

               ;;

     *)

                EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"

               ;;

esac

# Figure out current state

INTERNAL_STATE=$($SU xrandr | grep ^$INTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")

EXTERNAL_STATE=$($SU xrandr | grep ^$EXTERNAL_OUTPUT | grep con | sed "s/.*connected //" | sed "s/(.*//")

 

if [ -z "$INTERNAL_STATE" ]; then

     STATE="external"

elif [ -z "$EXTERNAL_STATE" ]; then

     STATE="internal"

else

     INTERNAL_STATE=$(echo $INTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")

     EXTERNAL_STATE=$(echo $EXTERNAL_STATE | sed "s/[0-9]*x[0-9]*//")

     if [ "$INTERNAL_STATE" = "$EXTERNAL_STATE" ]; then

           STATE="mirror"

     else

           STATE="both"

     fi

fi

function screen_external(){

       xrandr --output $INTERNAL_OUTPUT --off

       xrandr --output $EXTERNAL_OUTPUT --auto

}

function screen_internal(){

       xrandr --output $EXTERNAL_OUTPUT --off

       xrandr --output $INTERNAL_OUTPUT --auto

}

function screen_mirror(){

       xrandr --output $INTERNAL_OUTPUT --auto

#       xrandr --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT

       xrandr --output $EXTERNAL_OUTPUT --auto

}

function screen_both(){

       xrandr --output $INTERNAL_OUTPUT --auto

       xrandr --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION

}

function screen_toggle(){

       case "$STATE" in

             internal)

                     screen_mirror

                     ;;

               mirror)

                     screen_external

                     ;;

             external)

                     screen_internal

                     ;;

                 *)

                     screen_internal

                     ;;

        esac

}

# What should we do?

DO="$1"

if [ -z "$DO" ]; then

      if [ $(basename $0) = "thinkpad-fn-f7" ]; then

           DO="toggle"

      fi

fi

    

case "$DO" in

      toggle)

              screen_toggle

              ;;

    internal)

              screen_internal

              ;;

    external)

              screen_external

              ;;

      mirror)

         screen_mirror

         ;;

   both)

         screen_both

         ;;

      status)

              echo "Current Fn-F7 state is: $STATE"

              echo

              echo "Attached monitors:"

              xrandr | grep "\Wconnected" | sed "s/^/ /"

              ;;

        *)

              echo "usage: $0 <command>" >&2

              echo >&2

              echo "  commands:" >&2

              echo "          status" >&2

              echo "          internal" >&2

              echo "          external" >&2

              echo "          mirror" >&2

              echo "          both" >&2

              echo "          toggle" >&2

              echo >&2#!/bin/sh

              ;;

esac

```

which can be used as stand alone or from acpid script.  My acpid script /etc/acpi/ibm.sh  is

```

# Specific signal handling

THINKPAD_ACPI_DIR=/sys/devices/platform/thinkpad_acpi

X_USER=`who | sed -ne "s/^\([^[:space:]]*\)[[:space:]]*:0.*/\1/p"`

if [ -n "$X_USER" ]; then

   export DISPLAY=":0.0"

   export XAUTHORITY=/home/${X_USER}/.Xauthority

fi

function x_info () {

   if [ -n "$XAUTHORITY" ]; then

           echo $1 | osd_cat -d 3 -p bottom -A center -o -50 -s 2 -c $2 -f -adobe-courier-bold-r-normal--*-240-*-*-m-*-iso8859-1

        fi

}

case $4 in

   00001002)

           su $X_USER -c 'alock -bg shade:shade=20 -cursor theme:name=xtr -auth pam'

      ;;

   00001004) 

      # Fn-F4 suspends to RAM (standard)

      # loaded thinkpad_acpi always captures Fn-F4, even masked  

      /usr/sbin/hibernate-ram

      ;;

   00001005) 

      # Fn-F5 toggles bluetooth radio (standard)

      # On toggle auto loads driver (hotplug ??), off leaves it

      # Services are currently untouched

      if [ `cat ${THINKPAD_ACPI_DIR}/bluetooth_enable` == 1 ] ; then

         echo 0 > ${THINKPAD_ACPI_DIR}/bluetooth_enable

      elif [ `cat ${THINKPAD_ACPI_DIR}/hotkey_radio_sw` == 1 ] ; then

      # we enable radio only if "hard" switch is on

         echo 1 >  ${THINKPAD_ACPI_DIR}/bluetooth_enable

      fi

      ;;      

   00001006)

      # Fn-F6 starts-stops wireless services (NON-standard)

      # In my network config wlan stop comes with disabling radio

      status=`/etc/init.d/net.wlan0 status` 

      status=${status#* status:}

      if   [ $status == started ] ; then

         /etc/init.d/net.wlan0 stop   

      elif [ $status == stopped ] ; then

           if [ `cat ${THINKPAD_ACPI_DIR}/hotkey_radio_sw` == 1 ] ; then

         /etc/init.d/net.wlan0 start   

           else

              x_info "Radio Kill Switch in the back is enabled" red

           fi

      elif [ $status == inactive ] ; then

           # This perhaps can arise if there are no AP's

           # this is why I do not restart automatically

           # May do it when understand wpa_supplicant better

           message="No AP's or WLAN may have hanged. Restart manually, perhaps reinserting iwlagn"

           x_info "$message" red

           logger "$message"

      fi

      ;;

   00001007)

      # Fn-F7 cycles through monitors (standard)

      /usr/local/sbin/thinkpad-fn-f7 toggle

      ;;

   00001008)

      # Fn-F8 switches touchpad on and off (standard)

      if synclient -l | grep -q TouchpadOff[^[:alnum:]]*0 ; then

         synclient TouchpadOff=1

         status="TouchPad OFF"

      else

         synclient TouchpadOff=0

         status="TouchPad ON"

      fi

      x_info "$status" green

      ;;

   0000100c)

      # Fn-F12 hibernates (standard)

      /usr/sbin/hibernate

      ;;

   00001014)

      # Fn-Space zoom application (standard)

           su $X_USER -c xmag

      ;;

   00007000)

      # Hard radio switch off (standard)

      if [ `cat  ${THINKPAD_ACPI_DIR}/hotkey_radio_sw` == 0 ] ; then

          status=`/etc/init.d/net.wlan0 status` 

         status=${status#* status:}

         /etc/init.d/net.wlan0 stop   

         echo 0 >  ${THINKPAD_ACPI_DIR}/bluetooth_enable

      fi

      ;;

              ;;

esac

```

----------

## muebi

dmpogo, 

I copied and pasted your Fn+F7 script and made it executable but still nothing happens...

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> I copied and pasted your Fn+F7 script and made it executable but still nothing happens...

 

what do you mean by 'nothing happens' ?

does it work if you call it by hand ? l

```

/usr/local/sbin/thinkpad-fn7 toggle

```

If it does, next you need to setup your acpid to call the script. In my case it is done by having /etc/acpi/ibm.sh which handles all Fn-F? keys

and having in /etc/acpi/events/ibm   file with the following content

```

event=ibm/hotkey

action=/etc/acpi/ibm.sh %e

```

----------

## muebi

dmpogo, 

Unfortunately, it does not work if I run /usr/local/sbin/thinkpad-fn7 toggle by hand.  :Sad: 

Although the monitor cable is plugged I have the feeling that there is no communication between laptop and monitor at all...

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> Unfortunately, it does not work if I run /usr/local/sbin/thinkpad-fn7 toggle by hand. 
> 
> Although the monitor cable is plugged I have the feeling that there is no communication between laptop and monitor at all...

 

what does simply running

```

xrandr

```

says ? (please post output)

I also forgot, what video drivers are you using ?  Do they have xrandr extension (look into /var/log/xorg.log)

----------

## muebi

dmpogo, 

here is the output from xrandr:

$ xrandr

Screen 0: minimum 1280 x 1024, current 1680 x 1050, maximum 1680 x 1050

default connected 1680x1050+0+0 0mm x 0mm

   1680x1050      61.0*

   1280x1024      61.0

I actually do not have a /var/log/xorg.log file. I only have /var/log/Xorg.0.log which did not contain any information regarding xrandr.

I found the following in my xorg.conf which may be helpful:

Section "Device"

    Identifier     "Card0"

    Driver         "vesa"

    Option         "NoLogo" "True"

EndSection

Section "Screen"

    Identifier     "Screen0"

    Device         "Card0"

    Monitor        "Configured Monitor"

    DefaultDepth    24

EndSection

I also have a ATI Mobility Radeon video card but I didn't manage to get it running so far...

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> here is the output from xrandr:
> 
> $ xrandr
> ...

 

oh, I see. You should 

have in /etc/xorg.conf somethig like that

1. Two monitor sections like

```

Section "Monitor"

    Identifier   "Lenovo LCD Screen"

    Option      "DPMS"

EndSection

Section "Monitor"

    Identifier   "External VGA monitor"

    Option      "DPMS"

    Option      "Ignore" "false"                   <-------------- this is important

EndSection

```

Then later  in section device

```

Section "Device"

...............

    Option   "Monitor-LVDS" "Lenovo LCD Screen"

    Option   "Monitor-VGA" "External VGA monitor"                       <--------- must be same names as identifier in monitor section

EndSection

```

Then in section Screen

```

Section "Screen"

# The Identifier, Device and Monitor lines must be present

.................

# The favoured Depth and/or Bpp may be specified here

.................

    SubSection "Display"

   Depth      24

   Modes      "1440x900"

        Virtual      2880 900         <----- This is important. Must cover area LCD+External in pixels, and correspond

                                                                 to where external is placed.  Here I'll be putting external screen horizontally

                                                                 (left or right) of the LCD (which is 1440x900). I.e I have a space for

                                                                 two 1440x900 screens side by side.  This is enough for me because I'm not using

                                                                extrenal monitors yet, it is just for projector, which is rarely larger than 1024x768

    EndSubSection

EndSection

```

when you launch X, /var/log/Xorg.0.log should have a line

Initializing built-in extension RANDR

+ other lines about RANDR

----------

## gubacsek

Hi All!

First of all, thanks for all the information in this thread!  :Smile: 

I upgraded my kernel, and lost the functionality to change the display brightness, but thanks to You it's working again.

I have one question:

Is there a way to start an application in X with one of the unused keys? For example with the "ThinkVantage" button.

I can capture the event, but i don't know how to start for example a gnome-terminal.

Please help me!!  :Smile: 

thanks in advance!

(i had the same issues with suspend. I solved them by upgrading gnome-2.24 , and the kernel-2.6.28.r3)

----------

## dmpogo

 *gubacsek wrote:*   

> Hi All!
> 
> First of all, thanks for all the information in this thread! 
> 
> I upgraded my kernel, and lost the functionality to change the display brightness, but thanks to You it's working again.
> ...

 

If you do it through acpid, you can either specify the corresponding action (i.e the name of the program you want to call) in that file that describes the capture in /etc/acpi/events/,   or as usual have that 'action' line to point to a shell script (which in examples in this thread lived in /etc/acpi directory) which will in turn launch the necessary program, perhaps with some extra handling.

----------

## gubacsek

 *dmpogo wrote:*   

> 
> 
> If you do it through acpid, you can either specify the corresponding action (i.e the name of the program you want to call) in that file that describes the capture in /etc/acpi/events/,   or as usual have that 'action' line to point to a shell script (which in examples in this thread lived in /etc/acpi directory) which will in turn launch the necessary program, perhaps with some extra handling.

 

Yes, this is clear  :Smile: 

My problem was to start an application in X. I already figured out a solution, and i'm almost happy with it:

/etc/acpi/my_button.sh  (which is called from /etc/acpi/events/default)

```

case "$4" in

        "00001018") # ThinkVantage

                su - aron -c "export DISPLAY=:0.0;gnome-terminal --geometry=170x50 &"

                ;;

esac

```

So i get a gnome-terminal in my X session. BUT. Gnome-keyring is not active for this terminal window.  :Sad: 

I have set gnome-keyring to be opened when my session starts, this saves me a lot of password typing, and this is a pretty comfortable thing, which i would like to have in this terminal also.

I hope you guys understand what i'm trying to achieve here, and there is a solution for it  :Smile: 

----------

## dmpogo

 *gubacsek wrote:*   

>  *dmpogo wrote:*   
> 
> If you do it through acpid, you can either specify the corresponding action (i.e the name of the program you want to call) in that file that describes the capture in /etc/acpi/events/,   or as usual have that 'action' line to point to a shell script (which in examples in this thread lived in /etc/acpi directory) which will in turn launch the necessary program, perhaps with some extra handling. 
> 
> Yes, this is clear 
> ...

 

I don't know much, but launching desktop application is a tricky matter, since it has to communicate to other parts of the desktop - perhaps via dbus, dcop or whatever.   I don't know gnome, but my advice would be to dig Gnome documentation to how the application must be launched to have all Gnome functionality.

----------

## stupidkid

Thanks for the scripts dmpogo.

----------

## gubacsek

 *dmpogo wrote:*   

> 
> 
> I don't know much, but launching desktop application is a tricky matter, since it has to communicate to other parts of the desktop - perhaps via dbus, dcop or whatever.   I don't know gnome, but my advice would be to dig Gnome documentation to how the application must be launched to have all Gnome functionality.

 

OK, i will do that. Thank You anyway dmpogo! And to you all!

----------

## muebi

dmpogo, 

I have problems again using my external projector using the Fn+F7 key combination on my laptop. 

It just seems that there is no communication between both devices. Maybe you have a clue why or can help me out with that.

I was following your guidance earlier in this thread with some other functional keys...

Thanks.

----------

## dmpogo

 *muebi wrote:*   

> dmpogo, 
> 
> I have problems again using my external projector using the Fn+F7 key combination on my laptop. 
> 
> It just seems that there is no communication between both devices. 
> ...

 

What exactly is happening ?

----------

## muebi

Actually nothing is happening and I am scratching my head what could be wrong...

There just doesn't seem anything to happen when I press Fn+F7 and I don't know if there is something wrong with the ACPI configuration or with the xorg.conf file... What can I try to narrow things down?

BTW: Below is my current xorg.conf file:

Section "ServerLayout"

    Identifier     "Default Layout"

    Screen      0  "Screen0" 0 0

EndSection

Section "Files"

EndSection

Section "Module"

    Load           "dbe"

    Load           "extmod"

    Load           "fbdevhw"

    Load           "glx"

    Load           "record"

EndSection

Section "ServerFlags"

    Option         "Xinerama" "0"

EndSection

Section "Monitor"

    Identifier     "LCD Monitor"

EndSection

Section "Monitor"

    Identifier     "Projector"

    VendorName     "Unknown"

    ModelName      "Samsung SyncMaster"

    HorizSync       30.0 - 81.0

    VertRefresh     56.0 - 75.0

EndSection

Section "Device"

    Identifier     "Card0"

    Driver         "vesa"

    Option         "NoLogo" "True"

    BusID          "PCI:0:2:0"

EndSection

Section "Device"

    Identifier     "Videocard0"

    Driver         "fglrx"

    VendorName     "ATI Corporation"

    BoardName      "Radeo 4850"

    BusID          "PCI:1:0:0"

EndSection

Section "Screen"

    Identifier     "Screen0"

    Device         "Card0"

    Monitor        "LCD Monitor"

    DefaultDepth    24

    Subsection "Display"

    	    Depth       24

	    Modes	"1680x1050" "1280x1024" "1024x768" "800x600" "640x480"

    EndSubsection

EndSection

As you can see I have several different configurations in "Modes". However, xrandr only gives:

Screen 0: minimum 1680 x 1050, current 1680 x 1050, maximum 1680 x 1050

default connected 1680x1050+0+0 0mm x 0mm

   1680x1050       0.0*

----------

## dmpogo

xrandr is not using different modes. Instead, one need to configure a large virtual screen that encompasses both your physical screens.

search online for proper configuration, my laptop is unavailable right now

----------

## muebi

dmpogo, 

I experimented with a line

Virtual 2048 2048

I can restart the xserver but the display is totally blurred then so it doen't seem to work properly.

And I can't go beyond 2048 because my graphic card doesn't seem to support it.

----------

## muebi

Ok, it seems I got it fixed. Here is what I did:

First, I replaced the graphics driver in section "Device". It was "vesa" before and now I use "intel". With this change I was able to set the line

            Virtual     3360 2048

in the section "Screen" without the blurry screen issue. 

I experimented a little bit with the numbers but it doesn't seem to matter much as long as the virtual screen is not too small I guess. There is a webpage http://www.thinkwiki.org/wiki/Xorg_RandR_1.2#xorg.conf which has some useful info.

However, I also cleaned up my xorg.conf file and got rid of all the stuff that doesn't seem to do any good.

E.g., I also commented the section "Modes" (in subsection "Display") since it seems obsolete and xrandr get's the info from somewhere else.

Below is my currently working xorg.conf:

Section "ServerLayout"

    Identifier     "Default Layout"

    Screen      0  "Screen0" 0 0

EndSection

Section "Files"

EndSection

Section "Module"

    Load           "dbe"

    Load           "extmod"

    Load           "fbdevhw"

    Load           "glx"

    Load           "record"

EndSection

Section "ServerFlags"

    Option         "Xinerama" "0"

EndSection

Section "Monitor"

    Identifier     "LCD Monitor"

    Option         "DPMS"

EndSection

Section "Device"

    Identifier     "Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller"

    Driver         "intel"

    BusID          "PCI:0:2:0"

EndSection

Section "Device"

    Identifier     "Videocard0"

    Driver         "fglrx"

    VendorName     "ATI Corporation"

    BoardName      "Radeo 4850"

    BusID          "PCI:1:0:0"

EndSection

Section "Screen"

    Identifier     "Screen0"

    Device         "Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller"

    Monitor        "LCD Monitor"

    DefaultDepth    24

    Subsection "Display"

    	    Depth       24

#	    Modes	"1680x1050" "1280x1024" "1024x768" "800x600" "640x480"

            Virtual     3360 2048

    EndSubsection

EndSection

----------

