LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 10344|回复: 40

thinkpad x32功能键设置

[复制链接]
发表于 2007-7-11 15:35:37 | 显示全部楼层 |阅读模式
linux对thinkpad的支持非常好,各功能键都能实现,现将本人的x32的一些设置贡献给大家,希望对zhou3345和其他兄弟有所帮助,同时也希望大家对疏漏和错误给予补充、批评和指正。

实现如下功能:
声音大小的调节、屏幕亮度的调节和键盘灯
Fn+F3:power down the backlight (on)
Fn+F4:hibernate-ram
Fn+F5:power down the wireless (on)
Fn+F7:外接显示器
Fn+F12:hibernate
Shift+NumLk:数字键盘切换
屏幕显示功能

1、首先将ACPI_IBM编译进内核或编译成模块

2.6.22以前内核
  1. CONFIG_ACPI_IBM=y
复制代码
2.6.22以后内核
  1. CONFIG_THINKPAD_ACPI=y
复制代码
安装sys-power/acpid并加入boot runlevel
  1. emerge sys-power/acpid
  2. rc-update add acpid boot
复制代码
启动acpid
  1. /etc/init.d/acpid start
复制代码

2、将echo enable,0xffff > /proc/acpi/ibm/hotkey添加入/etc/conf.d/local.start,或者直接执行如下命令
  1. echo "echo enable,0xffff > /proc/acpi/ibm/hotkey" >> /etc/conf.d/local.start
复制代码
这一步很重要,至此已经激活了所有thinkpad的功能键。声音大小的调节、屏幕亮度的调节和键盘灯等都已经能正常使用了。

3、Fn+F3:power down the backlight (on)
安装app-laptop/radeontool,通过radeontool能够实现真正的开关显示屏
  1. emerge app-laptop/radeontool
复制代码
新建/etc/acpi/events/ibm-screen文件
  1. event=ibm/hotkey HKEY 00000080 00001003
  2. action=/etc/acpi/ibm-screen.sh
复制代码
新建/etc/acpi/ibm-screen.sh
  1. #!/bin/sh
  2. #
  3. event=$1
  4. status=
  5. event="'backlight'";
  6. status=$(radeontool light | grep -Eo '[^ ]+$')
  7. if [ "$status" = "on" ]; then
  8. status=off
  9. else
  10. status=on
  11. fi
  12. radeontool light $status
复制代码
使其可执行
  1. chmod a+x /etc/acpi/ibm-screen.sh
复制代码
重新启动acpid
  1. /etc/init.d/acpid restart
复制代码
到这里便可以通过Fn+F3开关显示屏了。

4、Fn+F5:power down the wireless (on)
不同内核有些差别,这个只讨论2.6.20内核的情况。首先应确认无线已经可以使用,可参考相关wiki。

新建/etc/acpi/events/ibm-wireless文件
  1. event=ibm/hotkey HKEY 00000080 00001005
  2. action=/etc/acpi/ibm-wireless.sh
