Gnome On Xorg 配置多功能鼠标侧键

1. 安装xbindkeys、xdotool

sudo pacman -S xbindkeys xdotool

2. 生成默认的xbindkeys配置文件:

$ xbindkeys -d > ~/.xbindkeysrc

3. 编辑~/.xbindkeysrc,定义鼠标侧键功能。增加如下定义:

"xdotool key --clearmodifiers Page_Up"
 b:9
 "xdotool key --clearmodifiers Page_Down"
 b:8

4. 设置xbindkeys自启动。编辑~/.xprofile,内容如下:

#!/bin/bash
xbindkeys &

参考:

https://wiki.archlinux.org/index.php/Xbindkeys

http://zzss.cf/?p=5290

Gnome On Wayland 配置多功能鼠标侧键

参考1:wayland-mouse-mapper

安装libinput、evemu,并下载mousemapper.sh和mousemapper.service。

sudo pacman -S libinput evemu
wget https://github.com/mathportillo/wayland-mouse-mapper/raw/master/mousemapper.sh
wget https://raw.githubusercontent.com/mathportillo/wayland-mouse-mapper/master/mousemapper.service

修改mousemapper.sh默认配置,将鼠标侧键功能改为PAGEUP、PAGEDOWN:

# COMMANDS MAP
# BTN_EXTRA=(KEY_LEFTMETA KEY_PAGEUP)
# BTN_SIDE=(KEY_LEFTMETA KEY_PAGEDOWN)
BTN_EXTRA=(KEY_PAGEUP)
BTN_SIDE=(KEY_PAGEDOWN)

用root权限启动:

chmod +x mousemapper.sh
sudo ./mousemapper.sh

测试发现,按鼠标侧键时,可上下翻页,但浏览器中的网页会切换到上一页或下一页。

参考2:ubuntu 14.04配置多功能鼠标

安装xinput、xev

sudo pacman -S xorg-xinput xorg-xev

然后找到鼠标设备id:

$ xinput list | grep 'id='
WARNING: running xinput against an Xwayland server. See the xinput man page for details.
 ⎡ Virtual core pointer                        id=2    [master pointer  (3)]
 ⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
 ⎜   ↳ xwayland-pointer:17                         id=6    [slave  pointer  (2)]
 ⎜   ↳ xwayland-relative-pointer:17                id=7    [slave  pointer  (2)]
 ⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
     ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
     ↳ xwayland-keyboard:17                        id=8    [slave  keyboard (3)]

猜测鼠标设备id=6。获取其button-map:

$ xinput get-button-map 6
WARNING: running xinput against an Xwayland server. See the xinput man page for details.
1 2 3 4 5 6 7 8 9 10

获取鼠标侧键的键值:

$ xev |grep button
    state 0x0, button 9, same_screen YES
    state 0x0, button 9, same_screen YES
    state 0x0, button 8, same_screen YES
    state 0x0, button 8, same_screen YES

确定两个侧键键值为:上=9,下=8。

设置button-map,屏蔽8和9两个键,避免浏览器前后翻页:

$ xinput set-button-map 6 1 2 3 4 5 6 7 0 0 10

再次测试,功能正常。

最后按mousemapper主页,将其转为service:

sudo cp mousemapper.sh /usr/bin/mousemapper
sudo cp mousemapper.service /usr/lib/systemd/system/
sudo systemctl enable mousemapper.service
sudo systemctl start mousemapper.service

DONE !

manjaro-xfce使用鼠标侧键

1. 安装xbindkeys和xdotool

pacman -S xbindkeys xdotool xorg-xev

2. 找到鼠标侧键键码

xev

点击两个鼠标侧键,输出为:

ButtonPress event, serial 37, synthetic NO, window 0x4600001,
     root 0x16a, subw 0x0, time 2359097, (105,76), root:(816,450),
     state 0x0, button 9, same_screen YES
 ButtonRelease event, serial 37, synthetic NO, window 0x4600001,
     root 0x16a, subw 0x0, time 2359243, (105,76), root:(816,450),
     state 0x0, button 9, same_screen YES
 ButtonPress event, serial 37, synthetic NO, window 0x4600001,
     root 0x16a, subw 0x0, time 2370571, (105,76), root:(816,450),
     state 0x0, button 8, same_screen YES
 ButtonRelease event, serial 37, synthetic NO, window 0x4600001,
     root 0x16a, subw 0x0, time 2370691, (105,76), root:(816,450),
     state 0x0, button 8, same_screen YES

其中,button 9为上键,button 8为下键。

3. 编辑.xbindkeysrc文件

xbindkeys -d > ~/.xbindkeysrc
vim ~/.xbindkeyrc

在文件中加入:

"xdotool key Page_Up"
  b:9
"xdotool key Page_Down"
  b:8

保存退出,测试:

xbindkeys -p

侧键翻页功能生效。

4. 加入自启动

编辑~/.xprofile文件,加入一行:

xbindkeys


https://forum.manjaro.org/t/how-do-i-set-up-extra-mouse-buttons/59291