Automating X11 Rootless Mode

Relates to OSX and X11

Many of the applications I use on a daily basis come from the KDE toolkit or other X11 software most notably Konqueror, eSVN, Kompare, Karm, XEmacs and (of course) Amarok. If I am working extensively with KDE apps I will load up the K Desktop Environment as my window manager in full screen mode. However, sometimes I find I want to share X11 and native OS X applications. It is a little frustrating having to keep changing the initialisation file for X11 and switch to rootless mode in the Preferences pane. So I decided to concote a script to do this automatically.

By default my .xinitrc file will start up KDE with:

startkde >/tmp/kde.log 2>&1

Then I also have a start up file for the quartz window manager (.xinitrc.quartz) with:

exec quartz-wm

Then the startup script for X11 applications (based on the Xdroplets scripts) looks to see if X11 is already running by searching for display lock files in the tmp dir. If it is not another script is called which switches X11 to rootless mode and boots it with the Quartz window manager initialisation file. This allows me to start up X11 using its application link if I want to use KDE or to just open an X11 application if I want it to run in rootless mode seamlessly with native OSX applications.

The main challenge with achieveing this is switching the preference since this is stored in a binary plist file (~/Library/Preferences/ Fortunately the property list utility (plutil command) makes this task relatively simple:

if [ ! -z $1 ] && [ $1 == 'false' ] ; then
plutil -convert xml1 -o /tmp/ ~/Library/Preferences/
sed "/rootless/{ n; $pattern; }" /tmp/ > /tmp/
plutil -convert binary1 -o ~/Library/Preferences/ /tmp/
\rm /tmp/{,-new}.plist

The property list utility converts the binary file to XML so that sed can then replace the state of the rootless property. So now I can open an X11 app or two without having to either boot a KDE session or reconfigure my .xinitrc or X11 preferences.

Posted on Friday, Aug 19, 2005 at 00:40:13.

Comments on Automating X11 Rootless Mode (0)

Breadcrumbs Trail

[ Home ] -> TW Blog -> Aug 05 -> Automating X11 Rootless Mode
Site Map

The Severn Solutions website achieves the following standards:

[ XHTML 1.0 ] [ CSS 2 ] [ WAI AA ] [ Bobby AA ]

Page compiled in 0.006 seconds