I want to perform a repetitive task using Emacs and another program (which, unfortunately, runs under X). I have then set up an elisp function and a xdotool
script to do the two parts of the work. The elisp function uses a cl-loop
to iterate over the lines of a temporary buffer I create.
I'd like the two to be synchronized, so that Emacs
- cannot continue until the
xdotool
script has finished - it can also check the return code (potentially stopping if the script fails).
I'd normally do this with call-process-shell-command
, but for some reason, then xdotool
won't accept mouse clicks. I found in another question that calling the process asynchronously solves the problem, and indeed it does:
(let ((async-shell-command-display-buffer nil))
(shell-command "/home/alessandro/xorg-session.sh&"
nil
nil)
)
(sleep-for 5)
but then I can no longer wait for the process, and I'm forced to use an extremely fragile sleep-for
. How can I do both? I.e., running a xdotool
, but synchronously and checking for its success? I've heard about sentinels, but I don't think they can help here (due to the cl-loop
).
Thanks!