Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xdotool type takes ages and causes entire desktop to freeze

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 --version xdotool version 3.20160805.1

like image 380
confetti Avatar asked Dec 30 '17 21:12

confetti


2 Answers

I faced the same problem on Xubuntu, so it's not just a GNOME's problem. It looks like the problem is somewhere in the interaction between xserver, proprietary nvidia driver and some compositing managers.

In Xubuntu I solved this issue by disable compositor (Settings Manager > Window Manager Tweaks > Compositor). As a result, tearing began, which is partially treated by this command (added in autostart): nvidia-settings --assign CurrentMetaMode="1920x1080 +0+0 { ForceCompositionPipeline = On }".

Theoretically you can solve this issue by changing video driver or switching from X to Wayland (and from xdotool to ydotool).

like image 187
Beast Winterwolf Avatar answered Nov 10 '22 23:11

Beast Winterwolf


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 want And there is also "pl + an indentation" that will trigger it

enter image description here

like image 31
Benjamin Avatar answered Nov 10 '22 23:11

Benjamin