A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

How to really loop over filenames with spaces in

 Don't parse the output of "ls".

Instead:

for file in *

do

  ...

done


(source)

Automating mouse movement and clicks on Linux

Windows has AutoHotkey (AHK), and Linux has xdotool.

But xdotool 3.20160805.1 doesn't work on Wayland at all. It silently fails. Turns out xdotool only works on X11, which is no longer the default for Ubuntu.

In 2024, using Ubuntu 22, this version of xdotool is the latest one available by running `apt install xdotool`.

To find out if you're using Wayland:

$ loginctl show-session 2 -p Type
Type=wayland
$ echo $XDG_SESSION_TYPE
wayland

To switch to X11, edit/etc/gdm3/custom.conf, uncomment the line WaylandEnable=false, and reboot.

Now xdotool will work perfectly.

xdotool README does mention some alternatives:

  • ydotool (available in apt) -- last updated January 2023, also didn't work for me on Wayland or X11
  • dotool -- updated more recently, but not packaged for Ubuntu, and building from source requires Go, which is quite heavy so it's easier to just switch to X11 for xdotool.