Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to get extra functional keys to work?
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3, 4  Next  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Fri Nov 21, 2008 5:25 pm    Post subject: How to get extra functional keys to work? Reply with quote

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
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Fri Nov 21, 2008 5:48 pm    Post subject: Re: Hot to get extra functional keys to work? Reply with quote

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.
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Fri Nov 21, 2008 6:05 pm    Post subject: Reply with quote

Lenovo Thinkpad W500.
Thanks!
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Fri Nov 21, 2008 7:19 pm    Post subject: Reply with quote

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
Code:

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]
Back to top
View user's profile Send private message
albright
Advocate
Advocate


Joined: 16 Nov 2003
Posts: 2588
Location: Near Toronto

PostPosted: Fri Nov 21, 2008 8:22 pm    Post subject: Reply with quote

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 :)
_________________
.... there is nothing - absolutely nothing - half so much worth
doing as simply messing about with Linux ...
(apologies to Kenneth Graeme)
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Fri Nov 21, 2008 9:49 pm    Post subject: Reply with quote

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?

looks like a fantastic machine :)


Well, X301 is better :)


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.
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Sat Nov 22, 2008 11:53 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Sat Nov 22, 2008 4:12 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Sat Nov 22, 2008 4:51 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Sun Nov 23, 2008 10:57 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Sun Nov 23, 2008 4:16 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Sun Nov 23, 2008 6:25 pm    Post subject: Reply with quote

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. :-)
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Sun Nov 23, 2008 11:23 pm    Post subject: Reply with quote

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
Code:
event=ibm/hotkey
action=/etc/acpi/ibm.sh %e


/etc/acpi/events/lidbtn
Code:

event=button/lid
action=/etc/acpi/lidbtn.sh


/etc/acpi/events/video
Code:

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
Code:

#!/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


Code:
#!/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
Code:

#!/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
Code:

#!/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
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Tue Nov 25, 2008 8:06 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Tue Nov 25, 2008 8:18 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Tue Nov 25, 2008 9:18 pm    Post subject: Reply with quote

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 ?
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Thu Nov 27, 2008 9:08 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Thu Nov 27, 2008 9:34 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Thu Nov 27, 2008 9:50 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Thu Nov 27, 2008 10:31 pm    Post subject: Reply with quote

muebi wrote:
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.


so get me tail /var/log/daemon.log just after you press Fn-F2
Back to top
View user's profile Send private message
caspar
Apprentice
Apprentice


Joined: 02 Mar 2003
Posts: 228
Location: 240 000 miles away from moon

PostPosted: Thu Nov 27, 2008 11:49 pm    Post subject: Reply with quote

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.
Code:

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,

Code:

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:


Code:

   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
_________________
"Dream as if you'll live forever. Live as if you'll die today."
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Fri Nov 28, 2008 12:22 am    Post subject: Reply with quote

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

Code:

#!/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
Back to top
View user's profile Send private message
muebi
Guru
Guru


Joined: 07 Nov 2008
Posts: 312

PostPosted: Fri Nov 28, 2008 9:27 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
caspar
Apprentice
Apprentice


Joined: 02 Mar 2003
Posts: 228
Location: 240 000 miles away from moon

PostPosted: Fri Nov 28, 2008 11:04 am    Post subject: Reply with quote

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
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


Please read my post.

Regards,
caspar
_________________
"Dream as if you'll live forever. Live as if you'll die today."
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3269
Location: Canada

PostPosted: Fri Nov 28, 2008 4:47 pm    Post subject: Reply with quote

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
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


Please read my post.

Regards,
caspar




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
Code:

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
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum