绑定到快捷键的 xdotool 命令不起作用
xdotool commands bound to key shortcuts doesnot work
我非常喜欢 VIM,我想在任何地方都使用它的快捷键。有很多 IDE 插件可以模拟这个,但我想要更多,也许是 Minecraft 中的 VIM 键绑定? :D 或 VIM 键绑定无处不在,无需下载任何插件。
我注意到每个编辑器都实现了这些键:Home、End、Ctrl +结束, Ctrl+左, Ctrl+退格等等...
我将这些键用作构建块,并为 i3wm 想出了这个配置:
mode "VIM MODE NORMAL" {
bindsym --release h exec "xdotool key --clearmodifiers Left"
bindsym --release j exec "xdotool key --clearmodifiers Down"
bindsym --release k exec "xdotool key --clearmodifiers Up"
bindsym --release l exec "xdotool key --clearmodifiers Right"
bindsym --release Shift H exec "xdotool key --clearmodifiers Home"
bindsym --release Shift L exec "xdotool key --clearmodifiers End"
bindsym --release Shift G exec "xdotool key --clearmodifiers ctrl+End"
bindsym --release g exec "xdotool key --clearmodifiers ctrl+Home"
bindsym --release u exec "xdotool key --clearmodifiers --repeat 5 Up"
bindsym --release d exec "xdotool key --clearmodifiers --repeat 5 Down"
bindsym --release b exec "xdotool key --clearmodifiers ctrl+Left"
bindsym --release e exec "xdotool key --clearmodifiers ctrl+Right"
bindsym --release Shift O exec "xdotool key --clearmodifiers Up End Return"; mode "delault"
bindsym --release o exec "xdotool key --clearmodifiers End Return"; mode "default"
bindsym --release Shift A exec "xdotool key --clearmodifiers End"; mode "default"
bindsym --release Shift I exec "xdotool key --clearmodifiers Home"; mode "default"
bindsym q mode "default"
bindsym Escape mode "default"
}
bindsym Menu mode "VIM MODE NORMAL"
该代码片段有效,但不是我想要的方式。如果我不使用 --release
代码根本不起作用,因为这个键不重复,所以不可能按住 J 并向下滚动.
这似乎是一个 window 焦点问题。出于某种原因,当我按下键绑定时,window 失去焦点几毫秒,然后再次聚焦。这在 Firefox 的 Url 栏中最为明显。我发现 this question asked years ago,这表明在执行 xdotool
之前增加一秒延迟,我可以使用它,但第二个会产生巨大的输入延迟。
我也试过其他 window 管理器和热键守护进程 sxhkb
但一切都完全一样...
我有同样的问题,我意识到你必须告诉 xdotool 为你的键绑定中的键发送 keyup 事件。例如:
bindsym h exec "xdotool keyup h; xdotool key"
对每个绑定都这样做,我认为它会起作用。
我非常喜欢 VIM,我想在任何地方都使用它的快捷键。有很多 IDE 插件可以模拟这个,但我想要更多,也许是 Minecraft 中的 VIM 键绑定? :D 或 VIM 键绑定无处不在,无需下载任何插件。
我注意到每个编辑器都实现了这些键:Home、End、Ctrl +结束, Ctrl+左, Ctrl+退格等等...
我将这些键用作构建块,并为 i3wm 想出了这个配置:
mode "VIM MODE NORMAL" {
bindsym --release h exec "xdotool key --clearmodifiers Left"
bindsym --release j exec "xdotool key --clearmodifiers Down"
bindsym --release k exec "xdotool key --clearmodifiers Up"
bindsym --release l exec "xdotool key --clearmodifiers Right"
bindsym --release Shift H exec "xdotool key --clearmodifiers Home"
bindsym --release Shift L exec "xdotool key --clearmodifiers End"
bindsym --release Shift G exec "xdotool key --clearmodifiers ctrl+End"
bindsym --release g exec "xdotool key --clearmodifiers ctrl+Home"
bindsym --release u exec "xdotool key --clearmodifiers --repeat 5 Up"
bindsym --release d exec "xdotool key --clearmodifiers --repeat 5 Down"
bindsym --release b exec "xdotool key --clearmodifiers ctrl+Left"
bindsym --release e exec "xdotool key --clearmodifiers ctrl+Right"
bindsym --release Shift O exec "xdotool key --clearmodifiers Up End Return"; mode "delault"
bindsym --release o exec "xdotool key --clearmodifiers End Return"; mode "default"
bindsym --release Shift A exec "xdotool key --clearmodifiers End"; mode "default"
bindsym --release Shift I exec "xdotool key --clearmodifiers Home"; mode "default"
bindsym q mode "default"
bindsym Escape mode "default"
}
bindsym Menu mode "VIM MODE NORMAL"
该代码片段有效,但不是我想要的方式。如果我不使用 --release
代码根本不起作用,因为这个键不重复,所以不可能按住 J 并向下滚动.
这似乎是一个 window 焦点问题。出于某种原因,当我按下键绑定时,window 失去焦点几毫秒,然后再次聚焦。这在 Firefox 的 Url 栏中最为明显。我发现 this question asked years ago,这表明在执行 xdotool
之前增加一秒延迟,我可以使用它,但第二个会产生巨大的输入延迟。
我也试过其他 window 管理器和热键守护进程 sxhkb
但一切都完全一样...
我有同样的问题,我意识到你必须告诉 xdotool 为你的键绑定中的键发送 keyup 事件。例如:
bindsym h exec "xdotool keyup h; xdotool key"
对每个绑定都这样做,我认为它会起作用。