本文介绍了xdotool类型需要很长时间,并且会导致整个桌面冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我过去一直使用 xdotool类型,只是使用 xdotool类型'¯\ _(ツ)_/¯'在快捷方式上键入耸肩.可以,但是总是要花很长时间,并且会导致整个桌面冻结(完全,不仅仅是输入)几秒钟.没打扰我.

现在,我需要一种方法来从文件中读取内容,对其进行处理并将其键入.我想像这样使用xdotool来完成这项任务:

 同时读取URL;做xdotool类型!play $ URL"&&睡觉1&&xdotool键Return&&睡1完成<<(我的命令) 

mycommand 约有20行网址.运行脚本后,我的桌面(gnome3.26,archlinux)完全冻结了.我通过SSHd进入计算机,成功杀死了bash进程,但这对冻结状态没有任何作用.十分钟后,它再次起作用,命令确实运行了(例如,xdotool按预期正确键入了所有内容),但由于鼠标不再起作用,我不得不重新启动X服务器.

我需要一种像 xdotool type 一样自动键入的方式,但是没有这种冻结行为.最好的情况是可以立即输入我通过的整个文本的工具.我想到了一种实现 xclip 的解决方案,然后仅模拟粘贴和输入的按键,但是我认为必须有一个更好的解决方案.

这个关于 xdotool 的问题对我来说已经存在了大约两年了(一直在gnome + archlinux上),直到现在我再也不需要耸耸肩了.因此,我猜测这不仅仅是我使用的版本中的错误.只是为了完整性:

$ xdotool --versionxdotool版本3.20160805.1

解决方案

我发现这是xdotool中的错误:

I've been using xdotool type in the past only to type a shrugface on shortcut using xdotool type '¯\_(ツ)_/¯'. That works, but always takes quite a long time and causes the entire desktop to freeze (entirely, not just input) for a few seconds. Didn't bother me much though.

Now I need a way to read things from a file, manipulate that, and type it out. I wanted to use xdotool for that task like this:

while read URL; do
    xdotool type "!play $URL" && sleep 1 && xdotool key Return && sleep 1
done < <(mycommand)

The mycommand put out around 20 lines of URLs. Once I ran the script my desktop (gnome3.26, archlinux) freezed entirely. I SSHd into the machine killing the bash process (successfully), but that didn't do anything to the frozen state. Ten minutes later it worked again, the command did run (as in, xdotool typed everything correctly as expected) but I had to restart the X server since my mouse wasn't working anymore.

I need a way to type automated like xdotool type does but without this freezing behaviour. The best case would be a tool that types the whole text I pass pretty much instantly. I thought of a solution implementing xclip and then just simulating the key presses for paste and enter, but I think there has to be a better solution.

This issue with xdotool has been present for me for around two years now (always been on gnome + archlinux), until now I never needed it for more than a shrugface though. I'm guessing it's not just a bug in the version I use because of that. Just for completeness:

$ xdotool --versionxdotool version 3.20160805.1

解决方案

I found that it's a bug from xdotool:

https://github.com/jordansissel/xdotool/issues/281

I suggest you to go to something else, this will do exactly what you want without any delay :

https://github.com/autokey/autokey

After instalation you can define a shortcut or an abreviation to type your phrase.

Here I defined alt+z to trigger what you wantAnd there is also "pl + an indentation" that will trigger it

这篇关于xdotool类型需要很长时间,并且会导致整个桌面冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 06:05