|
Debian testing, KDE, xorg,
罗技Logitech MX310鼠标,共六键。
简单总结如下:
1. 修改 /etc/X11/xorg.conf
...
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option " rotocol" "ExplorerPS/2"
Option "Device" "/dev/input/mice"
Option "Buttons" "9"
Option "Emulate3Buttons" "false"
Option "ZAxisMapping" "6 7"
EndSection
...
2.建立~/.kde/Autostart/xmodmap 文件
内容:
#!/bin/sh
xmodmap -e "pointer = 1 2 3 6 7 4 5 8 9"
重启X即可
参考工具: xev (用来在X下查看鼠标击键事件的程序)
参考资源:
http://gentoo-wiki.com/HOWTO_Mouse_Nav_Buttons
==============
Contents
* 1 Introduction
* 2 Xfree/Xorg Config
* 3 .xinitrc
* 4 KDM and KDE
* 5 GDM and GNOME
* 6 imwheel
* 7 BONUS
* 8 Final Notes
[edit]
Introduction
This is a HOWTO guide based on one from the Gentoo Forums. It was written by meowsqueak, and I've had great success with it. Here's a link to the thread in the forums.
Do you have one of those mice with the extra thumb buttons? Ever wondered how to get those buttons working in X, or how to get the scroll wheel working? Wonder no more...
For Microsoft mice, you usually have to use the USB interface (not going through the green USB -> PS/2 converter) in order to get the extra buttons to work. (I am not sure this is accurate -- meowsqueak)
So far, this HOWTO has been verified with the Microsoft Explorer, Intellimouse, the Logitech MX500, MX700, and MX900, and the Kensington PilotMouse Optical Wireless brand name mice.
[edit]
Xfree/Xorg Config
A typical configuration for such mice often looks like this [XF86Config | XOrg]:
File: /etc/X11/XF86Config or /etc/X11/xorg.conf
...
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option " rotocol" "ImPS/2"
Option "Device" "/dev/mouse"
Option " rotocol" "auto"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5"
EndSection
...
You may find you don't have an xorg.conf file in /etc/X11, only a xorg.conf.example (like me). Look here for help on generating one first.
This typically gives you the usual three-button X mouse and a scroll wheel. With the above configuration, the extra mouse buttons do nothing, and don't even generate X events.
Run the program xev in an XTerm. Move the mouse over the window that pops up, and click the side buttons. If nothing happens, read on.
First, you need to change your XF86Config file to use a newer protocol called ExplorerPS/2. You also need to tell the mouse driver that there are now seven buttons in total (left, middle, right, wheelup, wheeldown, and, depending on your mouse, side-left and side-right or thumb-forward and thumb-back). You must also tell it to map the ZAxisMapping to buttons 6 and 7, NOT 4 and 5.
Note: Depending on your hardware, the Device location might change. It could also be /dev/input/mice
File: /etc/X11/XF86Config Or /etc/X11/xorg.conf
...
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option " rotocol" "ExplorerPS/2"
Option "Device" "/dev/mouse"
Option "Buttons" "7"
Option "ZAxisMapping" "6 7"
EndSection
...
Ok, now restart your X server and run xev again. Those extra buttons should now emit X events. You'll probably also notice that the extra buttons perform the same functions that the mouse wheel used to. This is because of the new ZAxisMapping.
If you have a Logitech MX310, change the xorg.conf file to read
File: /etc/X11/XF86Config Or /etc/X11/xorg.conf
...
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option " rotocol" "ExplorerPS/2"
Option "Device" "/dev/input/mice"
Option "Buttons" "9"
Option "Emulate3Buttons" "false"
Option "ZAxisMapping" "6 7"
EndSection
...
[edit]
.xinitrc
Now we need to fix the button mapping. The best way to do this is to invoke this command when X starts somewhere (e.g. in your .xinitrc):
File: ~/.xinitrc or
xmodmap -e "pointer = 1 2 3 6 7 4 5"
For XFree86, you can have a global setup:
File: /etc/X11/xinit/.Xmodmap
pointer = 1 2 3 6 7 4 5
Note the order of the numbers - we've swapped 6 and 7 with 4 and 5. After you run this, you'll find your mouse wheel works properly again. Now, returning to xev, you'll see that the side buttons now produce the correct events.
NOTE: If you have followed the 'Gnome Configuration HOWTO' there will be 'exec gnome-session' in your ~/.xinitrc file. Make sure the xmodmap command occurs before this, otherwise it will never execute.
Again, for the MX310
File: /etc/X11/xinit/.Xmodmap
pointer = 1 2 3 6 7 4 5 8 9
[edit]
KDM and KDE
When using KDM and KDE, your .xinitrc may be ignored. To automatically call xmodmap, you can use the Autostart folder of kde
File: ~/.kde/Autostart/xmodmap
#!/bin/sh
xmodmap /etc/X11/xinit/.Xmodmap
Alternatively, you can add the following line to ${kdedir}/share/config/kdm/Xstartup to remap your mouse buttons/wheel:
File: ${kdedir}/share/config/kdm/Xstartup
exec /usr/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"
[edit]
GDM and GNOME
When using GDM your .xinitrc may be ignored. To fix this, use the .Xmodmap loading feature of gdm:
File: ~/.Xmodmap
pointer = 1 2 3 6 7 4 5
You will be prompted by gdm at the next login to enable the new mapping.
[edit]
imwheel
Note: the imwheel daemon is unecessary for the Logitech MX310. Just tell X that you have other buttons (see above) and it will work. Make sure, though, that you set the pointer string correctly (mine is in my .xinitrc file), or your nav-buttons may become your scroll wheel...
Else...
Now run "emerge imwheel" as root. Then switch back to your normal account and create a file called ~/.imwheelrc and put this into it:
File: ~/.imwheelrc
"(null)"
None, Up, Alt_L|Left
None, Down, Alt_L|Right
".*"
None, Up, Alt_L|Left
None, Down, Alt_L|Right
".*" matches any window and the next two lines instruct imwheel on what to do when the buttons are pressed. Button 6 is 'down' and button 7 is 'up' - this doesn't relate to the action of pressing and releasing a button, it is actually because X maps these buttons onto a sort of virtual mousewheel or 'joystick'. The "(null)" entry is necessary for compatibility with some programs, particularly GNOME.
You can replace Alt_L|Left etc with whatever you want. These settings just invoke forward/backward browsing in mozilla/epiphany, like the Windows drivers would with IE.
You can do some pretty fancy stuff with this. I have a slightly enhanced .imwheelrc:
File: ~/.imwheelrc
"mozilla*"
None, Up, Alt_L|Left
None, Down, Alt_L|Right
"XTerm"
None, Up, Alt_L|Control_L|S
None, Down, Alt_L|Control_L|T
# this should be last
".*"
None, Up, Alt_L|Control_L|P
None, Down, Alt_L|Control_L|O
Just remember to put the ".*" entry LAST since imwheel stops looking once it matches an entry.
Those longish Alt_L|Control_L|... sequences match settings in my fluxbox/keys file, which do various things such as open new xterms, ffwd xmms, or open the selected URL in Mozilla.
// personally i've found a rather nice use for the Down button in firefox...assign it to Control_L|W. This lets you hit that thumb button to close the current tab. I have not, however, found the right "*******" name to give it. mozilla* does not work, and neither does firefox*. I use gnome; my guess is its different for each window manager. I currently have ".*" set to None, Down, Control_L|W.
NOTE: If using a Logitech MX700 mouse, you may need to replace "Up" with "Left" and "Down" with "Right" in your .imwheelrc. That is, the thumb-back button is "Left" and the thumb-forward button is "Right".
Now, the final step is to fire up the imwheel program:
Code:
$ imwheel -f -k -p -b "67"
To make it so this happens automatically at login, put this command in your ~/.xinitrc file, right after the xmodmap command.
NOTE: If you are using GDM and GNOME, your ~/.xinitrc may be ignored. To start imwheel at login, when logged into GNOME, go to G->Desktop-> references->Sessions, select the Startup Programs tab, and add a new entry. For the command, use an unadorned "imwheel". Set the priority at 20. This will make imwheel start early upon login.
NOTE: If you're using GDM and KDE, you may have to put the imwheel command in /etc/X11/gdm/Sessions/kde-* instead. (Confirmed?)
Please contribute to the thread at the top of this page if you have further details, or wish to point out errors or inconsistencies. Please also modify this page accordingly.
[edit]
BONUS
Here's a nice little script you can bind to one of your mouse buttons with your window manager. It opens the currently selected text (usually a URL) in a new mozilla or firefox tab. Remove references to wmctrl if you don't like it changing your workspace:
File: clipurl
#!/bin/bash
# opens a new tab at selected URL in mozilla-like browser
#
# Copyright 2004 David Antliff <dave.antliff@paradise.net.nz>
# This program is distributed under the terms of the GPL version 2.
#
# Last changed:
# 20041207
# Where to find/open the browser
DISPLAY=:0.0
SCREEN=7
if test -z "$BROWSER"
then
BROWSER='/usr/bin/mozilla'
fi
# fix URLs that span multiple lines and may have injected spaces
# (e.g. Pine)
URL=`xclip -o | tr '\n' ' ' | sed 's/\s//g'`
echo clipurl: $URL
PING=`$BROWSER -remote 'ping()' 2>&1`
if test -z "$PING"
then
echo $BROWSER: opening new tab
wmctrl -s $SCREEN
$BROWSER -remote "openURL($URL,new-tab)" &
else
echo $BROWSER: starting new session
wmctrl -s $SCREEN
$BROWSER $URL &
fi
[edit]
Final Notes
If you have a bluetooth mouse and all these extra buttons are not working, check out the kernel patches at bluez.org
If you've got a six button mouse, a few things will be different:
pointer = 1 2 3 6 4 5
imwheel -k -b "6"
================= |
|