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
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).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With