XDroplets

A collection of Applescript droplets to launch your X11 programs from the Finder.

Scripting: Martin Fuhrer < >
XDroplets are licensed under the GNU GPL v2.

Universal binary conversion: Adam Scheblein

Launcher Icons:
SVG Crystal Icon collection, courtesy of Everaldo (website)
KDE Classic icons, from KDE 3
Gnome stock icons, from Gnome 2

Icons retain the copyright and licenses of their respective authors.

Minimum Requirements

  • Mac OS X 10.3.9 or later (earlier versions are unsupported)
  • X11 environment (Apple X11, XDarwin, or OroborOSX)
  • Gnome, KDE, and X11 programs (installed via Fink, MacPorts, or manually)

About the XDroplets Collection

The XDroplets Collection consists of a bunch of launchers, or "XDroplets", that better integrate X11 programs with the Mac OS X environment. XDroplets provide the following features:

  • X11 programs can be launched via the Finder or Dock
  • documents can be opened in X11 programs via double-clicking or drag and drop
  • URLs can be forwarded from Mac apps to X11 programs
  • X11 automatically gets launched if it is not already open

Given the extensive range of X11 programs, this set of launchers is by no means comprehensive, but it does cover some of the most common programs for standard X11, KDE, and Gnome distributions. Feel free to contact me if I am missing a launcher for an important program, or to pass along your feedback and thoughts.

Installation

Place the individual launchers found in the XDroplets Collection folder anywhere you wish. Toss out the ones you don't need. For a menu that loosely resembles a KDE or Gnome style launcher menu, drag the KDE-Qt and Gnome-Gtk folders to the Dock, and control-click (or right-click) to bring up the menu. Optionally run the XDroplets Setup script to customize the behaviour of XDroplets, and the XDroplets Factory script to generate your own XDroplets.

XDroplets Setup Script

If you are using a standard installation of the Apple X11 environment, the XDroplet launchers should work right away. If you prefer to further modify the behaviour of XDroplets, run the XDroplets Setup script:

  • X11 Environment: This setting tells XDroplets which X11 environment to use. Available choices are Apple X11, XDarwin, and OroborOSX. Note to OroborOSX users: Please rename the OroborOSX application from 'OroborOSX-vx.x.x' to 'OroborOSX'. See also Known Issues.
  • Administrator Password Mode: If enabled, this setting prompts for an administrator password when an XDroplet is launching a document for which you have insufficient viewing or editing privileges.
  • XDroplets Stay Open: If enabled, this setting forces an XDroplet launcher to remain running until the program it launched quits. Although the XDroplet is visible as a running application in the Dock during this time, you will not be able to switch to or quit the program via the Dock icon. This setting is currently "experimental".

You can choose to apply your settings to all users on your Mac (in case you intend to install XDroplets for multiple users), the current user, or both (meaning preferences will be written to both /Library/Preferences and ~/Library/Preferences).

XDroplets Factory

