2008年12月4日星期四

Synaptics及其他:xorg.conf一些新旧设置

Archlinux的xorg-server升级到1.5.3了,最大的变化是默认启用了hotplugging,简单说就是支持输入设备的热插拔了。各位可以去wiki看看,有很清楚的说明。

反映到xorg.conf就是所有的InputDevice都不需要了,扔这儿吧:

Section "InputDevice"
Identifier "Keyboard0"
Driver "keyboard"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
Option "XkbVariant" ""
EndSection

Section "InputDevice"
Identifier "Serial Mouse"
Driver "mouse"
Option "Protocol" "Microsoft"
Option "Device" "/dev/ttyS0"
Option "Emulate3Buttons" "true"
Option "Emulate3Timeout" "70"
Option "SendCoreEvents" "true"
EndSection
Section "InputDevice"
Identifier "PS/2 Mouse"
Driver "mouse"
Option "Protocol" "auto"
Option "ZAxisMapping" "4 5"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "true"
Option "Emulate3Timeout" "70"
Option "SendCoreEvents" "true"
EndSection

Section "InputDevice"
Identifier "USB Mouse"
Driver "mouse"
Option "Device" "/dev/input/mice"
Option "SendCoreEvents" "true"
Option "Protocol" "IMPS/2"
Option "ZAxisMapping" "4 5"
Option "Buttons" "5"
EndSection
Section "InputDevice"
Driver "synaptics"
Identifier "Touchpad"
Option "Device" "/dev/input/mouse1"
Option "Protocol" "auto-dev"
Option "LeftEdge" "1700"
Option "RightEdge" "5300"
Option "TopEdge" "1700"
Option "BottomEdge" "4200"
Option "FingerLow" "25"
Option "FingerHigh" "30"
Option "MaxTapTime" "180"
Option "MaxTapMove" "220"
Option "VertScrollDelta" "100"
Option "MinSpeed" "0.06"
Option "MaxSpeed" "0.12"
Option "AccelFactor" "0.0010"
Option "SHMConfig" "on"
# Option "Repeater" "/dev/ps2mouse"
Option "CircularScrolling" "on"
Option "CircScrollTrigger" "0"
EndSection
当然,别忘了删除ServerLayout字段中的相关内容。

触摸板synaptics驱动需要安装xf86-input-synaptics,老的不知在哪一次升级的时候被卸掉了,害我折腾了一会儿,也怪我没重新看一下wiki。以下是我的新配置文件:
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.touchpad">
<match key="info.product" contains="SynPS/2 Synaptics TouchPad">
<merge key="input.x11_driver" type="string">synaptics</merge>
<!-- Arbitrary options can be passed to the driver using
the input.x11_options property since xorg-server-1.5. -->
<!-- EXAMPLE:
<merge key="input.x11_options.LeftEdge" type="string">120</merge>
-->
<merge key="input.x11_options.Protocol" type="string">auto-dev</merge>
<merge key="input.x11_options.LeftEdge" type="string">1700</merge>
<merge key="input.x11_options.RightEdge" type="string">5300</merge>
<merge key="input.x11_options.TopEdge" type="string">1700</merge>
<merge key="input.x11_options.BottomEdge" type="string">4200</merge>
<merge key="input.x11_options.FingerLow" type="string">25</merge>
<merge key="input.x11_options.FingerHigh" type="string">30</merge>
<merge key="input.x11_options.MaxTapTime" type="string">180</merge>
<merge key="input.x11_options.MaxTapMove" type="string">220</merge>
<merge key="input.x11_options.VertScrollDelta" type="string">100</merge>
<merge key="input.x11_options.MinSpeed" type="string">0.06</merge>
<merge key="input.x11_options.MaxSpeed" type="string">0.12</merge>
<merge key="input.x11_options.AccelFactor" type="string">0.0010</merge>
<merge key="input.x11_options.SHMConfig" type="string">true</merge>
<merge key="input.x11_options.CircularScrolling" type="string">on</merge>
<merge key="input.x11_options.CircScrollTrigger" type="string">0</merge>
<merge key="input.x11_options.TapButton1" type="string">1</merge>
<merge key="input.x11_options.TapButton2" type="string">2</merge>
<merge key="input.x11_options.TapButton3" type="string">3</merge>
</match>
<match key="info.product" contains="AlpsPS/2 ALPS">
<merge key="input.x11_driver" type="string">synaptics</merge>
</match>
<match key="info.product" contains="appletouch">
<merge key="input.x11_driver" type="string">synaptics</merge>
</match>
<match key="info.product" contains="bcm5974">
<merge key="input.x11_driver" type="string">synaptics</merge>
</match>
</match>
</device>
</deviceinfo>
默认配置是/usr/share/hal/fdi/policy/10osvendor/11-x11-synaptics.fdi,复制到/etc/hal/fdi/policy/,再把老的配置项添加进去。型号(如SynPS/2 Synaptics TouchPad)可以用以下命令查到(参见wiki):
hal-device|grep -B 15 input.x11.driver
如我的机器上显示是这样的:
--
input.x11_options.MaxTapMove = '220' (string)
input.x11_options.VertScrollDelta = '100' (string)
input.x11_options.MinSpeed = '0.06' (string)
linux.sysfs_path = '/sys/class/input/input8/event8' (string)
linux.device_file = '/dev/input/event8' (string)
input.x11_options.MaxSpeed = '0.12' (string)
info.parent = '/org/freedesktop/Hal/devices/platform_i8042_i8042_AUX2_port' (
string)
input.x11_options.AccelFactor = '0.0010' (string)
input.x11_options.SHMConfig = 'true' (string)
input.x11_options.CircularScrolling = 'on' (string)
input.x11_options.CircScrollTrigger = '0' (string)
input.device = '/dev/input/event8' (string)
input.x11_options.TapButton1 = '1' (string)
input.product = 'SynPS/2 Synaptics TouchPad' (string)
input.x11_options.TapButton2 = '2' (string)
input.x11_driver = 'synaptics' (string)


论坛上也有一些配置(15楼)可以参考。

另外,再附送一个小脚本,可以快速开关Synaptics,我把它绑定到了Fn+1:
#!/bin/bash

Status=$(synclient -l | grep TouchpadOff | tr -d [:blank:])

eval $Status

if [ "$TouchpadOff" = "0" ]
then
synclient TouchpadOff=1
elif [ "$TouchpadOff" = "1" ]
then
synclient TouchpadOff=0
fi
另外,好象已经可以不用xorg.conf了,但我的还不行,不知是否没装开源ati驱动的缘故(只有fglrx)。

KDE快捷键与keyboard layout的问题

近日arch的xorg-server升级到1.5.3,默认使用hotplugging。问题是方向键等许多按键失灵了,论坛上说需要在KDE系统设置->地区和语言->键盘布局中使用键盘布局"Evdev-managed keyboard",一试之下,果然好多了。只是系统的一些快捷键依旧无法使用,比如无须确认注销。

系统设置->键盘和鼠标->键盘快捷键重新设置一下,又可使用了。想起这个问题以前配置xmodmap时就碰到过。简单测试一下后,可以确认,键盘布局(映射)必须在KDE启动之前应用,否则就会出现这种情况。虽然有一些其他的考虑,如键盘布局切换后,按键都变了,原来的快捷键可能不是你需要的。但我依然认为这是个Bug(我已经去官网确认了),我们需要全局快捷键机制(比如用于快速切换键盘布局,有人就遇到了麻烦),每个键盘布局也应该可以有自己的快捷键,而不是象现在这样直接罢工。

解决很简单,在上述系统设置中禁用键盘布局,而把它放到.xinitrc中,下面是我的配置:

# SCIM
export LC_ALL=zh_CN.utf8
export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE="scim"
export QT_IM_MODULE="scim"
scim -d

# 键盘设置
xmodmap ~/.Xmodmap

# 关闭触摸板
synclient TouchpadOff=1

# 键盘绑定
xbindkeys &

setxkbmap -keycodes evdev -model evdev

exec startkde