个人工具

“Synaptics触摸板指南”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(New page: == UbuntuChinaTemplate == ---- 原文出处:https://wiki.ubuntu.com/SynapticsTouchpadHowTo 原文作者:[https://wiki.ubuntu.com/brallan brallan] 授权许可:[http://www.creativec...)
 
使用快捷键来启动/禁用Synaptics触摸板
第169行: 第169行:
 
粘贴下列代码,保存并关闭。
 
粘贴下列代码,保存并关闭。
 
<pre><nowiki>
 
<pre><nowiki>
 +
#!/usr/bin/python
 
import os
 
import os
 
import string
 
import string

2008年11月16日 (日) 03:36的版本

UbuntuChinaTemplate


原文出处:https://wiki.ubuntu.com/SynapticsTouchpadHowTo

原文作者:brallan

授权许可:创作共用协议

翻译人员:ShawnLing

校对人员:

适用版本:Breezy (5.10) and Dapper (6.06)

文章状态:翻译完成


致新手

笔记本电脑上,使用触摸版作为内建鼠标。注意,“Synaptics触摸板”应当与“Synaptic”(Ubuntu的包管理器,即apt-get的图形化用户界面形式)加以区分。

在Breezy (5.10)中,笔记本电脑的触摸板应该立即可用。打开一个终端用grep查看您的/etc/X11/xorg.conf文件:

grep Id /etc/X11/xorg.conf

如果其中有一行:

        Identifier        "Synaptics Touchpad"

那么,就说明您正在使用一个Synaptics触摸板。

在Dapper flight 7 (6.06)中synaptics触摸板好像会被认成一个摄像头之类的设备,所以触摸板的滚轮功能可能不可用。查看“编辑您的xorg.conf文件以包含Synaptics触摸板驱动”来获取滚轮支持。

qsynaptics(或者KDE中的ksynaptics)是一个允许您设置您的触摸板的图形化用户界面程序。要安装该程序,请在终端中键入:

sudo apt-get install qsynaptics

或者:

sudo apt-get install ksynaptics

您可能需要在每次启动X的时候运行qsynaptics -r。请到“系统>首选项>会话>启动程序”中添加。

Dapper:编辑您的xorg.conf文件以包含Synaptics触摸板驱动

为了获取滚轮支持,您可能需要编辑您的xorg.conf文件。请在终端中键入sudo gedit /etc/X11/xorg.conf。在如下内容之后:

Section "InputDevice"
        Identifier        "Configured Mouse"
        Driver                "mouse"
        Option                "CorePointer"
        Option                "Device"                "/dev/input/mice"
        Option                "Protocol"                "ExplorerPS/2"
        Option                "ZAxisMapping"                "4 5"
        Option                "Emulate3Buttons"        "true"
EndSection

添加如下内容:

Section "InputDevice"
        Identifier        "Synaptics Touchpad"
        Driver                "synaptics"
        Option                "SendCoreEvents"        "true"
        Option                "Device"                "/dev/psaux"
        Option                "Protocol"                "auto-dev"
        Option                "HorizScrollDelta"        "0"
        Option              "SHMConfig"                 "on"
EndSection

there are also a bunch of lines about a wacom tablet, I have commented them out, I am not sure if that is a necessary step. -原作者brallan注

接下来,向下寻找如下内容:

Section "ServerLayout"
        Identifier        "Default Layout"
        Screen                "Default Screen"
        InputDevice        "Generic Keyboard"
        InputDevice        "Configured Mouse"
        InputDevice     "stylus" "SendCoreEvents"
        InputDevice     "cursor" "SendCoreEvents"
        InputDevice     "eraser" "SendCoreEvents"
EndSection

在"Configured Mouse"之后添加:

        InputDevice        "Synaptics Touchpad"

i also commented out the three lines about the wacom: "stylus", "cursor", and "eraser", but I am not sure if this is necessary. -原作者brallan注

重启X:<ctrl> <Backspace>,现在您应该有拥有滚轮支持了。然后安装qsynaptics来更精准地控制您的设备。

使用快捷键来启动/禁用Synaptics触摸板

您有可能想要启用或者禁用触摸板,从而在您使用USB或者其他鼠标的时候不致因触摸板的缘故干扰您打字。请使用如下步骤:

步骤 1

在终端中编辑/etc/xorg.conf

sudo gedit /etc/X11/xorg.conf

找到如下内容:

Section "InputDevice"
        Identifier        "Synaptics Touchpad"
        Driver                "synaptics"
        Option                "SendCoreEvents"        "true"
        Option                "Device"                "/dev/psaux"
        Option                "Protocol"                "auto-dev"
        Option                "HorizScrollDelta"        "0"
EndSection

在Section的最后添加如下的选项:

        Option              "SHMConfig"                 "on"
EndSection

如果您正在使用一个Alps触摸板(您可以通过如下方法确认)

cat /proc/bus/input/devices

您看到的代码应当如下:

Section "InputDevice"
        Driver          "synaptics"
        Identifier          "TouchPad"
        Option                "SendCoreEvents"        "true"
        Option                "Device"                "/dev/input/event2"
        Option                "Protocol"                "event"
        Option          "SHMConfig"             "on"
EndSection

您可以定义一些参数来改变您的触摸板的行为。这些参数已经在[1]中列出。您可以通过如下方法检查您的触摸板是否工作正常,或者您是否使用了正确的参数:

synclient -m l

如果一切正常,您的手指的位置应该能够随您的移动而改变,而且您可以根据这一信息设置您的参数。


步骤 2

接下来,我们会创建三个文件:一个bash脚本来启用触摸板,一个来禁用,以及一个python脚本来使用组合键启用或者禁用。在终端中cd/usr/local/bin下,新建一个文件:

cd /usr/local/bin
sudo gedit tpoff

将下列代码粘贴到文件中,保存并关闭。


synclient touchpadoff=1 

然后,再新建一个文件:

sudo gedit tpon

粘贴下列代码,保存并关闭。


synclient touchpadoff=0

再新建一个文件:

sudo gedit touchpad.py

粘贴下列代码,保存并关闭。

#!/usr/bin/python 
import os
import string
        

def ReadFile():
        myfile = open('/tmp/synclient.tmp', 'rb')
        for line in myfile:
                TestString(line)                
        myfile.close()

def TestString(string):
        for word in string.split():
                if word == "TouchpadOff":
                        setting = string.split()
                        ChangeState(setting[2])
        

def ChangeState(current):    
        if current == "0":
                os.system("synclient touchpadoff=1")
        else:
                os.system("synclient touchpadoff=0")
        os.system("rm /tmp/synclient.tmp")

def Main():
        ReadFile()
os.system("synclient -l > /tmp/synclient.tmp")
Main()

最后,为这三个文件设置访问权限:

sudo chmod 777 tpon tpoff touchpad.py

步骤 3

接下来,编辑您的sudo用户文件,以允许您在无须输入密码的情况下运行那两个脚本。

sudo visudo

加入以下行:

{user}   ALL = NOPASSWD: /usr/local/bin/touchpad.py

注意:{user}代表您的用户名。

保存(在nano中,键入<CTRL> <o>),确保将其保存为/etc/sudoers

步骤 4 接下来,安装xbindkeys

sudo apt-get install xbindkeys

完成后,请安装xbindkeys-config,xbindkeys的图形用户界面

sudo apt-get install xbindkeys-config

安装完成后,请把这两个程序都打开:

xbindkeys
以及
xbindkeys-config

编辑您的文件来定义您想要的快捷键。例如,要使用<Ctrl><F5>来启用/禁用触摸板,在Edit下面填入以下内容:

Name: Touchpad On/Off Key: Control + F5 | m:0x4 + c:71 Action: /usr/local/bin/touchpad.py

然后点击apply,save,exit

这样就完成了,重启xbindkeys:

xbindkeys

您可能需要重新起动X。

请记住,在每次启动X的时候您都需要再次运行xbindkeys来启用快捷键。请到“系统>首选项>会话>启动程序”中添加。

Apple ibook G4

Dapper的全新安装环境下触摸板工作极度缓慢。这个bug已经被修复了,详见此处:[2]。这个修复方案非常简单,只要将如下设置添加到您/etc/X11/xorg.conf中适当的位置,然后重新启动X即可。

Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/input/mice"
Option "Protocol" "auto-dev"
Option "LeftEdge" "0"
Option "RightEdge" "850"
Option "TopEdge" "0"
Option "BottomEdge" "645"
Option "MinSpeed" "0.4"
Option "MaxSpeed" "1"
Option "AccelFactor" "0.03"
Option "FingerLow" "55"
Option "FingerHigh" "60"
Option "MaxTapMove" "20"
Option "MaxTapTime" "100"
Option "TapButton1" "0"
Option "TapButton2" "3"
Option "TabButton3" "2"
Option "HorizScrollDelta" "10"
Option "VertScrollDelta" "30"
Option "SHMConfig" "on"
EndSection