Prevent Windows server screen lock on Linux RDP client

I got fed up with a Windows server putting on a lock screen all the time.

Windows Server 2012 lock screen

I found out an easy way to prevent it at Linux RDP client side with xdotool. It is available on Debian/Ubuntu (install with apt install xdotool) and is also in EPEL for RHEL/CentOS/etc.

Just start the following script in background:

The script works by injecting X11 key up events to the window. These are transmitted to the remote RDP server. They are enough to keep the screen lock away and do not disturb normal usage.

If using some other RDP client, the string “rdesktop” needs to be changed to match the X11 window class name of the RDP client in use. To find out the class name of a window you can run xprop WM_CLASS and click the RDP window.