I am going to share part of my script that downloads a file from google drive GNOME Virtual file system convert part of it as pdf and sends it through thunderbird
you need to set xorg as your window system for xdotool to work, as it will not work if wayland is set as your window system in ubuntu.
# Step 8: Send email with attachment
thunderbird -compose "subject='Comprobante de pago',to='$EMAIL',body='Buenas noches, envío comprobante de pago mes relacionado en el recibo adjunto.
Gracias y feliz día.
Cristian Beltrán
3143530535',attachment='$DOWNLOAD_DIR/$PDF_NAME'" &
# Step 9: Wait for Thunderbird window and simulate send
sleep 2
xdotool mousemove 2048 214
sleep 0.25
xdotool click 1
wait
# Step 10: Cleanup
rm "$DOWNLOAD_DIR/$PDF_NAME" "$DOWNLOAD_DIR/$FILE_NAME"
1 ----&----- for Background Execution:
Running thunderbird with & allows it to execute in the background, which is crucial for continuing the script without blocking.
2 ----wait---- for Synchronization:
After triggering xdotool to simulate the "Send" action, wait ensures that the script doesn't terminate prematurely, especially before Thunderbird finishes processing.
Important Note on Xorg:
As highlighted, xdotool depends on Xorg for interacting with graphical windows. If Wayland is active (the default on newer Ubuntu installations), xdotool won't work. This means users must set their session to Xorg.