概括

概括

概括

我切换到 i3wm 并且正在尝试设置我的环境。我使用的是 Apple 键盘(大约 2007 年)。它有三个音量键,我找不到它们的映射键码。

分析

我阅读了其他一些有关如何确定密钥代码的在线指南。我尝试用它xev来找出这些键是什么,但它没有返回给我一个键码……只有一个似乎没有意义的输出。

FocusOut event, serial 33, synthetic NO, window 0x2200001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 33, synthetic NO, window 0x2200001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 33, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

FocusOut event, serial 33, synthetic NO, window 0x2200001,
    mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 33, synthetic NO, window 0x2200001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 33, synthetic NO, window 0x0,
    keys:  2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

前三个“块”来自按“音量增大”键,后三个“块”来自按“音量减小”键。从这些信息中,我无​​法弄清楚键码是什么,以便我可以为系统中的卷进行映射。

在此之前,我使用的是 GNOME (Fedora 25),GNOME 能够正确使用音量键。所以我不认为这是内核无法检测到密钥的问题,因为不知何故,GNOME 能够做到这一点。

预期行为

  1. 按“音量减”键xev
  2. 获取密钥代码
  3. 添加到 i3wm 配置的绑定
    • bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5% # Increase sound volume
    • bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5% # Decrease sound volume
    • bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # Mute sound
  4. 使用音量键调节系统音量

实际行为

  1. 按“音量减”键xev
  2. 收到不同的输出,似乎没有密钥代码

答案1

我假设您使用的是通过 USB 连接的键盘。这意味着你必须使用测试通过evtest /dev/input/eventX。要找出哪个数字是“X”,请使用ls -l /dev/input/by-id。就我而言,它看起来像:

sudo evtest /dev/input/event6
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x5ac product 0x205 version 0x110
Input device name: "Mitsumi Electric Apple Extended USB Keyboard"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 113 (KEY_MUTE)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
    Event code 142 (KEY_SLEEP)
    Event code 143 (KEY_WAKEUP)
    Event code 150 (KEY_WWW)
    Event code 155 (KEY_MAIL)
    Event code 161 (KEY_EJECTCD)
    Event code 163 (KEY_NEXTSONG)
    Event code 164 (KEY_PLAYPAUSE)
    Event code 165 (KEY_PREVIOUSSONG)
    Event code 166 (KEY_STOPCD)
    Event code 168 (KEY_REWIND)
    Event code 208 (KEY_FASTFORWARD)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1484112801.351497, type 4 (EV_MSC), code 4 (MSC_SCAN), value c00ea
Event: time 1484112801.351497, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
Event: time 1484112801.351497, -------------- SYN_REPORT ------------
Event: time 1484112801.479485, type 4 (EV_MSC), code 4 (MSC_SCAN), value c00ea
Event: time 1484112801.479485, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 0
Event: time 1484112801.479485, -------------- SYN_REPORT ------------

相关内容