Install xdotool from the repository with sudo apt install xdotool if not
already installed. Make a note of the keyboard shortcut you use for "Show
Desktop." It is under Window Manager > Keyboard. Mine is ctrl+alt+d. Create
the following two scripts:

 ~$ cat bin/graphics-workaround
#!/bin/bash

export DISPLAY=:0.0
export XAUTHORITY=/home/brock/.Xauthority

xdotool key ctrl+alt+d
xdotool key ctrl+alt+d
~$ cat /lib/systemd/system-sleep/graphics-workaround
#!/bin/sh
if [ $1 = post ] && [ $2 = suspend ]; then
/home/brock/bin/graphics-workaround
fi

Edit export XAUTHORITY=/home/brock/.Xauthority to correspond to your home
directory path. Also edit /home/brock/bin/graphics-workaround to the path
to your script. Don't forget to mark both scripts as executable with chmod
+x script-name

You can also create a systemd service if you prefer that method. I've
tested both methods, and both work. Here is more information setting a
command or script to run upon resume from suspend.
https://askubuntu.com/questions/661715/make-a-script-start-after-suspend-in-ubuntu-15-04-systemd#answer-661747

Feel free to email me if you have any difficulty in getting it set up.

Reply via email to