KGS: How-to set up SGF file associations on Mac OSX.

Comments, questions, rants, etc, that are specifically about KGS go here.
Post Reply
rubin427
Lives in gote
Posts: 338
Joined: Sat Dec 05, 2009 9:24 pm
GD Posts: 0
Location: Las Vegas, NV
Has thanked: 163 times
Been thanked: 62 times

KGS: How-to set up SGF file associations on Mac OSX.

Post by rubin427 »

Setting up SGF file associations for KGS/CGoban3 on Mac OSX is a topic that comes up from time to time (previous discussions from 2009, 2008, and 2007).

I've come up with an alternative method to that same ends, which I'll be describing here. (The previously discussed methods didn't work for me.) This process has three parts. First we use "automator" and some bash scripting to create a mac-friendly wrapper to kgs that can launch arbitrary SGF files when they are dragged onto the application icon. Secondly, we use OSX native file associations to associate one specific SGF file with the wrapper so that double clicking that SGF will open it in KGS. Finally, we make the file association applicable to all SGF files on the system. These techniques work for me using OSX 10.6.6, your results may vary.

Part 1: An Automator wrapper for KGS
1.1) Launch "Automator" from your apps folder.
1.2) When asked to "Choose a template for your workflow", chose "Application"
Image

1.3) Select the "Run Shell Script" action which is found under Actions->Library
Image

1.4) Set the drop-down menu "Pass input:" to "as arguments"
1.5) Copy and paste the following script into the window:

Code: Select all

if [ "${1}" == ""  ]; then
  /usr/bin/javaws  ~/bin/cgoban.jnlp
else
  /usr/bin/javaws  ~/bin/cgoban.jnlp -nosplash -open $1
fi

in the script above, "~/" is a shortcut notation for "my home directory". You can see I keep my copy of cgoban.jnlp file in ~/bin/. You may need to adjust this path to point to where you keep your copy of cgoban.jnlp.
1.6) Chose "save as" from the file menu. I suggest you save the application in either /Applications, or in ~/Applications. Name the application whatever you like, I've chosen "auto_kgs".

Testing our progress so far: Open the finder to the folder where you've saved the wrapper application in step 1.6. You should see a new application with your chosen name. double-clicking this application should open KGS. Dragging any SGF file onto this application should open that SGF in KGS. If either of these tests fail, something has gone wrong.

Part 2: Setting up file associations for one specific SGF file
2.1) Double click (or control+click) any sgf file.
2.2) Chose "Open with ->" "Other".
2.3) Find your application created in step 1.6. Checkmark the box "Always open with". Finally, click open.
2.4) This specific sgf file should always open in KGS from now on.

Part 3: Expanding file associations for all SGF files
3.1) Double click (or control+click) on the specific sgf file from part 2.
3.2) Choose "Get Info" from the menu.
3.3) Expand the "Open with:" drop-down menu
3.4) Make sure your wrapper application from step 1.6 is listed in the "Open with:" drop-down menu.
3.5) Click on the "Change All..." button
Image

3.6) Click on "Continue" when the pop-up pops up.

Well, with any luck, it's now working for you.

Edit History:
Sat March 26, added instructions for part three, revised previous steps slightly.
User avatar
Jedo
Lives in gote
Posts: 588
Joined: Wed Apr 21, 2010 3:30 am
Rank: 2D KGS
GD Posts: 0
Location: NY
Has thanked: 123 times
Been thanked: 46 times

Re: KGS: How-to set up SGF file associations on Mac OSX.

Post by Jedo »

Very cool idea, I'll be thrilled if this works.

Problem: I was doing part 1, but when I tested the autokgs automater it tried to launch javaweb start but then crashed, saying unable to launch application. Ideas?

I did a quick spotlight search, and I couldn't find a cgoban.jnlp file on my comp, despite using the cgoban app all the time. huh?
"There are no limits. There are plateaus, but you must not stay there, you must go beyond them. If it kills you, it kills you. A man must constantly exceed his level." -- Bruce Lee
rubin427
Lives in gote
Posts: 338
Joined: Sat Dec 05, 2009 9:24 pm
GD Posts: 0
Location: Las Vegas, NV
Has thanked: 163 times
Been thanked: 62 times

Re: KGS: How-to set up SGF file associations on Mac OSX.

Post by rubin427 »

Jedo wrote:I did a quick spotlight search, and I couldn't find a cgoban.jnlp file on my comp, despite using the cgoban app all the time. huh?


Visit the KGS download site:
http://www.gokgs.com/download.jsp

Image


Image


Right-Click on the link, "CGoban for Java Web Start", and choose "Download linked file as...". Wherever you download the file to, you need to modify the bash script to match.

To provide a specific example, lets say you download cgoban.jnlp to /Applications, then you need to adjust the bash script used in Part 1.5 to the following:

Code: Select all

if [ "${1}" == ""  ]; then
  /usr/bin/javaws  /Applications/cgoban.jnlp
else
  /usr/bin/javaws  /Applications/cgoban.jnlp -nosplash -open $1
fi
GoAcademy
Beginner
Posts: 12
Joined: Sat Jan 31, 2015 7:05 am
GD Posts: 0
KGS: Oel
Been thanked: 5 times

Re: KGS: How-to set up SGF file associations on Mac OSX.

Post by GoAcademy »

Thanks a lot for this explanation. It still works perfectly for me (I am using Mac OS X 10.11 El Capitan). The only issue I had was with my file structure. You should not have any white spaces neither in the filename nor in the path.
xed_over
Oza
Posts: 2264
Joined: Mon Apr 19, 2010 11:51 am
Has thanked: 1179 times
Been thanked: 553 times

Re: KGS: How-to set up SGF file associations on Mac OSX.

Post by xed_over »

GoAcademy wrote:Thanks a lot for this explanation. It still works perfectly for me (I am using Mac OS X 10.11 El Capitan). The only issue I had was with my file structure. You should not have any white spaces neither in the filename nor in the path.


quote the last argument to fix that

Code: Select all

if [ "${1}" == ""  ]; then
  /usr/bin/javaws  /Applications/cgoban.jnlp
else
  /usr/bin/javaws  /Applications/cgoban.jnlp -nosplash -open "$1"
fi
Post Reply