1 | 2

6 - 9   [9]

## Multiple Firefox Profiles OSX

Also relates to Firefox and Co

Firefox used to be a popular blogging topic for me, but since migrating to OSX I have rarely used it. However, recently working on design scamps I have found a need to call upon the Web Developer toolbar once again. So I am once again using Firefox regularly.

First thing I wanted to do after installing 1.5RC3 was setup multiple profiles since I was also keen to return to some experimental XForms development I had started on Windows. Also I like to have a profile for extension testing - especially as RC3 is a new release.

To set up multiple profiles it is necessary to burrow into the APP file. I decided to let a couple of aliases in my .bashrc save me the trouble of navigating through the finder.


# run the profile manager to create a new profile
alias foxpm='$HOME/Applications/Browsers/Firefox.app/Contents/MacOS/firefox-bin -ProfileManager' # start firefox using a specific profile eg. fox xforms alias fox='$HOME/Applications/Browsers/Firefox.app/Contents/MacOS/firefox-bin -p'


Note my HD is partitioned in a way such that I can keep all my applications distinct from OSX.

Then just a case of a few AppleScript shortcuts that I can call from Quicksilver rather than having to keep entering the terminal.

Posted on Nov 20, 2005 at 14:58:34.

## Automating X11 Rootless Mode

Also relates to 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. ## Verify Sudo in Script Execution Also relates to Apache and UNIX Earlier I was setting up a couple of shell scripts to allow me to quickly switch between PHP versions on the Apache web server and enable/disable my unit testing environment in OS X. Along the lines of:  apachectl stop httpd -f /usr/local/php5/httpd.conf  Since such scripts must be run as root user I wanted to concote a little script to check I had used sudo to run the commands (as I have a habit of forgetting!). Firstly I came up with the following:  #!/bin/sh # verify-su umask 222 touch /tmp/user-status echo whoami 2> /dev/null >| /tmp/user-status if [$? -ne 0 ] ; then
if [ $# -eq 0 ] ; then "This command must be run with root privileges!" else "$1 must be run with root privileges!"
fi
exit 1
fi

\rm /tmp/user-status

exit 0


A file is created with read only permissions (by temporarily changing umask) and then the script attempts to write to it. The output redirection to file will only succeed if the script is run as root (the superuser).

In running this without the rm command I discovered that a script executed with sudo will return root from the whoami command instead of the user name I am currently logged in with. So this could actually be simplified considerably to:


if [ whoami != 'root' ] ; then
# etc …
exit 1
else
exit 0
fi


There is always a simpler way to do things!

## AWOL Explained

Also relates to X11