4

I need to use xdotool to quickly automate some click at specific locations of my screen. I could use the following script:

#! /bin/bash
sleep 0.5
xdotool click 200 150
sleep 0.5
xdotool click 200 175
sleep 0.5
xdotool click 1050 150
sleep 0.5
xdotool click 1350 450
sleep 0.5
xdotool click 1100 150

And it would work fine. However, xdotool is not installed on the machine I'm using, and I do not have root access. I cannot install it locally because the X11/extensions/XTest.h library is not present. What are my options?

Tim
  • 33,500

2 Answers2

0

You can compile xdotool statically and copy it to that machine.

Alternatively you can copy the dynamically linked binary and see if the libraries resolve.

V13
  • 101
0

If I'd seen this question in 2017, I'd've urged you to just find the XTest.h header, rather than heading down some other avenue. Fixing some missing headers is probably easier than anything else suggested here, assuming that was the only problem.

tl;dr: sudo apt install libxtst-dev

However, in 2024, for Debian and Ubuntu (and derivatives), xdootool should be available in the distro repositories. In Ubuntu, you'll need to enable the universe respository, which many distros do by default.

If you must install from source, for some reason, apt build-dep xdotool will help immensely. It installs all the build-time dependencies for a given source package. The only downside is the package must exist in the Debian/Ubuntu repositories for build-dep to know what to do.

When a particular software package does exist in the Debian/Ubuntu repositories (even as an older version), this alleviates the burden of having to identify which headers (-dev packages) and other libraries need to be installed to build from source.

$ apt-get --dry-run build-dep xdotool | grep Inst
Inst libllvm14 (1:14.0.0-1ubuntu1.1 Ubuntu:22.04/jammy-security, Ubuntu:22.04/jammy-updates [amd64])
[…snip…]
Inst openbox (3.6.1-10 Ubuntu:22.04/jammy [amd64])
Inst xserver-common [2:21.1.3-2ubuntu2.5] (2:21.1.4-2ubuntu1.7~22.04.5 Ubuntu:22.04/jammy-security, Ubuntu:22.04/jammy-updates [all])
Inst xterm (372-1ubuntu1 Ubuntu:22.04/jammy [amd64])
Inst xvfb (2:21.1.4-2ubuntu1.7~22.04.5 Ubuntu:22.04/jammy-security, Ubuntu:22.04/jammy-updates [amd64])
Inst dh-exec (0.23.4build2 Ubuntu:22.04/jammy [amd64])

In truth, you may end up with some other cruft—packages only "required" in the sense that they were needed for testing and packaging, like openbox through dh-exev in the output above—but at least it's alleviating the guesswork. I would say in some cases you can uninstall those packages later with a command like this:

apt-get --dry-run build-dep THE_PACKAGE_NAME \
  | awk '$1=="Inst"{print $2}' \
  | xargs sudo apt remove

…but I wouldn't recommend blindly doing that for the particular case of xdootool, otherwise you'll break your system.

Let's say I hadn't known about apt build-dep, though. One can always use apt-file* to help locate the package that would contain that missing header:

$ apt-file search XTest.h
libbcprov-java-doc: /usr/share/doc/libbcprov-java/api/org/bouncycastle/crypto/test/EAXTest.html
libbcprov-java-doc: /usr/share/doc/libbcprov-java/api/org/bouncycastle/jce/provider/test/PKIXTest.html
libjna-java-doc: /usr/share/doc/libjna-java/api/com/sun/jna/platform/unix/X11.XTest.html
libxtst-dev: /usr/include/X11/extensions/XTest.h

The answer in this case is sudo apt install libxtst-dev.

On a pretty new install of elementary OS 7 (based on Ubuntu 22.04), where I had already installed build-essential and elementary-sdk, I had no issue cloning the current master branch of jordansissel/xdotool from GitHub, and running make in the source directory. Your mileage may vary, though.

Hope that helps (someone)!


*Expect this issue this issue the first time you try to use apt-file search, though; you may just need to run an extra sudo apt update before sudo apt-file update is all.

Kevin E
  • 153
  • 5