xdotool not executing 'type' depending on how I start it from vim

119 views Asked by At

I have the following script:

#!/bin/bash

# Find the Firefox window with a title containing 'Plan page'
firefox_window_id=$(xdotool search --name "Plan page")
echo "Firefox Id is" + $firefox_window_id
xdotool windowactivate "$firefox_window_id"
xdotool type "y"

It's purpose is to find a particular firefox window and send the key "y"

It works perfectly from the command line, but I'd like it as a Vim macro.

If I run it like this:

:! ~/git/delores/mcve.sh 

it works perfectly.

But if I run it like this:

noremap ,ny :! /home/joe/git/delores/mcve.sh<cr>

Then xdotool grabs the focus of the window but doesn't send the 'y' and keeps the focus of the firefox window. I get the same (bad) behavior when I run it from i3. EDIT - adding a delay to the script means that the keypress is sent, but it's very unclear why that makes a difference...

Why would the script act differently depending on how I call it in Vim, and what can I do about it?

My OS is Ubuntu. I am using Vim 8.2.

0

There are 0 answers