VICE on Macs is currently an application bundle that launches X11 and the X11 version of VICE. I added a new launcher script for the next VICE release that allows to drop files on the app icon. Each dropped file is autostarted when opening the emulator. Furthermore, you can run the launcher from the command line in your terminal and pass arbitrary arguments. In this case, no xterm for VICE input/output is opened but the terminal is used.
Recently, I found a really nice tool for Macs called Platypus. This tool can package a script in an application bundle. A click on the bundle runs the scripts and even passes the dropped files as arguments to the script. Thats the feature, I was missing in VICE so I started to integrate this new packager.
In the current VICE release, two scripts are used to launch VICE: the first one is a shell script that calls open-x11 to launch the X11 server and then executes the second script in the X11 context (i.e. a DISPLAY variable is defined). The second one now runs an xterm for VICE input and output and the xterm finally runs the VICE binary. Puh! A lot of stuff to run the emulator and not very well suited for Platypus integration. Furthermore, calling the first script on the command line would run VICE but its output is always in an external window and not on the console. Also any arguments passed to the first script were not propagated to VICE.
Looking at other Applications that launch X11 apps, I found the launcher of Gimp-App very interesting: There a single script is used (with Platypus) to fire up X11 and launch the application. Inspired by this work I created a new x11-launcher.sh that does VICE startup in a single script.
This script also sets up a temporary .xinitrc for the user if none is available. This startup file does not open an unwanted XTerm as the default does.
The launcher now determines in which context it was called and changes its behaviour accordingly: If called on the command line then no xterm is opened and VICE is started with output on the console. Additionally, all arguments are passed directly to VICE. If called by Platypus then the arguments are the dropped files and the script creates -autostart arguments for VICE.
I adapted the make bindist distribution build process to use Platypus on default if its installed on the build system. You can pass NO_PLATYPUS=1 if you don’t want to use the packager. Then the launcher script is installed directly in the application bundle. This works like the current launcher: no file drops are possible. The command line features work for both distribution types.
Another nice side effect of the new launcher in a single script is the fact, that the VICE application icon will stay in the dock and not disappear after startup…