AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1134335
Accepted
Welat
Welat
Asked: 2019-04-17 02:38:37 +0800 CST2019-04-17 02:38:37 +0800 CST 2019-04-17 02:38:37 +0800 CST

如何为 Trackpoint、Trackpad 和 Mouse 分别设置 xbindkey?

  • 772

我在 kUbuntu 18.04 上通过 xbindkeys 配置了我的 Logitech MX-Revolution 鼠标。我在滚轮(左/右滑动)上设置了额外的按钮来播放下一首/上一首歌曲。

我的问题是,我的罗技鼠标上的按键映射相当于在我的触控板上向左/向右滚动(手指滑动)。由于我的联想 Thinkpad 也有一个带有物理鼠标按钮的轨迹点,所以它也相当于在向左/向右移动轨迹点的同时按下鼠标中键。

我如何告诉 xbindkeys,如果我在 Logitech 鼠标上使用按键事件,它应该只播放下一首/上一首歌曲?如何为不同的输入设备分别设置 xbindkeys?

这是我的 .xbindkeysrc 文件:

######### MultimediaControl #########

# backward button => previous song       
"xte 'key XF86AudioPrev'"                
   m:0x0 + b:6                                   

# forward button => next song            
"xte 'key XF86AudioNext'"                
   m:0x0 + b:7

#################################

提前致谢!

mouse multimedia touchpad logitech xbindkeys
  • 1 1 个回答
  • 852 Views

1 个回答

  • Voted
  1. Best Answer
    UnKNOWn
    2019-04-26T09:56:25+08:002019-04-26T09:56:25+08:00

    有一个很棒的工具的解决方法xinput

    在您的情况下,您总共有 3 个鼠标设备,其中 2 个是内置的,一个是您的外接鼠标。

    首先我们需要获取这 3 个设备的 ID。

    1. 跑xinput list

    示例输出:

    pratap@i7-6550U:~$ xinput list
    ⎡ Virtual core pointer                      id=2    [master pointer  (3)]
    ⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
    ⎜   ↳ PixArt USB Optical Mouse                  id=10   [slave  pointer  (2)]
    ⎜   ↳ ETPS/2 Elantech Touchpad                  id=12   [slave  pointer  (2)]
    ⎜   ↳ Logitech USB Receiver Mouse               id=16   [slave  pointer  (2)]
    ⎜   ↳ Logitech USB Receiver Consumer Control    id=17   [slave  pointer  (2)]
    ⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
        ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
        ↳ Power Button                              id=6    [slave  keyboard (3)]
        ↳ Video Bus                                 id=7    [slave  keyboard (3)]
        ↳ Video Bus                                 id=8    [slave  keyboard (3)]
        ↳ Power Button                              id=9    [slave  keyboard (3)]
        ↳ AT Translated Set 2 keyboard              id=11   [slave  keyboard (3)]
        ↳ Toshiba input device                      id=13   [slave  keyboard (3)]
        ↳ Logitech USB Receiver                     id=14   [slave  keyboard (3)]
        ↳ Logitech USB Receiver System Control      id=15   [slave  keyboard (3)]
        ↳ Logitech USB Receiver Consumer Control    id=18   [slave  keyboard (3)]
    pratap@i7-6550U:~$ 
    

    我有 3 个设备是鼠标输入

    1. PixArt USB 光电鼠标 id=10
    2. ETPS/2 Elantech 触摸板 id=12
    3. 罗技 USB 接收器鼠标 id=16

    例如,当罗技 USB 接收器鼠标 id=16 鼠标滚轮向上和鼠标滚轮向下时,我想绑定两个命令,即按钮 b:4 和 b:5

    如果我的~/.xbindkeysrc内容如下所示,所有 3 台设备都将执行相同的功能。

    ######### MultimediaControl #########
    
    # backward button => my Command       
    "gnome-control-center"                
       m:0x0 + b:4                                   
    
    # forward button => my Command            
    "gnome-tweaks"                
       m:0x0 + b:5
    
    #####################################
    
    1. 运行xmodmap -pp并查看有多少按钮可用。

    从man xmodmap

           -pp     This option indicates that the current  pointer  map  should  be  printed  on  the
               standard output.
    

    示例输出xmodmap -pp

    pratap@i7-6550U:~$ xmodmap -pp
    There are 20 pointer buttons defined.
    
        Physical        Button
         Button          Code
            1              1
            2              2
            3              3
            4              4
            5              5
            6              6
            7              7
            8              8
            9              9
           10             10
           11             11
           12             12
           13             13
           14             14
           15             15
           16             16
           17             17
           18             18
           19             19
           20             20
    
    pratap@i7-6550U:~$ 
    

    这意味着即使我们没有 20 个物理按钮,我们也可以配置特定按钮来执行这 20 个中的其他按钮的操作。

    1. 现在修改~/.xbindkeysrc文件内容,如下所示。

    内容:

    ######### MultimediaControl #########
    
    # backward button => my Command       
    "gnome-control-center"                
       m:0x0 + b:19                                   
    
    # forward button => my Command            
    "gnome-tweaks"                
       m:0x0 + b:20
    
    #####################################
    
    1. 跑killall xbindkeys; xbindkeys

    所以现在很清楚,如果我按下 b:19 和 b:20,我的命令就会运行。

    现在的诀窍是将 id=16 b:4 和 b:5 的罗技鼠标物理按钮的按钮映射到 b:19 和 b:20

    从man xinput

       --set-button-map device map_button_1 [map_button_2 [...]]
               Change  the  button mapping of device. The buttons are specified in physical order
               (starting with button 1) and are mapped to the logical button provided. 0 disables
               a button. The default button mapping for a device is 1 2 3 4 5 6 etc.
    
    1. 跑xinput --set-button-map 16 1 2 3 19 20

    例子:

    pratap@i7-6550U:~$ xinput --set-button-map 16 1 2 3 19 20
    pratap@i7-6550U:~$ 
    

    完成,现在您可以~/.xbindkeysrc使用罗技鼠标滚轮向上和向下运行您的两个命令,而其他两个设备具有向上和向下滚动的原始功能。

    此按钮映射在注销或重新启动后不会持续存在。

    1. 添加此命令xinput --set-button-map 16 1 2 3 19 20以在系统启动时运行。

    请注意,如果您以后更改罗技鼠标的 USB 插槽,id 可能与 xinput 列表不同,这将不起作用。您需要获取 id 并在启动命令中更改它。

    • 2

相关问题

  • Firefox 鼠标中键滚动

  • 如何为不同的鼠标设置不同的设置?

  • 为什么默认不包含多媒体编解码器?

  • Ubuntu 和交互式媒体安装

  • 什么可能会阻止 xrandr 屏幕之间的鼠标移动?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve