The Haiku/BeOS Tip Server
Tips and tricks for Haiku/BeOS users

Running console apps from the Desktop

Contributed by: Diego Gallina
This tip is valid for: Both BeOS and Haiku

If you want to be able to run console-based applications or scripts by double-clicking icons on the Desktop or in the Tracker, there are several ways to go about it. If you’re just running a script, the easiest way is to make sure you’ve got the magic cookie as the script’s first line, e.g.:

#!/bin/sh

And then make the script executable with, e.g.:

chmod 755 scriptname

If you want to get a little fancier, and make sure the program’s name appears in the title tab of the Terminal windows, you’ll need to invoke them from a secondary script. That script will launch a Terminal session and pass the desired app or script to it as an argument. Create a file on the Desktop with these contents:


Terminal -t "Window Title Here" /bin/sh --login -i -c your_app_here 

This starts Terminal with the title of your choice (-t), starts the BASH shell in interactive mode, and passes the command after -c to the shell. Now just make your shell script executable (chmod a+x yourshellscript) from the Terminal.

For example, let’s say you want to run a keepalive script to keep your Internet connection awake, and you don’t want to have to launch a Terminal and type the keepalive command by hand each time. Just create an executable text file on the Desktop, containing:


Terminal -t "Connection Keeper" /bin/sh --login -i -c keepalive 

As long as the keepalive script is already in your path, you’re all set.

Note that a program like xicon will do the same thing AND will give you the ability to drag/drop files onto your script icons for passing to the script.

rabba@maine.rr.com contributed to this tip.

Posted in Terminal


(comments are closed).