“UbuntuHelp:SynapticsTouchpad/ShortcutKey”的版本间的差异
来自Ubuntu中文
小 (新页面: {{From|https://help.ubuntu.com/community/SynapticsTouchpad/ShortcutKey}} {{Languages|UbuntuHelp:SynapticsTouchpad/ShortcutKey}} == Turning Synaptics Touchpads On/Off with a Shortcut Key =...) |
小 |
||
第2行: | 第2行: | ||
{{Languages|UbuntuHelp:SynapticsTouchpad/ShortcutKey}} | {{Languages|UbuntuHelp:SynapticsTouchpad/ShortcutKey}} | ||
== Turning Synaptics Touchpads On/Off with a Shortcut Key == | == Turning Synaptics Touchpads On/Off with a Shortcut Key == | ||
− | |||
− | |||
You may wish to turn the touchpad on or off so that it doesn't interfere with typing when using a USB or other mouse. | You may wish to turn the touchpad on or off so that it doesn't interfere with typing when using a USB or other mouse. | ||
− | |||
Use following steps: | Use following steps: | ||
− | |||
=== Step 1 === | === Step 1 === | ||
− | |||
from a terminal, edit /etc/xorg.conf | from a terminal, edit /etc/xorg.conf | ||
<pre><nowiki> | <pre><nowiki> | ||
第15行: | 第10行: | ||
</nowiki></pre> | </nowiki></pre> | ||
and look for the following section of code: | and look for the following section of code: | ||
− | |||
<pre><nowiki> | <pre><nowiki> | ||
Section "InputDevice" | Section "InputDevice" | ||
第31行: | 第25行: | ||
EndSection | EndSection | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
If you are using an Alps-Touchpad, which you can find out by typing | If you are using an Alps-Touchpad, which you can find out by typing | ||
<pre><nowiki> | <pre><nowiki> | ||
cat /proc/bus/input/devices | cat /proc/bus/input/devices | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
your code section should look like this | your code section should look like this | ||
<pre><nowiki> | <pre><nowiki> | ||
第48行: | 第40行: | ||
EndSection | EndSection | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
You can define some parameters which influence the behaviour of your touchpad. These parameters are presented already in [https://wiki.ubuntu.com/SynapticsTouchpadWartyHowto?highlight=%28touchpad%29]. You can check if your touchpad works correct and you have the correct parameters with | You can define some parameters which influence the behaviour of your touchpad. These parameters are presented already in [https://wiki.ubuntu.com/SynapticsTouchpadWartyHowto?highlight=%28touchpad%29]. You can check if your touchpad works correct and you have the correct parameters with | ||
<pre><nowiki> | <pre><nowiki> | ||
第54行: | 第45行: | ||
</nowiki></pre> | </nowiki></pre> | ||
If everything works fine, the position of your finger will be updated everytime you move it and based on this information you can set your parameters. | If everything works fine, the position of your finger will be updated everytime you move it and based on this information you can set your parameters. | ||
− | |||
− | |||
=== Step 2 === | === Step 2 === | ||
− | |||
Next we will create 3 files - a bash script to turn the touchpad on, one to turn it on, and a python script to use a single key combination for both. At a terminal, <code><nowiki>cd</nowiki></code> to <code><nowiki>/usr/local/bin</nowiki></code> and make a new file: | Next we will create 3 files - a bash script to turn the touchpad on, one to turn it on, and a python script to use a single key combination for both. At a terminal, <code><nowiki>cd</nowiki></code> to <code><nowiki>/usr/local/bin</nowiki></code> and make a new file: | ||
<pre><nowiki> | <pre><nowiki> | ||
第67行: | 第55行: | ||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
− | |||
synclient touchpadoff=1 | synclient touchpadoff=1 | ||
</nowiki></pre> | </nowiki></pre> | ||
第78行: | 第65行: | ||
#!/bin/bash | #!/bin/bash | ||
# | # | ||
− | |||
synclient touchpadoff=0 | synclient touchpadoff=0 | ||
</nowiki></pre> | </nowiki></pre> | ||
第90行: | 第76行: | ||
import os | import os | ||
import string | import string | ||
− | |||
− | |||
def ReadFile(): | def ReadFile(): | ||
myfile = open('/tmp/synclient.tmp', 'rb') | myfile = open('/tmp/synclient.tmp', 'rb') | ||
第97行: | 第81行: | ||
TestString(line) | TestString(line) | ||
myfile.close() | myfile.close() | ||
− | |||
def TestString(string): | def TestString(string): | ||
for word in string.split(): | for word in string.split(): | ||
第103行: | 第86行: | ||
setting = string.split() | setting = string.split() | ||
ChangeState(setting[2]) | ChangeState(setting[2]) | ||
− | |||
− | |||
def ChangeState(current): | def ChangeState(current): | ||
if current == "0": | if current == "0": | ||
第111行: | 第92行: | ||
os.system("synclient touchpadoff=0") | os.system("synclient touchpadoff=0") | ||
os.system("rm /tmp/synclient.tmp") | os.system("rm /tmp/synclient.tmp") | ||
− | |||
def Main(): | def Main(): | ||
ReadFile() | ReadFile() | ||
第117行: | 第97行: | ||
Main() | Main() | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
and finally, change the permissions of these three files: | and finally, change the permissions of these three files: | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo chmod 755 tpon tpoff touchpad.py | sudo chmod 755 tpon tpoff touchpad.py | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
=== Step 3 === | === Step 3 === | ||
− | |||
Next, edit your sudoers files to allow you to execute both scripts without a password. | Next, edit your sudoers files to allow you to execute both scripts without a password. | ||
<pre><nowiki> | <pre><nowiki> | ||
第134行: | 第111行: | ||
</nowiki></pre> | </nowiki></pre> | ||
where {user} is your user name | where {user} is your user name | ||
− | |||
save (in nano hit <CTRL> <o>), and make sure to save it as: <code><nowiki>/etc/sudoers and not /etc/sudoers.tmp</nowiki></code> | save (in nano hit <CTRL> <o>), and make sure to save it as: <code><nowiki>/etc/sudoers and not /etc/sudoers.tmp</nowiki></code> | ||
− | |||
=== Step 4 === | === Step 4 === | ||
− | |||
Alternatively to setup bellow, you might use [https://help.ubuntu.com/community/MultimediaKeys gnome-keybindings](In depth instructions, 4.) or other desktop-dependent tool. | Alternatively to setup bellow, you might use [https://help.ubuntu.com/community/MultimediaKeys gnome-keybindings](In depth instructions, 4.) or other desktop-dependent tool. | ||
− | |||
Next, install xbindkeys | Next, install xbindkeys | ||
<pre><nowiki> | <pre><nowiki> | ||
第156行: | 第129行: | ||
xbindkeys-config | xbindkeys-config | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
edit your file to the shortcut key you want. For example, to be able to switch the touchpad on/off by <Ctrl><F5>, fill in the following, under Edit: | edit your file to the shortcut key you want. For example, to be able to switch the touchpad on/off by <Ctrl><F5>, fill in the following, under Edit: | ||
− | |||
Name: Touchpad On/Off | Name: Touchpad On/Off | ||
Key: Control + F5 | m:0x4 + c:71 | Key: Control + F5 | m:0x4 + c:71 | ||
Action: /usr/local/bin/touchpad.py | Action: /usr/local/bin/touchpad.py | ||
− | |||
then click apply & save & exit | then click apply & save & exit | ||
− | |||
Now that that is done, restart xbindkeys: | Now that that is done, restart xbindkeys: | ||
− | |||
<pre><nowiki> | <pre><nowiki> | ||
xbindkeys | xbindkeys | ||
</nowiki></pre> | </nowiki></pre> | ||
− | |||
You may need to restart X. | You may need to restart X. | ||
− | |||
Remember that each time you restart X, you will need to run xbindkeys again in order for the shortcut to work. Go to System>Preferences>Sessions>Startup Programs> click add type xbindkeys then click ok. | Remember that each time you restart X, you will need to run xbindkeys again in order for the shortcut to work. Go to System>Preferences>Sessions>Startup Programs> click add type xbindkeys then click ok. | ||
− | |||
---- | ---- | ||
[[category:CategoryDocumentation]] [[category:CategoryCleanup]] | [[category:CategoryDocumentation]] [[category:CategoryCleanup]] | ||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2007年11月30日 (五) 21:40的版本
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
目录
Turning Synaptics Touchpads On/Off with a Shortcut Key
You may wish to turn the touchpad on or off so that it doesn't interfere with typing when using a USB or other mouse. Use following steps:
Step 1
from a terminal, edit /etc/xorg.conf
gksudo gedit /etc/X11/xorg.conf
and look for the following section of code:
Section "InputDevice" Identifier "Synaptics Touchpad" Driver "synaptics" Option "SendCoreEvents" "true" Option "Device" "/dev/psaux" Option "Protocol" "auto-dev" Option "HorizScrollDelta" "0" EndSection
and add one more Option at the End of the Section:
Option "SHMConfig" "on" EndSection
If you are using an Alps-Touchpad, which you can find out by typing
cat /proc/bus/input/devices
your code section should look like this
Section "InputDevice" Driver "synaptics" Identifier "TouchPad" Option "SendCoreEvents" "true" Option "Device" "/dev/input/event2" Option "Protocol" "event" Option "SHMConfig" "on" EndSection
You can define some parameters which influence the behaviour of your touchpad. These parameters are presented already in [1]. You can check if your touchpad works correct and you have the correct parameters with
synclient -m l
If everything works fine, the position of your finger will be updated everytime you move it and based on this information you can set your parameters.
Step 2
Next we will create 3 files - a bash script to turn the touchpad on, one to turn it on, and a python script to use a single key combination for both. At a terminal, cd
to /usr/local/bin
and make a new file:
cd /usr/local/bin gksudo gedit tpoff
and paste the following code in the file, save it and close it.
#!/bin/bash # synclient touchpadoff=1
again, make a new file:
gksudo gedit tpon
paste the following, save and close:
#!/bin/bash # synclient touchpadoff=0
once again, make a new file:
gksudo gedit touchpad.py
paste the following, save and close
#!/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()
and finally, change the permissions of these three files:
sudo chmod 755 tpon tpoff touchpad.py
Step 3
Next, edit your sudoers files to allow you to execute both scripts without a password.
sudo visudo
and add this line
{user} ALL = NOPASSWD: /usr/local/bin/touchpad.py
where {user} is your user name
save (in nano hit <CTRL> <o>), and make sure to save it as: /etc/sudoers and not /etc/sudoers.tmp
Step 4
Alternatively to setup bellow, you might use gnome-keybindings(In depth instructions, 4.) or other desktop-dependent tool. Next, install xbindkeys
sudo apt-get install xbindkeys
when it's done, install xbindkeys-config, the GUI for xbindkeys
sudo apt-get install xbindkeys-config
once each is installed, start both applications:
xbindkeysand
xbindkeys-config
edit your file to the shortcut key you want. For example, to be able to switch the touchpad on/off by <Ctrl><F5>, fill in the following, under Edit: Name: Touchpad On/Off Key: Control + F5 | m:0x4 + c:71 Action: /usr/local/bin/touchpad.py then click apply & save & exit Now that that is done, restart xbindkeys:
xbindkeys
You may need to restart X. Remember that each time you restart X, you will need to run xbindkeys again in order for the shortcut to work. Go to System>Preferences>Sessions>Startup Programs> click add type xbindkeys then click ok.