在我的〜/ .xinitrc中,我通过启动setxkbmap命令来重置键映射:
setxkbmap -option ctrl:nocaps,终止:ctrl_alt_bksp
但是,如果我在X11启动后插入USB键盘,我的USB键盘上的CapsLock键不映射到“CTRL”function,但如果我重新运行上面的命令,它的工作原理。
问题是,我怎么能让这个自动完成? 如果我尝试parsing/ var / log / messages中的内核消息,那么它根本就不是很酷。
欣赏你的答案; -P
观看hal / dbus / udev或您的等价物,并在添加设备后触发脚本。 看看https://askubuntu.com/questions/27948/usb-device-changes-using-udev-and-d-bus和http://packages.python.org/pyudev/api/index.html 。
使用pyudev的示例应用程序
$ python watch_the_mouse.py remove "Logitech USB Optical Mouse" remove "Logitech USB Optical Mouse" remove Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1/2-2.1:1.0/0003:046D:C05A.002F/hidraw/hidraw0') remove Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1/2-2.1:1.0/input/input53') remove Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1/2-2.1:1.0/0003:046D:C05A.002F') remove Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1/2-2.1:1.0') remove Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1') add Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1') add Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1/2-2.1:1.0') add Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1/2-2.1:1.0/input/input54') add Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1/2-2.1:1.0/0003:046D:C05A.0030') add Device(u'/sys/devices/pci0000:00/0000:00:06.1/usb2/2-2/2-2.1/2-2.1:1.0/0003:046D:C05A.0030/hidraw/hidraw0') add "Logitech USB Optical Mouse" add "Logitech USB Optical Mouse"
如果您拥有root权限,则可以在/etc/X11/xorg.conf.d/
中放置一个xorg配置文件(例如60-keyboard-override.conf),该文件包含
Section "InputClass" Identifier "evdev keyboard catchall" MatchIsKeyboard "on" MatchDevicePath "/dev/input/event*" Driver "evdev" Option "XkbOptions" "ctrl:nocaps,terminate:ctrl_alt_bksp" EndSection
要测试它,运行setxkbmap -query
查看是否正在设置选项:
rules: evdev model: pc104 layout: us options: ctrl:nocaps,terminate:ctrl_alt_bksp