Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Just use a unix script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Just use a unix script
Authored by: Anonymous on Jan 20, '03 02:54:25PM

I've been doing this for a long time, but with ssh xwindow sessions:

/usr/bin/open /Applications/
until ps -cx|grep quartz-wm
do tail /etc/hosts >> /dev/null
/usr/bin/ssh -X -C anne "/usr/bin/CAClient" &

There's probably a better way to ensure the window manager is up, but this was what I threw together on a quick session quite some time back, and it's functional so I've had no reason to rethink it... For the uninitiated, it's opening X11, running a loop to check for the existence of quartz-wm (which means X11 is up) then opening a ssh xwindow session to the machine "anne" and running the xwindow app "CAClient" as a background process on the remote box. With ssh keys this is a complete background process. Name the script whatever.command and it's a double-click process as well. As for adding the display env var in the script, I'd add that in the .cshrc, and have it available for all shells. Add these 2 lines to your .cshrc:

setenv PATH "${PATH}:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin"
setenv DISPLAY localhost:0

Now you can get xapps from any shell, anytime. Cleaner, IMHO.

[ Reply to This | # ]
Just use a unix script
Authored by: jafager on Jan 20, '03 05:30:12PM

This can be a real pain if you don't have a terminal running all the time, or if you use an application launcher like LaunchBar.

I have a USENET post on turning X and console applications into regular double-clickable applications via Applescript:

[ Reply to This | # ]
Point conceded...
Authored by: Anonymous on Jan 20, '03 10:01:34PM

Heh heh... Being a sysadmin, there's almost never a time that I don't have term open... And I also use ssh port forwarding to deal with my personal mail, so even when I'm not working term is up... But it's a good point, for the traditional non-unixy macuser the applescript has some definite advantages...

[ Reply to This | # ]
Script example for Command Line Mongrals
Authored by: ktohg on Jan 21, '03 02:44:03AM
My text editor (VIM) has both an X11 version and a MacOS version. I prefer the X11 one but don't always have X11 running. So I created a script to select the prefered version depending. It's a sample that you can use.
#!/bin/sh showhelp() { cat <<EOF This is a wrapper script for the graphical version of VIM. The script recognizes the following command line options. Only the first option will be recognized.    -h              This cruft    --help          vim --help    -x, --x11       force X11 gvim (Start X Server if                    not one already runnung)    -X, --no-x11    force MacOS gvim    --              NO-OP (pass remaining options as-is) If you do not force a display method one will be guessed based on the DISPLAY environment variable and the presence of running. EOF } case "$1" in    --) shift; X11=ukn;;    -h|-help) showhelp; exit -1;;    --help) exec vim --help;;    -x|--x11)  shift; X11=yes;;    +x|-X|--no-x11)  shift; X11=no;;    *)  X11=ukn;; esac case `basename "$0"` in    xvim) X11=yes;;    mvim) X11=no;; esac if [ -z "$DISPLAY" ]; then    if [ -z "`ps ax | grep | grep -v grep`" ]; then        if [ $X11 == yes ]; then            open -a X11            sleep 5            export DISPLAY=:0        else            X11=no        fi    elif [ $X11 != no ]; then        export DISPLAY=:0        X11=yes    fi elif [ $X11 != no ]; then    X11=yes fi case "$X11" in    yes) exec vim -g $*;;    no)  exec open -a Vim $*;; esac

[ Reply to This | # ]
Another More Generic Script
Authored by: ktohg on Jan 21, '03 02:51:23AM
This one is a simpler one than the gvim one but it is more generalized. It's not as pretty as the gvim one. Also is an alias so the DISPLAY veriable gets set properly (unline a script which only sets it locally. This allows me to open an X11 app using `x' once or just typing `x' will start up the Here is my alias: alias x='export DISPLAY=:0;Xapp' and the Xapp program:
#!/bin/sh if [ -z "`ps ax | grep | grep -v grep`" ]; then    open -a X11    sleep 5 fi if [ -n "$*" ]; then    export DISPLAY=:0    exec $* else    exit 0 fi

[ Reply to This | # ]