Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: How to create custom file associations on Gnome 3

  1. #1
    Join Date
    Sep 2008
    Beans
    26
    Distro
    Ubuntu 12.04 Precise Pangolin

    Talking How to create custom file associations on Gnome 3

    So you installed Gnome Shell and you want to open a specific type of file with your favorite application but when you select 'Open With' from the Nautilus menu, your application is not on the list? The good old Gnome 2.X had an option to open with a 'custom command', missing it already? I agree, its a design flaw.

    So... here's how you do it.


    1. Add your Application
    First, you have to add your application so that Gnome Shell can find it. This can be done by creating a .desktop file. Run this command where myapp is the name you want to give your app.
    Code:
    sudo gedit /usr/share/applications/myapp.desktop
    Now create the file with the following format:
    Code:
    Exec=/path/to/your/app %U
    Version=1.0
    Name=My First App
    GenericName=MyApp
    X-GNOME-FullName=My First Application
    Comment=This app will do this and this
    Icon=myapp-icon
    StartupNotify=true
    Terminal=false
    Type=Application
    The Icon value sets an icon to your application found in /usr/share/app-install/icons/
    If you don't like any of the exiting icons, you can add your own! It's just a small .png image.


    2. Find out what file type you want to associate
    Right click your file, select Properties and look under Type, it should be something like application/x-type. Here's a screenshot!




    3. Associate the file type with your application
    Run the following command
    Code:
    sudo gedit /usr/share/applications/defaults.list
    Now add your file type (preferably in an alphabetically correct place) and link it to your application.
    Example:
    Code:
    application/x-type=myapp.desktop

    4. Logout and Login again
    I think this is necessary (its not enough to just restart the Gnome-shell).

    5. Done!
    Enjoy just having to double-click your files to open with your favorite application.
    Last edited by kalaka; October 16th, 2011 at 10:49 PM.

  2. #2
    Join Date
    Dec 2007
    Location
    Raleigh, NC
    Beans
    77
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How to create custom file associations on Gnome 3

    Thanks, Kalaka!

    This isn't working for me, though.

    I need to invoke a wine application (MS Project 2003 for *.mpp files), so I generated my "desktop" file as follows:

    PHP Code:
    Exec=env WINEPREFIX="/home/mswallow/.wine" wine "C:\Program Files\Microsoft Office\OFFICE11\WINPROJ.EXE" %U
    Version
    =1.0
    Name
    =msproject2003
    GenericName
    =msproject2003
    X
    -GNOME-FullName=msproject2003
    Comment
    =This app will open up the wine version of MS Project 2003
    Icon
    =projectl.png
    StartupNotify
    =true
    Terminal
    =false
    Type
    =Application 
    I notice that in the applications directory, it's the entry that has the ".desktop" fully qualified on it. Also, I wonder if I'm specifying the "Exec" correctly. Can you take a look?

    I did make the change to the defaults.list file: audio/x-musepack=msproject2003.desktop

    Appreciate any help!
    Regards,
    Mark S

  3. #3
    Join Date
    Jun 2007
    Beans
    16,017

    Re: How to create custom file associations on Gnome 3

    There are several ways to do an Exec= for wine in a custom .desktop
    If you are going to use a env of WINEPREFIX then don't "" your wine command.
    Also the %U may not be good to have - *an anomaly of gnome 3 is that any .desktop tat doesn't have have an %<some letter> on the Exec= line will not show up in the r. click > properties > open with list, so you can try with it included or remove if need be, doesn't matter that much

    So you could try this Exec= instead, if no go then try without the %U
    Code:
    Exec=env WINEPREFIX="/home/mswallow/.wine" wine C:\\\\Program\\ Files\\\\Microsoft\\ Office\\\\OFFICE11\\\\WINPROJ.EXE %U
    Or Try something like this, again with or without the %U

    Code:
    Exec=wine "C:\Program Files\Microsoft Office\OFFICE11\WINPROJ.EXE" %U
    (Not a big fan of using defaults.list to set a new default, think it's better to do locally in ~/.local/share/applications/mimeapps.list for both Added & Default

    You could also add a line to your .desktop that may provide some benefit
    Code:
    MimeType=audio/x-musepack;
    Edit: if still having difficulty with either of the above you could try adding this to the .desktop, though shouldn't matter.
    Code:
    Path=/home/mswallow/.wine/dosdevices/c:/Program Files/Microsoft Office/OFFICE11
    Last edited by mc4man; November 1st, 2011 at 08:06 PM.

  4. #4
    Join Date
    Dec 2007
    Location
    Raleigh, NC
    Beans
    77
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How to create custom file associations on Gnome 3

    Thanks, mc4man,

    Well, I've tried various incantations without success. I think there's something more fundamental wrong. When I compare properties for my entry against those already there, I get major differences:



    The one on the left is "standard" and the one on the right is mine.

    See what I mean?
    Attached Images Attached Images
    Regards,
    Mark S

  5. #5
    Join Date
    Jun 2007
    Beans
    16,017

    Re: How to create custom file associations on Gnome 3

    Your .desktop is missing a key line (at least as posted
    The very 1st line needs to be
    Code:
    [Desktop Entry]
    Here's an example of one I have for ImgBurn, note that I've not set any Mimetype= or Category= for this, no need for my use case (I just open ImgBurn, then do as I intend
    Code:
    [Desktop Entry]
    Name=ImgBurn
    Exec=env WINEPREFIX="/home/doug/.wine" wine C:\\\\Program\\ Files\\\\ImgBurn\\\\ImgBurn.exe 
    Type=Application
    StartupNotify=true
    Path=/home/doug/.wine/dosdevices/c:/Program Files/ImgBurn
    Icon=8074_ImgBurn.0

  6. #6
    Join Date
    Dec 2007
    Location
    Raleigh, NC
    Beans
    77
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How to create custom file associations on Gnome 3

    Thanks, again .... so I've updated the file to be

    PHP Code:
    [Desktop Entry]
    Name=msproject2003
    Exec
    =env WINEPREFIX="/home/mswallow/.wine" wine C:/Program Files/Microsoft Office/OFFICE11/WINPROJ.EXE %U
    Path
    =/home/mswallow/.wine/dosdevices/c:/Program Files/Microsoft Office/OFFICE11
    GenericName
    =msproject2003
    X
    -GNOME-FullName=msproject2003
    Comment
    =This app will open up the wine version of MS Project 2003
    Icon
    =projectl.png
    StartupNotify
    =true
    Terminal
    =false
    Type
    =Application  
    MimeType
    =audio/x-musepack 
    It's still not working and I still see a big difference in properties:



    Any other ideas?
    Attached Images Attached Images
    Regards,
    Mark S

  7. #7
    Join Date
    Jun 2007
    Beans
    16,017

    Re: How to create custom file associations on Gnome 3

    Try this -
    delete that file you've created in /usr/applications

    Open a terminal & go
    Code:
    gedit ~/.local/share/applications/msproject2003.desktop
    Use this inside, save & exit gedit (copy & paste
    Code:
    [Desktop Entry]
    Version=1.0
    Type=Application
    Exec=Exec=env WINEPREFIX="/home/mswallow/.wine" wine C:\\\\Program\\ Files\\\\Microsoft\\ Office\\\\OFFICE11\\\\WINPROJ.EXE 
    Name=msproject2003
    Icon=projectl.png
    Comment=This app will open up the wine version of MS Project 2003
    Path=/home/mswallow/.wine/dosdevices/c:/Program Files/Microsoft Office/OFFICE11
    MimeType=audio/x-musepack;
    Then in same terminal
    Code:
    chmod u+x ~/.local/share/applications/msproject2003.desktop
    Now browse to ~/.local/share/applications & d. click on the icon, see if it starts your app.

    If that goes well then see what happens if you d. click on a .mpp
    (it's possible your prog will open but not load the file - if so that can likely be fixed
    If your prog doesn't open then that can also be fixed..

    Edit: - in the future if you post a .desktop put it in a code box, not PHP
    Last edited by mc4man; November 2nd, 2011 at 04:41 AM. Reason: no PHP box for .desktops when posting

  8. #8
    Join Date
    Dec 2007
    Location
    Raleigh, NC
    Beans
    77
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How to create custom file associations on Gnome 3

    mc4man,

    Excellent! All works!

    (Sorry for the php...)
    Regards,
    Mark S

  9. #9
    Join Date
    Jun 2007
    Beans
    16,017

    Re: How to create custom file associations on Gnome 3

    Quote Originally Posted by MSwal2846 View Post
    mc4man,

    Excellent! All works!

    (Sorry for the php...)
    There is a possible variation to your Exec= that you might try at some point.
    It would only be needed if you were using unity, added the .desktop to the launcher & wanted to use Drag & Drop of .mpp files on to the icon.

    If so & they didn't open loaded in your prog then try adding this to the end of the Exec= line, using a space after .EXE
    Code:
    Z:%f
    (For some reason when I tried copying your posted .desktop's from the php box they'd always produce a bad .desktop until I replaced all the lines, can't quite figure that one out...

  10. #10
    Join Date
    Dec 2007
    Location
    Raleigh, NC
    Beans
    77
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How to create custom file associations on Gnome 3

    Ok, got it ... I'll give that a try...
    Regards,
    Mark S

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •