8

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

confetti
  • 1,062
  • 2
  • 12
  • 27
  • This Q is not about programming as defined for StackOverflow. It **may** be more appropriate on http://superuser.com or another StackExchange site. Use the `flag` link at the bottom of your Q and ask the moderator to move it. Please don't post the same Q on 2 different sites. ***Please*** read https://stackoverflow.com/help/on-topic , https://stackoverflow.com/help/how-to-ask , https://stackoverflow.com/help/dont-ask and https://stackoverflow.com/help/mcve before posting more Qs here. GoodLuck – shellter Dec 30 '17 at 22:36
  • 1
    I think it is appropriate on StackOverflow since I need a way to do it programatically. I need this kind of automation to be controlled using bash. – confetti Dec 30 '17 at 23:05
  • 1
    This is a problem for GNOME. I had enough of this while developing my own input method (that does not utilize any english like ibus/fcitx/gcim/scim...). `xdotool type` and `xdotool key` could kill GNOME for me, and it's still not fixed and I don't think it will ever be fixed. I just gave up and proceed to manipulate clipboard and sending low level ctrl+v to type texts. – Saren Arterius Oct 28 '18 at 07:19

4 Answers4

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).

Beast Winterwolf
  • 229
  • 2
  • 11
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 want And there is also "pl + an indentation" that will trigger it

enter image description here

Benjamin
  • 142
  • 1
  • 8
0

I investigate on this because it's also a problem for me and I found that :

When you type only 10 char :

18:29:25 date +%s%N ; echo -; xdotool type "0123456789" ; echo - ;  date +%s%N
1612286985355706637

0123456789
1612286985498079368

You are in the dark for 0.142372864 sec

But when you type 100 char :

18:27:12 date +%s%N ; echo -; xdotool type "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" ; echo - ;  date +%s%N
1612286840678952107

0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
1612286841733910300

You are in the dark for 1,054958080 sec

So my best guess is that when you use type, each char are typed one by one increasing the time.

xdotool type --delay 0 "long_sentence"

Seems to improve a little but not when used in an alias

Benjamin
  • 142
  • 1
  • 8
0

As a workaround, you can copy the text to clipboard and paste it instead of typing:

# Hangs with long text and text with special characters:
xdotool type "$1"

# Does not hang:
echo "$1" | xclip -sel primary    # for use with some shared clipboards (e.g. Remmina) 
echo "$1" | xclip -sel clipboard  # for use with local OS clipboard
xdotool key Shift+Insert
vvzh
  • 391
  • 5
  • 8