Every now and then someone asks on the OpenBSD public mailing list if it is possible to have a graphical application start at system boot time, circumventing the usual xdm login screen. I had to do exactly this a web browser is to be started for visitors to browse the web. Another application are point of sale systems where the POS application handles the login.
The most obvious, and easy way, would be if xdm, the graphical X11 login application, could autologin as a specific user; in that users homedirectory a .xsession file would then start the application. Since xdm in its current state can not autologin as a specific user, I had to find a different way. So the first thing was to turn off xdm. After some experimenting with changing stuff in /etc/ttys, I dropped this approach for a more straight-forward way. The basic approach is to start X11 from /etc/rc.local as an application specific user and to have the application be started from a .xinitrc file in that users homedirectory. To start X11, a small shell script is used which is called from /etc/rc.local: Calling the script in /etc/rc.local
if [ -x /usr/local/libexec/xpos-start ]; then echo -n ' xpos' && /usr/local/libexec/xpos-start & fi
The called script starts X11 on a tty that is disabled in /etc/ttys (which is tty05 by default on OpenBSD):
#!/bin/ksh trap 'echo Ignoring HUP' HUP INT QUIT CHLD ABRT while true do su - _xpos -c "startx -- /usr/X11R6/bin/Xorg vt05 :0" sleep 1 done
This script assumes that a user _xpos exists in the system, something we assure using the pkg_* tools. When the package is installed, the user and group is created and a .xinitrc file is installed in his homedirectory. The last step is the .xinitrc file, which starts the application and sets up the screen saver:
#!/bin/ksh P=/usr/local/share/xpos exec ${P}/xpos-loop & exec xidle -program "${P}/idle" -timeout 600 & mwm
xpos-loop starts the application in an endless loop and the idle script referenced here just starts the xscreensaver. mwm is the Motif window manager which is used in this specific application.
category:
- Zum Verfassen von Kommentaren bitte Anmelden.