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.

Posted on Aug 19, 2005 at 00:40:13. [Comments for Automating X11 Rootless Mode- 0]

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!

Posted on Jun 20, 2005 at 20:12:51. [Comments for Verify Sudo in Script Execution- 1]

AWOL Explained

Also relates to X11

Not been much time to blog recently with all out of hours preoccupied with my newly acquired Apple Ibook. Only a week old, she has far and away exceeded all expectations. Within 48 hours I felt familiar with the OSX interface - considerably more user friendly than its PC counterpart and had filled up half a gigabyte with my favourite songs, plus a few nostalgic memories courtesy of the ITunes store. One frustration was the apparent absence of Apples X11 disk image anywhere on the hard drive or accompanying discs. But this probably was for the best, as I decided rather than downloading the installer from the Apple site to instead go with Fink and the somewhat purer XFree86 variant, XDarwin. So a few sleepless nights and longhaul downloads later, I now have GNOME set up and running smoothly (bar one or two glitches), giving me access to the Gimp, Nautilus (a great file explorer!), Bluefish editor and an Amaya release which actually includes the bookmarks feature to name just a few. Add the ability to run the Xserver rootless (actually using Xnest) I still have access to all those OSX applications - superb! And then there is my free OSX upgrade to Tiger still to come once it has stabilised.

This is just a quick summary really, and if I can find time to drag myself away from the captivating transit of Io in my RXVT shell - courtesy of Xplanet - I will post some extended blogs on my first experiences and the tools that assisted me in getting my Ibook development ready.

Posted on May 05, 2005 at 16:23:59. [Comments for AWOL Explained- 2]

Breadcrumbs Trail

[ Home ] -> TW Blog -> OSX
Site Map

The Severn Solutions website achieves the following standards:

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

Page compiled in 0.072 seconds