1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Fink newb question

Discussion in 'Mac Programming' started by telecomm, Jan 11, 2007.

  1. macrumors 65816


    So, I've discovered the world of X11 and Fink (after becoming interested in the GIMP). Using Fink Commander, I got a few binaries, which leads me to the following question.

    Instead of opening X11 and typing, say, /sw/bin/gnubg, how might I go about creating some sort of desktop icon–type thing that I could click, and then have X11 open and a particular X11 app start up? (In this case, I'm interested in creating such an icon so my gf can play backgammon without having to interact with a command line.)

  2. macrumors demi-god


    Command files (with a .command extension) are just the thing to solve these sorts of problems. Essentially, all a command file is is a shell script (with executable permissions set) with the .command extension. Double-clicking one of these will launch the Terminal and execute the various commands inside. In your specific case, to get around the problem of having the Terminal open, make it go away by launching the application in the background (append an ampersand (&) to the end of the command that launches the application to background), then using the killall command to make the Terminal quit in your script.
  3. macrumors 65816


    Thanks for that.

    I'm new to scripting too. :eek:

    Strangely, I'm able to get this to work with one binary, but not another. Here's my script

    open /applications/utilities/x11.app
    /usr/bin/open-x11 /sw/bin/xgalaga
    killall Terminal

    For the game xgalaga this works, but when I replace xgalaga with gnubg (the backgammon game), the x11 window for the game briefly flashes on the screen and disappears, nowhere to be found. Not suprisingly, I have no idea why this is happening.

    Of note, when I run the command open-x11 /sw/bin/xgalaga from Terminal things work, but running open-x11 /sw/bin/gnubg, the game window disappears as above. Any thoughts?
  4. macrumors demi-god


    Hmm... interesting. Try this:

    open /applications/utilities/x11.app&
    /usr/bin/open-x11 /sw/bin/xgalaga
    killall Terminal

    Hopefully, that will detach the X11.app from the Terminal, so when you kill it, X11 won't go away. I'd test this, but I'm not at a Mac right now.
  5. macrumors 65816


    Thanks for the help, but that didn't work either. Since it works with one game and not the other, I this it's something specific to gnubg. If there were some way to pass X11 the string "/sw/bin/gnubg" and then have it execute that command, I think things would work, but something about starting in Terminal doesn't seem to agree with gnubg.

    Oh well, after playing around with things for the evening, I think I've found a better alternative anyway. There's another version of gnubng that does come with its own clickable app thing, and it looks a lot better than the version I had been working with earlier. :)

    Thanks again. :)

Share This Page