Thank you ted and JimH. You're right `nrngui test.hoc` does work as expected. The reason why I thought it didn't is because of the way the double-click launch works on Ubuntu. What I wanted to do is to replicate the Windows' version functionality of being able to double click on the .hoc file and have nrniv launch it. I did end up solving it in the end though. Here's my solution, in case anyone finds it useful. Note that it probably only works on Ubuntu.
First you need to register .hoc as a separate MIME type from the normal plain-text files.
Call up the terminal and type in this:
Code: Select all
gksudo gedit /usr/share/mime/packages/freedesktop.org.xml
Then, add the following lines somewhere inside it near the other MIME types.
Code: Select all
<mime-type type="text/x-hoc">
<sub-class-of type="text/plain"/>
<comment>hoc code</comment>
<glob pattern="*.hoc"/>
</mime-type>
For some older versions of GNOME it helps to make it be a subset of "test/x-csrc" instead. Try it if it complains about filetypes being wrong
Now, exit gedit and type in this:
Code: Select all
sudo update-mime-database /usr/share/mime
and then:
Put this into the opened file:
Code: Select all
#!/bin/bash
DIR=`dirname "$1"`
gnome-terminal -e "nrniv $1 - -dll ./x86_64/.libs/libnrnmech.so" --working-directory="$DIR"
Note:Replace ./x86_64/.libs/ by something else, if your nrnivmodl puts the libnrnmech.so in a different place
Close gedit again and type in:
Find the 'nrn' file you created, right click it, click properties and go to the Permissions tab. Make sure the 'Allow executing file as a program' check box is checked.
Now, find a .hoc file and right click that.
Click Properties->Open With->Add->use custom command
In that edit box, type in 'nrn'.
Now, upon double clicking the terminal will pop up with the hoc file opened. Also, if you compiled the mechanisms the nrniv should have loaded those as well.