Use this script to generate your own custom XDroplets. You will be able to specify the following information:

  • command line program name: This can be the program name alone (provided the program can be located by your $PATH setting), or it can be the full path to the program. If there are spaces in the name or path, enclose the entire phrase with double-quotation marks or prepend each space with a backslash (\). In other words, specify the name or path exactly how you would type it into the terminal in order to launch the program.
  • program arguments (leave empty if you don't require arguments)
  • working directory, ie. the directory from where the program will be launched. This is helpful, for example, if you want the program's open dialog boxes to start in a specified directory. Use the tilde sign '~' to set the working directory to your home directory.
  • environment variables (leave empty if you don't require environment variables).
  • document association: Click "Yes" if you wish to associate specific types of documents with the launcher.
    • file extensions: List the program's supported file extensions.
    • MIME types: List the program's supported MIME types. Click Auto Fill to automatically generate a list of MIME types based on the file extensions you entered previously.
    • classification: Indicate whether the program is best classified as a viewer or editor. A viewer program is only able to open documents for viewing, while an editor program is able to edit and save documents as well.
    • file arguments: List any arguments to pass to the program when files are being launched.
  • URL association: Click "Yes" if you wish to associate specific URL types with the launcher.
    • URL types: List the program's supported URL types.
    • URL arguments: List any arguments to pass to the program when a URL is being launched.

The following examples demonstrate how you might set up XDroplet launchers for various programs:

Example 1: XEdit

Xedit is a plain text editor included with X11 installations. To create a plain vanilla xedit launcher, launch XDroplets Factory and simply supply the name of the name of the program when the first dialog appears:

X11 Program: xedit

Use default settings for the remaining dialogs and save the launcher. You will now be able to launch xedit by double-clicking your new XDroplet. Because we did not set up document associations, any documents that you create and save within xedit will appear as generic documents in the Finder. To launch documents in xedit, simply drag the documents onto the Xedit icon.

Example 2: Nedit

Nedit is a popular code editor that can be installed via Fink or MacPorts. Suppose you want to create an Nedit launcher and make it the default application in which to open all your C and C++ documents. Because you store all your code files in the Documents folder in your home directory, you'd also like nedit to start in your Documents directory whenever you choose the Open or Save menu item. Suppose you also want to customize the appearance such that the editor displays a white background and 60 rows and 120 columns of text:

X11 Program: nedit
Arguments: -background white -rows 60 -columns 120
Working Directory: ~/Documents
Environment variable: <leave empty>
Associate documents: Yes
File extensions: c cpp h hpp
MIME types: <click Auto Fill>
Classification: Editor

Use default settings for the remaining dialogs and save the launcher. Now run Nedit (it should launch with a large, white, new window), type some text into a new file, and bring up the save dialog by choosing File > Save... The dialog should already be in your Documents folder, where you can save your file with a .cpp extension. Quit nedit, open a new Finder window, and locate your new file. Try double-clicking it to see if it opens in Nedit. If it doesn't, bring up the Info window for the file (select the file and choose File > Get Info), and in the "Open with" section, select Nedit from the pull down menu. While you're at it, click "Change All..." to associate all your .cpp files with Nedit. You can now perform similar steps to associate your .c, .h, and .hpp files with Nedit.

Example 3: Konqueror

Konqueror is a web browser for the KDE platform, and can be installed via Fink or MacPorts. Suppose you want to make Konqueror the default web browser on your Mac:

X11 Program: konqueror
Arguments: <leave empty>
Working Directory: ~
Environment variable: <leave empty>
Associate documents: Yes
File extensions: html htm
MIME types: <click Auto Fill>
Classification: Viewer
File arguments: <leave empty>
Associate URLs: Yes
URL types: http https ftp

Use default settings for the remaining dialogs and save the launcher. Try launching Konqueror to make sure it works. Launch Safari, and from the Preferences dialog, choose Konqueror in the default web browser dropdown menu. Now, whenever you click on a web link in another Mac application (eg. Mail), the link will launch in Konqueror.

Example 4: Pico (via xterm)

Pico is a text editor that runs within a terminal window. As a result, we must explicitly launch a terminal program and launch pico within the shell. XTerm is a popular X11 terminal program, and it supports passing a program name as an argument using the -e flag. We can now construct our XDroplet as follows:

X11 Program: xterm
Arguments: -e pico

In this way, XDroplets can work as launchers for simple shell programs as well as GUI programs.

When running an XDroplet, it bounces in the dock and disappears. What's wrong?

This is default behaviour. The launcher's job is simply to invoke the X11 program and pass along any files or folders you may have dragged and dropped. The launcher then quits, and the launched X11 program should appear shortly thereafter. If you prefer to keep the XDroplet running until the program quits, you can change this setting in XDroplets Setup.

If the X11 program does NOT appear, chances are it exited with an error (see Known Issues).

Why do some XDroplet icons appear pixelated?

Not all icons provided by the SVG Crystal, Gnome, and KDE icon collections are available at a crisp 128 x 128 resolution, much less a 512 x 512 Leopard-compatible resolution. As these icon collections are further developed and their resolution is increased, expect the XDroplet launcher icons to be updated as well. Meanwhile, feel free to customize the XDroplets with your own high-res icons. Icon files are found within the XDroplets application bundles and can be edited with Icon Composer (requires installation of Apple's development tools).

Can I change the appearance of my X11 applications so that they better match the Aqua look 'n feel?

Although this question doesn't directly pertain to XDroplets, it certainly pertains to the spirit of better integrating X11 apps with Mac OS X and the Aqua interface. KDE and Gnome apps are very themeable and a number of Aqua-like themes (eg. Glossy P, Baghira) exist on the web. Some good places to search for themes are:

Gnome (GTK) themes can be installed via Gnome Control Panels, and KDE (Qt) themes can be installed via KControl. Consult the websites for much more comprehensive information on installing themes.

Known Issues

The following problems will hopefully be corrected in future releases:

  • (OroborOSX users only) X11 windows may not respond to mouse clicks and keystrokes if an XDroplet attempts to automatically launch OroborOSX. If you encounter this problem, launch OroborOSX manually before using an XDroplet.
  • XDroplets do not display an error message if a program fails to launch properly (ie. returns an error code).
  • XDroplet launchers may not always quit properly when "XDroplets Stay Open" setting is enabled.

To Do List

Items to work on for future versions of XDroplets:

  • associate documents with XDroplets via UTIs (uniform type identifiers)
  • update to Leopard-size icons (512x512)
  • rewrite XDroplets Factory and XDroplets Setup with a proper user interface
  • rewrite XDroplets in Applescript Studio for more advanced event handling

Technical Notes

Each XDroplet is an Applescript droplet application containing bundled bash scripts. The Applescript source code can be viewed by opening the droplet in Script Editor, and the bash script code can be viewed in any text editor. The Applescript invokes the bash script 'launcher.sh' inside the application bundle. If the droplet received any files or URLs, these are passed along as arguments to the launcher script. (If Administrator Password Mode is enabled, file permissions are also queried by the bash script 'privileges.sh', and an administrator password will be requested from the user if the permissions are insufficient.) The launcher then calls the X11 program, along with customized arguments and a list of file paths and URLs. If an X11 environment is not running, the bash script launches the X11 application and waits for the display to be registered in /tmp/.X11-unix before calling the X11 program. If a problem arises, the launcher script generates various error codes and messages which the Applescript intercepts.

The XDroplets Setup script generates a preferences file in order to notify XDroplets about the X11 environment and administrator password mode. If the preferences file does not exist, XDroplets default to Apple's X11 environment and a disabled administrator password mode.

Feel free to contact me to pass along your feedback and thoughts. Any improvements to the code for future XDroplet releases are welcome! This project will remain open source and free for distribution.

Version History

1.1 (October 14, 2007)

  • XDroplet launchers may now be associated with particular types of documents and URLs.
  • Added administrator password mode to query file permissions and request an administrator password if required for viewing or editing the files.
  • Added option for XDroplets to remain running until the program they launched quits.
  • Environment variables entered in XDroplets Factory should now work properly.
  • Updated icons for existing launchers and added many new launchers.
  • Licensed XDroplets under GNU GPL v2.

1.0.2 (September 26, 2006)

  • Converted XDroplets scripts to Universal binary (thanks Adam Scheblein).
  • XDroplets now search for binaries and libraries in MacPorts (formerly DarwinPorts) paths and default system paths (eg. $PATH)

1.0.1 (January 10, 2006)

  • XDroplets Factory will now properly handle program names/paths containing spaces.
  • XDroplets Setup now supports preferences for current user and all users.

1.0 (March 23, 2005)

  • XDroplets Factory can now produce XDroplets that run as root user
  • Fixed a bug that prevented XDroplets from running if your username is longer than eight characters
  • Improved error handling

1.0b2 (February 25, 2005)

  • Launchers now properly set the X11 display variable for every user
  • XDroplets Factory allows specification of working directory and environment variables
  • XDroplets Setup no longer requires you to specify your window manager
  • Improved compatibility with OroborOSX

1.0b1 (September 2, 2004)

  • Initial release


Counter courtesy of bCentral