Wednesday, July 16, 2008

xdm Trick

PuffyHere's another quick tip I've started using. Actually, I don't normally run X with xdm and right now I can't remember why I am on one of my boxes. But I am.

If you put xdm_flags="" in your /etc/rc.conf.local, xdm will start automatically during the boot process. This is probably what you want nine times out of ten. But, that tenth time, it's annoying when X starts and you didn't want it to.

I put the following in my /etc/rc.local instead of putting xdm_flags="" in my /etc/rc.conf.local:

echo "Press any key within 10 seconds to bypass xdm..."
old_tty=`stty -g`
stty -echo -icanon min 0 time 100
_KEY=$(dd count=1 bs=1 2>/dev/null)
stty "${old_tty}"

if [ "${_KEY}" = "" ]; then
  echo "starting xdm..."
  echo Bypassing xdm

The first stty command waits 10 seconds for you to press any key. The value of that key is stored in ${_KEY}. If you pressed a key (${_KEY} != ""), rc.local does not start xdm and boots to a normal non-X login prompt. If you do not press a key, xdm starts and you're greeted with the xdm login screen.

I hope that helps someone.