复制代码
新建/etc/acpi/ibm-wireless.sh
  1. #!/bin/sh
  2. # Find and toggle wireless of bluetooth devices on ThinkPads
  3. #. /etc/acpi/state-funcs
  4. # Return 0 if there is, allowing you to write   if isAnyWirelessPoweredOn; then ...
  5. isAnyWirelessPoweredOn()
  6. {
  7.     for DEVICE in /sys/class/net/* ; do
  8.         if [ -d $DEVICE/wireless -a -r $DEVICE/device/power/state ] ; then
  9.             # If any of the wireless devices are turned on then return success
  10.             if [ "`cat $DEVICE/device/power/state`" -eq 0 ] ; then
  11.                 # Check if 'rf_kill' disagrees
  12.                 if [ -r $DEVICE/device/rf_kill ] ; then
  13.                     if [ "`cat $DEVICE/device/rf_kill`" -eq 0 ] ; then
  14.                         # And rf_kill has the radio on
  15.                         return 0
  16.                     fi
  17.                 else
  18.                     return 0
  19.                 fi
  20.             fi
  21.         fi
  22.     done
  23.     # otherwise return failure
  24.     return 1
  25. }
  26. # Takes no parameters, toggles all wireless devices.
  27. # TODO: Should possible toggle all wireless devices to the state of the first one.
  28. # Attempts to use 'rf_kill' first, and then tries 'power/state', though that
  29. # will fail on >=2.6.18 kernels since upstream removed the functionality...
  30. toggleAllWirelessStates()
  31. {
  32.     for DEVICE in /sys/class/net/* ; do
  33.         if [ -d $DEVICE/wireless ] ; then
  34.             # $DEVICE is a wireless device. Check if it's powered on:
  35.             ON=0
  36.             OFF=1  # 1 for rf_kill, 2 for power/state
  37.             for CONTROL in $DEVICE/device/rf_kill $DEVICE/device/power/state ; do
  38.                 if [ -w $CONTROL ] ; then
  39.                     # We have a way of controlling the device, lets try
  40.                     if [ "`cat $CONTROL`" = 0 ] ; then
  41.                         # It's powered on. Switch it off.
  42.                         if echo -n $OFF > $CONTROL ; then
  43.                             break
  44.                         else
  45.                             OFF=2 # for power/state, second time around
  46.                         fi
  47.                     else
  48.                         # It's powered off. Switch it on.
  49.                         if echo -n $ON > $CONTROL ; then
  50.                             break
  51.                         fi
  52.                     fi
  53.                 fi
  54.             done
  55.         fi
  56.     done
  57. }
  58. ##Find and toggle wireless of bluetooth devices on ThinkPads
  59. BLUETOOTH=/proc/acpi/ibm/bluetooth
  60. if [ -r $BLUETOOTH ]; then
  61.     grep -q disabled $BLUETOOTH
  62.     bluetooth_state=$?
  63. fi
  64. # Note that this always alters the state of the wireless!
  65. toggleAllWirelessStates;
  66. # Sequence is Both on, Bluetooth only, Wireless only, Both off
  67. if ! isAnyWirelessPoweredOn; then
  68.     # Wireless was turned off
  69.     if [ -w $BLUETOOTH ]; then
  70.         if [ "$bluetooth_state" = 0 ]; then
  71.             echo enable > $BLUETOOTH;
  72.         else
  73.             echo disable > $BLUETOOTH
  74.         fi
  75.     fi
  76. fi
复制代码
使其可执行
  1. chmod a+x /etc/acpi/ibm-wireless.sh
复制代码
重新启动acpid
  1. /etc/init.d/acpid restart
复制代码
到这里便可以通过Fn+F5开关无线网络了。

5、Fn+F4:hibernate-ram和Fn+F12:hibernate

安装hibernate-script并加入boot runlevel
  1. emerge hibernate-script
  2. rc-update add hibernate-cleanup boot
复制代码
新建/etc/acpi/events/ibm-suspend文件
  1. event=ibm/hotkey HKEY 00000080 00001004
  2. action=/usr/sbin/hibernate-ram
复制代码
新建/etc/acpi/events/ibm-hibernate文件
  1. event=ibm/hotkey HKEY 00000080 0000100c
  2. action=/usr/sbin/hibernate
复制代码
重新启动acpid
  1. /etc/init.d/acpid restart
复制代码
到这里便可以通过Fn+F4待机(Fn键唤醒),Fn+F12休眠了。

如过要使用suspend2,需要使用打过suspend2补丁的内核,具体可参考
http://www.gentoo.org/doc/en/power-management-guide.xml

6、实现屏幕显示。

安装app-laptop/tpb
  1. echo "app-laptop/tpb xosd" >> /etc/portage/package.use
  2. emerge app-laptop/tpb
复制代码
如果是gnome,将tpb -d加入senssions

配置~/.tpbrc或/etc/tpbrc,以下设置仅作参考
  1. # Use OSS mixer to change volume and for mute/unmute. This should be use on
  2. # models with no hardware mixer (volume and mute buttons show no effect). R31
  3. # is reported to have no hardware mixer. To use this you must enable write
  4. # access to the NVRAM device (possibly dangerous). Possible values are on and
  5. # off. Default is off.
  6. #
  7. MIXER      ON
  8. ## MIXERSTEPS
  9. # Defines how much steps should be available when using the OSS mixer. Default
  10. # is 14. If an other number of steps is used, tpb needs write access to the
  11. # nvram device.
  12. #
  13. #MIXERSTEPS  14
  14. ## MIXERDEVICE
  15. # Defines the mixer device to use for OSS mixer support. Default is /dev/mixer.
  16. #
  17. #MIXERDEVICE /dev/mixer
  18. ### POWERMANAGEMENT SETTINGS
  19. ## APM
  20. # Some ThinkPads generate mouse and keyboard events or have a high CPU load when
  21. # polling /proc/apm. You may enable this, if you want the AC connected/AC
  22. # disconnected messages. Default is off.
  23. #
  24. #APM         OFF
  25. ## POWERMGT
  26. # The program apmiser (part of tpctl package) switches the power management
  27. # mode according to the needs of the user. This results in lots of changes
  28. # displayed in OSD. To avoid this, the power management messages can be turned
  29. # off. Default is auto.
  30. #
  31. #POWERMGT    AUTO
  32. ### X11 SETTINGS
  33. ## XEVENTS
  34. # Some of the special keys generate X11 events instead of changing the nvram. TPB
  35. # is able to grab those keys and run an application. However some people like to
  36. # use the X11 events through xmodmap or the like. This option turns off the
  37. # grabbing of the events. Affected keys are HOME, SEARCH, MAIL, FAVORITES,
  38. # RELOAD, ABORT, BACKWARD, FORWARD and FN. Default is on.
  39. #
  40. #XEVENTS     OFF
  41. ### ON-SCREEN DISPLAY SETTINGS
  42. ## OSD
  43. # Global switch for showing on-screen display for volume, mute and brightness.
  44. # Possible values are on and off. Default is on.
  45. #
  46. #OSD         ON
  47. ## OSDZOOM
  48. # Specific switch for showing on-screen display for zoom button.
  49. # Possible values are on and off. Default is unset, follows the OSD option.
  50. #
  51. #OSDZOOM     OFF
  52. ## OSDTHINKLIGHT
  53. # Specific switch for showing on-screen display for thinklight button.
  54. # Possible values are on and off. Default is unset, follows the OSD option.
  55. #
  56. #OSDTHINKLIGHT OFF
  57. ## OSDDISPLAY
  58. # Specific switch for showing on-screen display for display output button.
  59. # Possible values are on and off. Default is unset, follows the OSD option.
  60. #
  61. #OSDDISPLAY OFF
  62. ## OSDHVEXPANSIOFF
  63. # Specific switch for showing on-screen display for HV expansion button.
  64. # Possible values are on and off. Default is unset, follows the OSD option.
  65. #
  66. #OSDHVEXPANSION OFF
  67. ## OSDBRIGHTNESS
  68. # Specific switch for showing on-screen display for brightness buttons.
  69. # Possible values are on and off. Default is unset, follows the OSD option.
  70. #
  71. #OSDBRIGHTNESS OFF
  72. ## OSDVOLUME
  73. # Specific switch for showing on-screen display for ivolume and mute buttons.
  74. # Possible values are on and off. Default is unset, follows the OSD option.
  75. #
  76. #OSDVOLUME OFF
  77. ## OSDPOWERMGT
  78. # Specific switch for showing on-screen display for ipower management changes.
  79. # Possible values are on and off. Default is unset, follows the OSD option.
  80. #
  81. #OSDPOWERMGT OFF
  82. ## OSDFONT
  83. # Defines the font for the on-screen display. You may use "xfontsel" to choose
  84. # one. Default is the default font of the xosd library.
  85. #
  86. #OSDFONT     -*-lucidatypewriter-*-*-*-*-*-240-*-*-*-*-*-*
  87. OSDFONT     -adobe-helvetica-*-r-*-*-12-*-*-*-*-*-iso10646-1
  88. ## OSDCOLOR
  89. # Defines the color of the on-screen display. You may use "xcolors" to choose
  90. # one. Default is BLUE.
  91. #
  92. OSDCOLOR    Blue
  93. ## OSDTIMEOUT
  94. # Defines how long (in seconds) the on-screen display is shown after the last
  95. # keys was pressed. Default is 3.
  96. #
  97. #OSDTIMEOUT  3
  98. ## OSDOFFSET
  99. # For backward compatibility. Same as OSDVERTICAL.
  100. #
  101. OSDOFFSET   25
  102. ## OSDSHADOW
  103. # Defines the offset of the font shadow in pixels. Default is 2.
  104. #
  105. OSDSHADOW   0
  106. ## OSDSHADOWCOLOR
  107. # Defines the color of the shadow of the on-screen display. You may use
  108. # "xcolors" to choose one. Default is BLACK.
  109. #
  110. #OSDSHADOWCOLOR BLACK
  111. ## OSDOUTLINE
  112. # Defines the width of the font outline in pixels. Default is 1.
  113. #
  114. OSDOUTLINE   0
  115. ## OSDOUTLINECOLOR
  116. # Defines the color of the outline of the on-screen display. You may use
  117. # "xcolors" to choose one. Default is BLACK.
  118. #
  119. #OSDOUTLINECOLOR BLACK
  120. ## OSDVERTICAL
  121. # Defines the offset from the top or bottom of the screen in pixels. Default is 25.
  122. #
  123. OSDVERTICAL 50
  124. ## OSDHORIZONTAL
  125. # Defines the offset from the left or right of the screen in pixels. Only
  126. # supported by xosd 2.0.0 and above. Default is 25.
  127. #
  128. OSDHORIZONTAL 100
  129. ## OSDPOS
  130. # Defines where the osd is shown. Possible values are top, middle and bottom.
  131. # The value middle is only supported by xosd 2.0.0 and above. Default is bottom.
  132. #
  133. OSDPOS      bottom
  134. ## OSDALIGN
  135. # Defines the alignment of the osd. Possible values are left, center and right.
  136. # Default is left.
  137. #
  138. #OSDALIGN    LEFT
复制代码

7、注意事项
i、如果使用gnome,需取消gnome快捷键的设置,否则会出现休眠待机两次的情况,具体处理如下:

在你使用的用户下执行gconf-editor,将如下两项的键值设为nothing
  1. /apps/gnome-power-manager/action_button_hibernate
  2. /apps/gnome-power-manager/action_button_suspend
复制代码

补充
8、Fn+F7实现参考:
Fn+F7的实现前面有个兄弟已发过相关配置:
http://www.linuxsir.cn/bbs/showt ... 2&highlight=ibm
21楼zhou3345兄补充。
http://www.linuxsir.cn/bbs/showthread.php?t=308091&page=2

9、Shift+NumLk:数字键盘切换
建立~/.xmodmaprc文件
  1. clear mod2
  2. keycode 77 = Num_Lock
  3. add mod2 = Num_Lock
复制代码
执行# xmodmap ~/.xmodmaprc,然后按Shift+NumLk数字灯会亮,实现小数字键盘功能
要实现每次重启后自动生效,在~/.xintirc中添加:
  1. xmodmap ~/.xmodmaprc
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
发表于 2007-7-11 15:45:09 | 显示全部楼层
楼主真是好人啊,我用x60的,受教了,不过楼主可否提供一下实现外接显示器配置的相关文件,这个问题我一直没有搞定
回复 支持 反对

使用道具 举报

发表于 2007-7-11 16:00:28 | 显示全部楼层
谢谢分享,应该让版主加精:)
回复 支持 反对

使用道具 举报

发表于 2007-7-11 16:36:31 | 显示全部楼层
强烈建议加精!另外,谁能给个HP的功能键设置过程啊……
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-7-11 19:58:35 | 显示全部楼层
Post by liwenqiu
楼主真是好人啊,我用x60的,受教了,不过楼主可否提供一下实现外接显示器配置的相关文件,这个问题我一直没有搞定

Fn+F7的实现前面有个兄弟已发过相关配置:
http://www.linuxsir.cn/bbs/showt ... 2&highlight=ibm
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-7-11 20:01:01 | 显示全部楼层
Post by zhou3345
谢谢分享,应该让版主加精:)
Post by Zer4tul
强烈建议加精!另外,谁能给个HP的功能键设置过程啊……

多谢大家的支持。
回复 支持 反对

使用道具 举报

发表于 2007-7-11 23:05:33 | 显示全部楼层
给楼主推荐个
  1. # paludis -q tp_smapi
  2. * app-laptop/tp_smapi
  3.     gentoo:            0.20 0.21 0.27 0.30 0.31 {:0}
  4.     installed:         0.31* {:0}
  5.     Homepage:          http://tpctl.sourceforge.net/
  6.     Description:       IBM ThinkPad SMAPI BIOS driver
  7.     License:           ( GPL-2 )
  8.     Source origin:     app-laptop/tp_smapi-0.31::gentoo
  9.     Installed time:    Tue Jul 10 14:13:59 2007
  10.     Use flags:         (-hdaps) (kernel_linux)
复制代码
支持thinkpad的电源管理.
回复 支持 反对

使用道具 举报

发表于 2007-7-11 23:24:12 | 显示全部楼层
没有Thinkpad 来觊觎一下

楼主把你的其他笔记也总结出来吧
回复 支持 反对

使用道具 举报

发表于 2007-7-11 23:28:20 | 显示全部楼层
分享,才能共同进步!
回复 支持 反对

使用道具 举报

发表于 2007-7-12 05:43:38 | 显示全部楼层
smapi?什么东西?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表