osx - How do I properly configure my .xinitrc file to start the openbox session manager
2014-04
I've installed openbox twice - once with Fink, and once with MacPorts. Both installations yield the same result: startx
terminates with an error diagnostic from xinit.
I have a working .xinitrc for various other window managers. How do I modify my .xinitrc to invoke either openbox or openbox-session? The man page for openbox seems to indicate that it is possible, but I cannot get the syntax down.
The error diagnostic that I receive when invoking startx is
whmcclos@mbp:~
[38] startx
font_cache: Scanning user font directories to generate X11 font caches
font_cache: Updating FC cache
font_cache: Done
xauth: file /Users/whmcclos/.serverauth.5834 does not exist
/opt/X11/bin/xinit: XFree86_VT property unexpectedly has 0 items instead of 1
Openbox-Message: Invalid button "A-Left" in mouse binding
Openbox-Message: Invalid button "A-Middle" in mouse binding
Openbox-Message: Unable to find a valid config file, using some simple defaults
ObRender-Message: Unable to load the theme 'Clearlooks'
Openbox-Message: Unable to load a theme.
/opt/X11/bin/xinit: connection to X server lost
waiting for X server to shut down
Here is my working .xinitrc - it works when I comment out exec openbox-session
and uncomment the line #e16
:
[40] cat .xinitrc
#!/bin/sh
# $Xorg: xinitrc.cpp,v 1.3 2000/08/17 19:54:30 cpqbld Exp $
source ~/.profile
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11/lib/X11/xinit/.Xmodmap
# merge in defaults and keymaps
if [ -f $sysresources ]; then
if [ -x /usr/bin/cpp ] ; then
xrdb -merge $sysresources
else
xrdb -nocpp -merge $sysresources
fi
fi
if [ -f $sysmodmap ]; then
xmodmap $sysmodmap
fi
if [ -f "$userresources" ]; then
if [ -x /usr/bin/cpp ] ; then
xrdb -merge "$userresources"
else
xrdb -nocpp -merge "$userresources"
fi
fi
if [ -f "$usermodmap" ]; then
xmodmap "$usermodmap"
fi
# start some nice programs
xrdb -load $HOME/.Xresources
xsetroot -solid gray &
xclock -g 50x50-0+0 -bw 0 &
xload -g 50x50-50+0 -bw 0 &
gnome-terminal --geometry=80x25+90+90 &
gnome-terminal --geometry=80x25+90-90 &
#gnome-wm
#twm
#quartz-wm
#mwm
#e16
exec openbox-session
I'm using xdm
and my ~/.Xsession
looks like this:
# <initialization stuff here>
exec openbox
It works, but I've noticed that when I log out Openbox
doesn't gracefully kill all the applications. In particular Google Chrome
complains about that.
How can I make sure to wait for all processes to exit (just like others configurations: Gnome, KDE, Windows ...)?
The only (ugly) solution that I've found involves sleep
and kill
into ~/.Xsession
.
You need a session manager to gracefully kill the applications. openbox-session
may do what you want. The documents explicitly say it doesn't do the saving session part, but it may do the gracefully kill part. openbox-gnome-session
or openbox-kde-session
will let you use the respective session managers while using openbox as your window manager.
Here's how I solved, I edited ~/.Xsession
this way:
# <initialization stuff here>
openbox-session &
WM_PID=$!
sleep 0.5 # time needed to start openbox
# <autostart applications here>
wait $WM_PID
for i in `ps -u $USER -o pid= | grep -v $$` ; do
kill $i
done
sleep 1 # grace time
I can't find anything better by now. Maybe I should use a session manager but I don't know which one fits my case.