我有一个运行FluxBox的Ubuntu 13.10的Macbook Pro。不幸的是,电源按钮在物理上位于我希望删除键所在的退格上方。在OS X中,PowerKey程序可用于重新映射要删除的电源键。如何在X Windows中执行类似操作?
我通过编辑/etc/systemd/logind.conf
和设置禁用了电源键。HandlePowerKey = ignore
在此之后,无需关闭笔记本电脑就可以按电源按钮。
运行xev -event keyboard
表明,电源键的KeyPress通常被另一进程占用:
MappingNotify event, serial 36, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
KeymapNotify event, serial 36, synthetic NO, window 0x0,
keys: 1 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
KeymapNotify event, serial 37, synthetic NO, window 0x0,
keys: 1 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
但是,通过直接从控制台仅运行xterm,我能够成功获取密钥代码并重新映射密钥。
xinit /usr/bin/xterm -- :1
xev -event keyboard | tee /tmp/junk.txt
tail -n ???? /tmp/junk.txt
MappingNotify event, serial 28, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
KeyPress event, serial 28, synthetic NO, window 0x600001,
root 0xa1, subw 0x0, time 720369, (146,89), root:(148,91),
state 0x0, keycode 124 (keysym 0x1008ff2a, XF86PowerOff), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 28, synthetic NO, window 0x600001,
root 0xa1, subw 0x0, time 720369, (146,89), root:(148,91),
state 0x0, keycode 124 (keysym 0x1008ff2a, XF86PowerOff), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
MappingNotify event, serial 29, synthetic NO, window 0x0,
request MappingKeyboard, first_keycode 8, count 248
此时,还可以使用xmodmap映射键。我将其映射到反斜杠,这比删除更容易看到:
xmodmap -e "keycode 124 = backslash bar"
通过将其添加到其中,我几乎无法获得等效的功能来运行,~/.fluxbox/keys
但这既丑陋又缓慢,以至于无法使用。
# Remap the power off to a delete key...
XF86PowerOff :Exec xdotool key Delete
如何与普通窗口管理器同时使用xmodmap或setxkbmap来使用电源按钮?