Don't parse the output of "ls".
Instead:
for file in *
do
...
done
(source)
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
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: