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.


  1. This is a great tip. Thanks, Mike.

  2. Wouldn't Ctrl+Alt+F1 easier?

  3. > Wouldn’t Ctrl+Alt+F1 easier?

    Sure. If you want to wait for X to start up before choosing that you don't want X to start up.

    What about the time when you want to boot quickly, not have xdm start, so you can run some command (sysmerge?) before rebooting quickly to get back into X?

  4. Awesome tip, been wondering how I might be able to do something similar. I don't always want to boot into X on my workstation, but I don't always want to have to run startx either.