绑定到快捷键的xdotool命令不起作用 [英] xdotool commands bound to key shortcuts doesnot work

查看:313
本文介绍了绑定到快捷键的xdotool命令不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常喜欢VIM,我想在任何地方都使用它的键绑定.有很多可以模拟此功能的IDE插件,但我想要更多,也许是Minecraft中的VIM绑定? :D或VIM键绑定无处不在,而无需下载任何插件.

I like VIM a lot and I wanted to use it's keybindings everywhere. There are many IDE plugins that can emulate this but I wanted more, maybe VIM keybindings in Minecraft? :D or VIM keybindings everywhere without the need to download any plugin.

我注意到每个编辑器都实现了以下键: Home End Ctrl + End Ctrl + Ctrl + 退格,依此类推...

I noticed that every single editor implements this keys: Home, End, Ctrl+End, Ctrl+Left, Ctrl+Backspace and so on...

我将这些键用作构建块,并为i3wm提出了此配置:

I used these keys as a building blocks and I came up with this config for 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 并向下滚动.

That code snippet works, but not in the way I want it to. If I don't use --release the code does not work at all, because of this keys do not repeat, so it is not possible to hold down on J and scroll down.

这似乎是一个窗口焦点问题.由于某些原因,当我按下键绑定时,该窗口会失去焦点几毫秒,然后再次变为焦点.这在Firefox的网址栏中最为明显.我发现几年前问的这个问题,这建议在执行xdotool之前增加一秒钟的延迟,我可以使用它,但是第二秒钟会产生巨大的输入延迟.

It seems to be a window focus issue. For some reason when I press keybindings, the window loses focus for some milliseconds and then it becomes focused again. This is most obvious in Firefox's Url Bar. I found this question asked years ago, which suggests adding one second delay until xdotool is executed, I could use this but second creates a huge input delay.

我还尝试了其他窗口管理器和热键守护程序sxhkb,但一切都完全相同...

I have also tried other window managers and the hotkey daemon sxhkb but everything is exactly same...

推荐答案

我遇到了同样的问题,并且我意识到您必须告诉xdotool为您的键绑定中的键发送键启动事件.例如:

I had this same issue, and I realized that you have to tell xdotool to send keyup events for the keys in your keybindings. So for example:

bindsym h exec "xdotool keyup h; xdotool key"

对每个绑定都执行此操作,我认为它会起作用.

Do that for every binding and I think it will work.

这篇关于绑定到快捷键的xdotool命令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