Restoring twm for vnc

This is what I did for RHEL 6, which defaults to displaying the current desktop (usually Gnome) by default. What follows is handy for those of us who have to do actual work over a (relatively) slow corporate VPN.

Although I really appreciate the enhanced eye-candy that comes with the Gnome desktop for RHEL 6, it can be a liability when you’re trying to work remotely over the corporate VPN. Bandwidth is everything under those circumstances, and ever bit of graphics you can squelch gives you more to work with.

First of all, lose the shipping vinagre and vino packages and replace them with tigervnc and tigervnc-server, you’ll be glad you did.

Also be sure that you’ve got the good old-fashioned xorg-x11-twm and xterm packages installed (if you get a gray screen with no terminal emulator after making the xstartup change below, it’s probably because you don’t have twm and xterm installed — they are no longer part of any of the standard installs for RHEL 6 as they were with RHEL 5).

Next, replace the “new” ~/.vnc/xstartup that gets set up by default with the older version that used to ship with RHEL 5 and earlier. The latter will give remote clients the bare bones, graphics lite, environment they need.

(note that “xstartup” must be set to executable, or you’ll get a black screen!)

Here’s the default xstartup:

#!/bin/sh

[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
export LANG
export SYSFONT
vncconfig -iconic &
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
  case "$WINDOWMANAGER" in
    *gnome*)
      if [ -e /etc/SuSE-release ]; then
        PATH=$PATH:/opt/gnome/bin
        export PATH
      fi
      ;;
  esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
   exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
  exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

and here’s a more ancient version you’ll want to replace it with:

#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

Both of these are provided in the event: (a) you need to “fix” the display on a server you want to use; and (b) if someone forgets to back up the default configuration and it needs to be restored.

While you’re at it you might want to take my advice from twm on Red Hat Enterprise and add the “RandomPlacement” directive to a .twmrc for the user so you don’t have to set each new open window. Or don’t, and find out what I’m talking about.