Changing File Association for applications not shown in list

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
mdwolfe

Changing File Association for applications not shown in list

Post by mdwolfe »

Hi,

My first post so please be gentle. I have upgraded to Mint 12 (32 bit) recently and have my system running well. However I have come across a number of occasions when I would like to associate a file type with an application but the application is not available in selectable list (right click file, Open With Tab, Show Other Applications button). On previous releases I thought there was a Browse facility to search for the appropriate application on the system but this appears to have been removed. Currently I am trying to associate a Gambas executable with the Gambas application but having no luck.

Any help would be greatly appreciated. :D
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
viking777

Re: Changing File Association for applications not shown in

Post by viking777 »

Hi mdwolfe. I will try and answer this question but if succeed it will be a minor miracle, firstly because before I read your post I had never even heard of gambas, and that doesn't make troubleshooting any easier, and secondly because you are saddled with that hopeless piece of garbage that the gnome project seem to think is an acceptable file manager - Nautilus.

However here goes with my best shot. I apologise profusely that this is so ridiculously difficult when it should be ridiculously easy - although maybe someone else will come up with a better way.

Do you have a file called /usr/share/applications/gambas or /gambas.desktop? If you don't have a look in ~/.local/share/applications instead and see if it is there. If you don't have one in either location skip the next few instructions, I have tried to deal with that eventuality further down the page.

If you do have the desktop file in one of those locations then that is a start at least. You wont be able to open it because Nautilus is too dumb to let you, it will only run it. If you had a decent file manager as I do, you would be able to open it but sadly you don't because you haven't been given one, and that really is pretty shocking in itself, and in no way your fault. So we have to go about it another way.

Continuing to look in that same location/s look for a folder called /usr/share/applications/mimeinfo.cache, or ~/.local/share/applications/mimeapps.list this is where the list of file type associations is kept. You will need to modify this with a text editor (and if your gambas desktop file is in /usr/share/xxxxxx you will need to have sudo privileges to do this, so - sudo gedit - ) for the ~/.local/xxxxx location you wont need sudo.

You need to add to one or other of these files a couple of lines line like this:

Code: Select all

application/x-extensions-gambas=gambas.desktop
application/x-gambasscript=gambas.desktop

Now I must add here that those mime types are ones that I have been able to glean by going online and searching, they may not be the only two that you need, I don't know as I don't use gambas you may have to research this further if those two alone don't work.

So, what if you don't have a 'gambas' desktop file in either location?

Answer, you have to write one yourself. It is only a text file so you just right click on one of the locations above and select 'Create new document'/Empty Document. After that what you put in will look something like this:

Code: Select all

Name=Gambas
Exec=gambas
Icon=/usr/share/icons/gambas.png
Type=Application
StartupNotify=false
NoDisplay=true
Hidden=false
Terminal=false
MimeType=application/x-extensions-gambas;application/x-gambasscript;
Then save it as gambas.desktop.

I cannot stress strongly enough that almost every entry that I have written in that file is guesswork and MUST be verified by you first (you can't do any damage by writing it as I have written it, but it more than likely wont work). I repeat I know nothing about this program and so cannot possibly write a correct desktop file for this program.

And that is all it is :shock:

I really hope for your sake that somebody else comes up with a better way :)

Good luck.
mdwolfe

Re: Changing File Association for applications not shown in

Post by mdwolfe »

Wow thanks Viking77 for your detailed reply. You gave me all the tools I needed to find the solution :D .

Here's what I found and the solution I came up with based on your info:-

Gambas has a separate BIN that runs scripts as an application called GBR2. By running 'gbr2 applicationname.gambas' from the terminal, the script would run as I required. Once I knew this I added a file '/usr/share/applications/gambas2executable.desktop' as you had advised, as shown below:-

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Exec=gbr2
Icon=/usr/share/pixmaps/gambas2.xpm
Terminal=false
Name=Gambas2 Executable
Name[es_ES]=Gambas2 Executable
Comment=Gambas Almost Means Basic
Comment[es_ES]=Gambas es parecido a Basic Visual
Type=Application
Categories=Development;
StartupNotify=true
MimeType=application/x-extensions-gambas;application/x-gambasscript;
I then added the following to '/usr/share/applications/mimeinfo.cache' :-

Code: Select all

application/x-extensions-gambas=gambas2executable.desktop
application/x-gambas=gambas2executable.desktop
This fixed my problem. As you quite rightly say, it should never be this difficult, but all the time there are helpful people like yourself around willing to share their knowledge we can all carry on enjoying the Linux experience.

Thanks once again and a Happy New Year to you.
Locked

Return to “Software & Applications”