Introduction

The default rdesktop screen script is fairly basic. It creates the connection, passing along flags to "rdesktop" as specified in lts.conf. But, sometimes you may want a more complicated script to work around some issues.

One example is to modify the script not to call "rdesktop" directly, but a wrapper script that puts rdesktop in an infinite loop, so when Windows Terminal Services drops the idle connection, the Xserver does not have to re-initialize.

This approach is obviously not limited to rdesktop, and a better rdesktop screen script should be included upstream, but until all that happens, here's a bit of a guide that may some day be obsolete.

Recipe

The recipe here will be to create a "wrapper" script around rdesktop and pass the variables through to it.

1. Create the wrapper script. Let's be organized about this. Since screen scripts are in /opt/ltsp/i386/usr/share/ltsp/screen.d/, let's create a new subdirectory called "wrappers" there.

mkdir /opt/ltsp/i386/usr/share/ltsp/screen.d/wrappers

2. Next, let's create a new script in there called "rdesktop" with the following contents:

#!/bin/sh

while true; do
    /usr/bin/rdesktop "$@"
done

3. Make this file executable

chmod +x /opt/ltsp/u386/usr/share/ltsp/screen.d/wrappers/rdesktop

4. Finally, edit the real rdesktop screen script in /opt/ltsp/i386/usr/share/ltsp/screen.d/rdesktop, so that instead of calling /usr/bin/rdesktop, it calls /usr/share/ltsp/screen.d/wrappers/rdesktop

Change the line that reads:

xinit $xinitrc /usr/bin/rdesktop ${RDESKTOP_OPTIONS} -- ${DISPLAY} vt${TTY} ${X_ARGS} -br >/dev/null

to read:

xinit $xinitrc /usr/share/ltsp/screen.d/wrappers/rdesktop ${RDESKTOP_OPTIONS} -- ${DISPLAY} vt${TTY} ${X_ARGS} -br >/dev/null

... and you're done! You can further enhance your wrapper script to report errors when rdesktop cannot connect, so that if rdesktop fails, it doesn't just loop forever. That is left as an exercise to the reader until we push something upstream.

UbuntuLTSP/RdesktopScreenScript (last edited 2009-10-13 19:33:12 by gideon)