Xdotool command works at command line, not in bash script

0

Why does the command xdotool search --class mupdf windowactivate --sync type f]H work in the command line as expected, almost, but not at all in the following script

joc(){ # Joy of Cooking, joc [page #, def 823]
  mupdf $HD/ReadBooks/Rombauer/Rombauer-JoyOfCooking_11_823.pdf ${1:-823}
  sleep 1
  eval "xdotool search --class mupdf windowactivate --sync type f]H"
}

Note I have tried in the script both with and without quotes, with and without eval, with and without 'search ... --sync'. As far as I can tell the xdotool command has no effect at all.

bash command-line mupdf xdotool
2021-11-23 21:43:13
1

1

Because after starting mupdf it doesn't return control to the script until you close it. You have to run it in background using & at the end:

mupdf example.pdf &
sleep 1
xdotool search --class mupdf windowactivate --sync type f]H
2021-11-23 22:13:41

Perfect, and how dumb must I be not to have noticed that.
user985675

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................