参考资料
感谢各位前辈的探索!
正文
映射Copilot键到Ctrl键
阅读本部分前,请先默念:“傻逼微软!”
本文适用于Copilot键对应“按下时执行一次leftmeta + leftshift + f23
,长按无作用,松开无作用”的机型。本部分将其映射为一个500ms内单次有效的rightctrl键。
原始的sudo keyd monitor -t
输出如下:
$ sudo keyd monitor -t
device added: 0001:0001:70533846 AT Translated Set 2 keyboard (/dev/input/event3)
+229 ms AT Translated Set 2 keyboard 0001:0001:70533846 leftmeta down
+3 ms AT Translated Set 2 keyboard 0001:0001:70533846 leftshift down
+10 ms AT Translated Set 2 keyboard 0001:0001:70533846 f23 down
+5 ms AT Translated Set 2 keyboard 0001:0001:70533846 f23 up
+5 ms AT Translated Set 2 keyboard 0001:0001:70533846 leftshift up
+12 ms AT Translated Set 2 keyboard 0001:0001:70533846 leftmeta up
首先装上kmonad
:sudo pacman -S kmonad
然后把这份配置文件存在一个合适的地方,比如~/.config/kmonad/kmonad.kbd
:
(defcfg
;; https://young-lord.github.io/posts/mechrevo-linux-2025 ver.20250727
;; For Linux
input (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd")
output (uinput-sink "Niko's KMonad profile: 机械革命 15X Pro 暴风雪" "/usr/bin/sleep 1 && /usr/bin/setxkbmap -option compose:ralt")
;; cmp-seq rctl ;; Set the compose key to `RightCtrl'
;; cmp-seq-delay 5 ;; 5ms delay between each compose-key sequence press
;; Comment this if you want unhandled events not to be emitted
fallthrough true
;; Set this to false to disable any command-execution in KMonad
allow-cmd true
)
;; niko: TODO: wait for XX to be released, replace Fn and Copilot key with XX
(defsrc
esc f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 prnt del home pgup pgdn end f23
grv 1 2 3 4 5 6 7 8 9 0 - = bspc nlck kp/ kp* kp-
tab q w e r t y u i o p [ ] \ kp7 kp8 kp9 kp+
caps a s d f g h j k l ; ' ret kp4 kp5 kp6
lsft z x c v b n m , . / rsft kp1 kp2 kp3 kprt
lctl lmet lalt spc ralt up kp0 kp.
left down rght
)
(defalias cpt (tap-hold 30 (layer-delay 15 remap-copilot) lmet))
(deflayer default
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
lctl _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
lctl @cpt _ _ _ _ _ _
_ _ _
)
(deflayer remap-copilot
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
(layer-delay 15 remap-copilot-2) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _
)
(deflayer remap-copilot-2
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ (sticky-key 500 rctl)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _
)
然后装个Systemd服务:
cat << EOF | sudo tee /etc/systemd/system/kmonad.service && sudo systemctl enable kmonad
[Unit]
Description=laptop keyboard kmonad
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/kmonad /home/$(whoami)/.config/kmonad/kmonad.kbd
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
EOF
重启电脑,或运行kmonad
服务即可。顺带一提这份配置会把CapsLock
映射为leftctrl
,还原此更改的方法显而易见。
无法休眠(Hibernate)
表现为:休眠后电源灯仍然点亮,只可长按电源键强制关机,开机后无法还原休眠前状态。
请先阅读ArchWiki 对应章节,以及其中引用的best practices to debug suspend issues 一文。
对于我,应用System does not power off when hibernating 一节中的内容即可解决。