1

1

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/com.apple.x11.plist). Fortunately the property list utility (plutil command) makes this task relatively simple:


if [ ! -z $1 ] && [ $1 == 'false' ] ; then
  pattern='s/true/false/'
else
  pattern='s/false/true/'
fi
plutil -convert xml1 -o /tmp/com.apple.x11.plist ~/Library/Preferences/com.apple.x11.plist
sed "/rootless/{ n; $pattern; }" /tmp/com.apple.x11.plist > /tmp/com.apple.x11-new.plist
plutil -convert binary1 -o ~/Library/Preferences/com.apple.x11.plist /tmp/com.apple.x11-new.plist
\rm /tmp/com.apple.x11{,-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 Aug 19, 2005 at 00:40:13. [Comments for Automating X11 Rootless Mode- 0]

Breadcrumbs Trail

[ Home ] -> TW Blog -> Archives for August 2005
Site Map

The Severn Solutions website achieves the following standards:

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

Page compiled in 0.007 seconds