|
|
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以前内核2.6.22以后内核安装sys-power/acpid并加入boot runlevel- emerge sys-power/acpid
- rc-update add acpid boot
复制代码 启动acpid
2、将echo enable,0xffff > /proc/acpi/ibm/hotkey添加入/etc/conf.d/local.start,或者直接执行如下命令- 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能够实现真正的开关显示屏- emerge app-laptop/radeontool
复制代码 新建/etc/acpi/events/ibm-screen文件- event=ibm/hotkey HKEY 00000080 00001003
- action=/etc/acpi/ibm-screen.sh
复制代码 新建/etc/acpi/ibm-screen.sh- #!/bin/sh
- #
- event=$1
- status=
- event="'backlight'";
- status=$(radeontool light | grep -Eo '[^ ]+$')
- if [ "$status" = "on" ]; then
- status=off
- else
- status=on
- fi
- radeontool light $status
复制代码 使其可执行- chmod a+x /etc/acpi/ibm-screen.sh
复制代码 重新启动acpid- /etc/init.d/acpid restart
复制代码 到这里便可以通过Fn+F3开关显示屏了。
4、Fn+F5:power down the wireless (on)
不同内核有些差别,这个只讨论2.6.20内核的情况。首先应确认无线已经可以使用,可参考相关wiki。
新建/etc/acpi/events/ibm-wireless文件- event=ibm/hotkey HKEY 00000080 00001005
- action=/etc/acpi/ibm-wireless.sh
复制代码 新建/etc/acpi/ibm-wireless.sh- #!/bin/sh
- # Find and toggle wireless of bluetooth devices on ThinkPads
- #. /etc/acpi/state-funcs
- # Return 0 if there is, allowing you to write if isAnyWirelessPoweredOn; then ...
- isAnyWirelessPoweredOn()
- {
- for DEVICE in /sys/class/net/* ; do
- if [ -d $DEVICE/wireless -a -r $DEVICE/device/power/state ] ; then
- # If any of the wireless devices are turned on then return success
- if [ "`cat $DEVICE/device/power/state`" -eq 0 ] ; then
- # Check if 'rf_kill' disagrees
- if [ -r $DEVICE/device/rf_kill ] ; then
- if [ "`cat $DEVICE/device/rf_kill`" -eq 0 ] ; then
- # And rf_kill has the radio on
- return 0
- fi
- else
- return 0
- fi
- fi
- fi
- done
- # otherwise return failure
- return 1
- }
- # Takes no parameters, toggles all wireless devices.
- # TODO: Should possible toggle all wireless devices to the state of the first one.
- # Attempts to use 'rf_kill' first, and then tries 'power/state', though that
- # will fail on >=2.6.18 kernels since upstream removed the functionality...
- toggleAllWirelessStates()
- {
- for DEVICE in /sys/class/net/* ; do
- if [ -d $DEVICE/wireless ] ; then
- # $DEVICE is a wireless device. Check if it's powered on:
- ON=0
- OFF=1 # 1 for rf_kill, 2 for power/state
- for CONTROL in $DEVICE/device/rf_kill $DEVICE/device/power/state ; do
- if [ -w $CONTROL ] ; then
- # We have a way of controlling the device, lets try
- if [ "`cat $CONTROL`" = 0 ] ; then
- # It's powered on. Switch it off.
- if echo -n $OFF > $CONTROL ; then
- break
- else
- OFF=2 # for power/state, second time around
- fi
- else
- # It's powered off. Switch it on.
- if echo -n $ON > $CONTROL ; then
- break
- fi
- fi
- fi
- done
- fi
- done
- }
- ##Find and toggle wireless of bluetooth devices on ThinkPads
- BLUETOOTH=/proc/acpi/ibm/bluetooth
- if [ -r $BLUETOOTH ]; then
- grep -q disabled $BLUETOOTH
- bluetooth_state=$?
- fi
- # Note that this always alters the state of the wireless!
- toggleAllWirelessStates;
- # Sequence is Both on, Bluetooth only, Wireless only, Both off
- if ! isAnyWirelessPoweredOn; then
- # Wireless was turned off
- if [ -w $BLUETOOTH ]; then
- if [ "$bluetooth_state" = 0 ]; then
- echo enable > $BLUETOOTH;
- else
- echo disable > $BLUETOOTH
- fi
- fi
- fi
复制代码 使其可执行- chmod a+x /etc/acpi/ibm-wireless.sh
复制代码 重新启动acpid- /etc/init.d/acpid restart
复制代码 到这里便可以通过Fn+F5开关无线网络了。
5、Fn+F4:hibernate-ram和Fn+F12:hibernate
安装hibernate-script并加入boot runlevel- emerge hibernate-script
- rc-update add hibernate-cleanup boot
复制代码 新建/etc/acpi/events/ibm-suspend文件- event=ibm/hotkey HKEY 00000080 00001004
- action=/usr/sbin/hibernate-ram
复制代码 新建/etc/acpi/events/ibm-hibernate文件- event=ibm/hotkey HKEY 00000080 0000100c
- action=/usr/sbin/hibernate
复制代码 重新启动acpid- /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- echo "app-laptop/tpb xosd" >> /etc/portage/package.use
- emerge app-laptop/tpb
复制代码 如果是gnome,将tpb -d加入senssions
配置~/.tpbrc或/etc/tpbrc,以下设置仅作参考- # Use OSS mixer to change volume and for mute/unmute. This should be use on
- # models with no hardware mixer (volume and mute buttons show no effect). R31
- # is reported to have no hardware mixer. To use this you must enable write
- # access to the NVRAM device (possibly dangerous). Possible values are on and
- # off. Default is off.
- #
- MIXER ON
- ## MIXERSTEPS
- # Defines how much steps should be available when using the OSS mixer. Default
- # is 14. If an other number of steps is used, tpb needs write access to the
- # nvram device.
- #
- #MIXERSTEPS 14
- ## MIXERDEVICE
- # Defines the mixer device to use for OSS mixer support. Default is /dev/mixer.
- #
- #MIXERDEVICE /dev/mixer
- ### POWERMANAGEMENT SETTINGS
- ## APM
- # Some ThinkPads generate mouse and keyboard events or have a high CPU load when
- # polling /proc/apm. You may enable this, if you want the AC connected/AC
- # disconnected messages. Default is off.
- #
- #APM OFF
- ## POWERMGT
- # The program apmiser (part of tpctl package) switches the power management
- # mode according to the needs of the user. This results in lots of changes
- # displayed in OSD. To avoid this, the power management messages can be turned
- # off. Default is auto.
- #
- #POWERMGT AUTO
- ### X11 SETTINGS
- ## XEVENTS
- # Some of the special keys generate X11 events instead of changing the nvram. TPB
- # is able to grab those keys and run an application. However some people like to
- # use the X11 events through xmodmap or the like. This option turns off the
- # grabbing of the events. Affected keys are HOME, SEARCH, MAIL, FAVORITES,
- # RELOAD, ABORT, BACKWARD, FORWARD and FN. Default is on.
- #
- #XEVENTS OFF
- ### ON-SCREEN DISPLAY SETTINGS
- ## OSD
- # Global switch for showing on-screen display for volume, mute and brightness.
- # Possible values are on and off. Default is on.
- #
- #OSD ON
- ## OSDZOOM
- # Specific switch for showing on-screen display for zoom button.
- # Possible values are on and off. Default is unset, follows the OSD option.
- #
- #OSDZOOM OFF
- ## OSDTHINKLIGHT
- # Specific switch for showing on-screen display for thinklight button.
- # Possible values are on and off. Default is unset, follows the OSD option.
- #
- #OSDTHINKLIGHT OFF
- ## OSDDISPLAY
- # Specific switch for showing on-screen display for display output button.
- # Possible values are on and off. Default is unset, follows the OSD option.
- #
- #OSDDISPLAY OFF
- ## OSDHVEXPANSIOFF
- # Specific switch for showing on-screen display for HV expansion button.
- # Possible values are on and off. Default is unset, follows the OSD option.
- #
- #OSDHVEXPANSION OFF
- ## OSDBRIGHTNESS
- # Specific switch for showing on-screen display for brightness buttons.
- # Possible values are on and off. Default is unset, follows the OSD option.
- #
- #OSDBRIGHTNESS OFF
- ## OSDVOLUME
- # Specific switch for showing on-screen display for ivolume and mute buttons.
- # Possible values are on and off. Default is unset, follows the OSD option.
- #
- #OSDVOLUME OFF
- ## OSDPOWERMGT
- # Specific switch for showing on-screen display for ipower management changes.
- # Possible values are on and off. Default is unset, follows the OSD option.
- #
- #OSDPOWERMGT OFF
- ## OSDFONT
- # Defines the font for the on-screen display. You may use "xfontsel" to choose
- # one. Default is the default font of the xosd library.
- #
- #OSDFONT -*-lucidatypewriter-*-*-*-*-*-240-*-*-*-*-*-*
- OSDFONT -adobe-helvetica-*-r-*-*-12-*-*-*-*-*-iso10646-1
- ## OSDCOLOR
- # Defines the color of the on-screen display. You may use "xcolors" to choose
- # one. Default is BLUE.
- #
- OSDCOLOR Blue
- ## OSDTIMEOUT
- # Defines how long (in seconds) the on-screen display is shown after the last
- # keys was pressed. Default is 3.
- #
- #OSDTIMEOUT 3
- ## OSDOFFSET
- # For backward compatibility. Same as OSDVERTICAL.
- #
- OSDOFFSET 25
- ## OSDSHADOW
- # Defines the offset of the font shadow in pixels. Default is 2.
- #
- OSDSHADOW 0
- ## OSDSHADOWCOLOR
- # Defines the color of the shadow of the on-screen display. You may use
- # "xcolors" to choose one. Default is BLACK.
- #
- #OSDSHADOWCOLOR BLACK
- ## OSDOUTLINE
- # Defines the width of the font outline in pixels. Default is 1.
- #
- OSDOUTLINE 0
- ## OSDOUTLINECOLOR
- # Defines the color of the outline of the on-screen display. You may use
- # "xcolors" to choose one. Default is BLACK.
- #
- #OSDOUTLINECOLOR BLACK
- ## OSDVERTICAL
- # Defines the offset from the top or bottom of the screen in pixels. Default is 25.
- #
- OSDVERTICAL 50
- ## OSDHORIZONTAL
- # Defines the offset from the left or right of the screen in pixels. Only
- # supported by xosd 2.0.0 and above. Default is 25.
- #
- OSDHORIZONTAL 100
- ## OSDPOS
- # Defines where the osd is shown. Possible values are top, middle and bottom.
- # The value middle is only supported by xosd 2.0.0 and above. Default is bottom.
- #
- OSDPOS bottom
- ## OSDALIGN
- # Defines the alignment of the osd. Possible values are left, center and right.
- # Default is left.
- #
- #OSDALIGN LEFT
复制代码
7、注意事项
i、如果使用gnome,需取消gnome快捷键的设置,否则会出现休眠待机两次的情况,具体处理如下:
在你使用的用户下执行gconf-editor,将如下两项的键值设为nothing- /apps/gnome-power-manager/action_button_hibernate
- /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文件- clear mod2
- keycode 77 = Num_Lock
- add mod2 = Num_Lock
复制代码 执行# xmodmap ~/.xmodmaprc,然后按Shift+NumLk数字灯会亮,实现小数字键盘功能
要实现每次重启后自动生效,在~/.xintirc中添加: |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|