特殊:Badtitle/NS100:G7Mouse

来自Ubuntu中文
Wikibot留言 | 贡献2008年10月19日 (日) 15:16的版本
跳到导航跳到搜索
可打印版本不再受到支持且可能有渲染错误。请更新您的浏览器书签并改用浏览器默认打印功能。

{{#ifexist: :G7Mouse/zh | | {{#ifexist: G7Mouse/zh | | {{#ifeq: {{#titleparts:G7Mouse|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:G7Mouse|1|-1|}} | zh | | }}

This content is quite old and may not be applicable to current versions of Ubuntu. (please remove this note if the page is updated)

Logitech G7 Mouse

The following describes how to configure the Logitech G7 Laser Cordless Mouse. Code was originally designed for Ubuntu 5.10 "The Breezy Badger". The Logitech receiver needs to be plugged into an USB port directly on the PC.

Edit xorg.conf file

First we'll tell X how to recognize our G7.

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_backup
gksudo gedit /etc/X11/xorg.conf

Scroll down until you find the mouse section, something like:

Section "InputDevice"
	Identifier	"Configured Mouse"

REPLACE the entire mouse section from "Section "Input Device"" to "End Section" with the following:

Section "InputDevice"
	Identifier	"Configured Mouse"
	Driver		"mouse"
	Option		"Protocol"		"evdev"
	Option       	"Dev Name"		"Logitech USB Receiver"
	Option		"Device"		"/dev/input/mice"
	Option		"Buttons"		"8"
	Option		"ZAxisMapping"		"4 5 7 8"
EndSection

Save the file.

Restart X

First bookmark this page because you will need to come back to finish. Then write down the following steps:

  1. Log out as usual.
  2. Simultaneously press "Control + Alt + Backspace"
  3. If the mouse cursor moves like it should, log back in and proceed to the next section.

If the mouse cursor won't move, simultaneously press "CONTROL + ALT + F1" and type the following to restore your prior settings:

sudo cp /etc/X11/xorg.conf_backup /etc/X11/xorg.conf
sudo restartx

Configure key-bindings

First install xvkbd and xvindkeys:

sudo apt-get install xvkbd xbindkeys
gedit ~/.xbindkeysrc

You then have two choices of code to enter. The following code will

  1. Allow the mouse "back" button to go back in Nautilus.
  2. Allow the left/right tilt on the scroll wheel to scroll text left and right in programs such as Firefox when applicable.

Copy and paste the following:

"/usr/X11R6/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]""
  m:0x0 + b:6
"/usr/X11R6/bin/xvkbd -xsendevent -text "\[right]""
  m:0x0 + b:7
"/usr/X11R6/bin/xvkbd -xsendevent -text "\[left]""
  m:0x0 + b:8

Save the file. OR you can use my preferred code below which will

  1. Allow the mouse "back" button to go back in Nautilus.
  2. Allow the left/right tilt on the scroll wheel to move through open tabs in Firefox! :)

Copy and paste the following:

"/usr/X11R6/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]""
  m:0x0 + b:6
"/usr/X11R6/bin/xvkbd -xsendevent -text "\[Control_L]\[Page_Down]""
  m:0x0 + b:7
"/usr/X11R6/bin/xvkbd -xsendevent -text "\[Control_L]\[Page_Up]""
  m:0x0 + b:8

Save the file. Finally, go to "System > Preferences > Sessions", click on the "Startup Programs" tab, click "+Add" and enter "xbindkeys" as a Startup Command. Log out, then log in again and run a final test. Bonus: You do not need the "Logitech Applet" as you can change the sensitivity settings directly on the G7 mouse by pressing the "+" and "-" buttons on the mouse next to the scroll wheel. B)

Delayed Switching

With the settings above, the tab switching can happen to fast. To circumvent this, create two files /usr/bin/xctlpageup.sh

#!/bin/bash
if [ ! -f /tmp/pageup.lok ]; then
 touch /tmp/pageup.lok
 /usr/X11R6/bin/xvkbd -xsendevent -text "\[Control_L]\[Page_Up]"
 sleep 0.1
 rm -f /tmp/pageup.lok
else
 sleep 1
 rm -f /tmp/pageup.lok
fi

and /usr/bin/xctlpagedown.sh

#!/bin/bash
if [ ! -f /tmp/paged.lok ]; then
 touch /tmp/paged.lok
 /usr/X11R6/bin/xvkbd -xsendevent -text "\[Control_L]\[Page_Down]"
 sleep 0.1
 rm -f /tmp/paged.lok
else
 sleep 1
 rm -f /tmp/paged.lok
fi

chmod a+x this two, to make them executeable. change your .xbindkeysrc to

"/usr/X11R6/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]" "
  m:0x0 + b:8
"/bin/bash /usr/bin/xctlpageup.sh"
  m:0x0 + b:7
"/bin/bash /usr/bin/xctlpagedown.sh"
  m:0x0 + b:6

The tilt wheel then calls the scripts that will lock restrict itself to one call per 0.1 second. The second cause in the shell scripts is for removing lost lok files.