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

Thread: how to associate a file type with an application?

  1. #1
    Join Date
    Mar 2012
    Beans
    130

    how to associate a file type with an application?

    This isn't so much an ubuntu-specific question, but...in Mac OS X and Windows, there's the capability of associating a particular file extension with an application. When you click on a .pro file, for example, it will open it with Qt Creator (assuming you have that installed). How do I do the equivalent thing in UNIX/ubuntu?

  2. #2
    Join Date
    Jul 2005
    Location
    England
    Beans
    Hidden!

    Re: how to associate a file type with an application?

    Quote Originally Posted by mzimmers View Post
    This isn't so much an ubuntu-specific question, but...in Mac OS X and Windows, there's the capability of associating a particular file extension with an application. When you click on a .pro file, for example, it will open it with Qt Creator (assuming you have that installed). How do I do the equivalent thing in UNIX/ubuntu?
    Right click on a file of that type in the file manager (nautilus) and choose Properties ->Open with- tab. There you can set it to open with whatever you choose.
    DISTRO: Xubuntu 12.04-64bit --- Code-tags --- Boot-Repair --- Grub2 wiki & Grub2 Basics --- RootSudo

  3. #3
    Join Date
    Mar 2012
    Beans
    130

    Re: how to associate a file type with an application?

    OK, but Qt Creator doesn't show up in the list of applications.

  4. #4
    Join Date
    Oct 2010
    Location
    London
    Beans
    481
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: how to associate a file type with an application?

    Right-click on one of the files in question (say, an MP3), click 'properties'; in the properties window, go to the 'Open With' tab and... well, the rest is pretty self-explanatory.

    If you, for example, set one MP3 to be opened by the program VLC; then all MP3s would be opened by VLC when double-clicked.

    This opens according to filetype, however, not extension (if anyone knows how to do that, it would be nifty to share).

    OK, but Qt Creator doesn't show up in the list of applications.
    Click on the button labelled 'Add'; this will bring up a long list of programs. If you know the terminal command to launch QT Creator, then you can use the 'Use a Custom Command' option.

    EDIT: A quick google search tells me that the command should be
    qtcreator

    So you should be able to type 'qtcreator' (without the quotes) into the 'custom command' box.
    Last edited by evilsoup; March 25th, 2012 at 12:57 AM.

  5. #5
    Join Date
    Mar 2012
    Beans
    130

    Re: how to associate a file type with an application?

    Quote Originally Posted by evilsoup View Post
    This opens according to filetype, however, not extension (if anyone knows how to do that, it would be nifty to share).
    Oh...in that case, I probably don't want this after all, as the .pro file is of type "plain text document."

    And...where is this "custom command" box? I don't find that in the properties window(s).

  6. #6
    Join Date
    Oct 2010
    Location
    London
    Beans
    481
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: how to associate a file type with an application?

    Here, I made a screenshot that should help:



    EDIT: I know that what you are looking for is possible, because adding .cbr to the end of the filename for a RAR archive makes the system treat it differently (without the extension it is opened with the archive mounter, with the extension it is opened with evince)... but unfortunately I don't know how to replicate this.
    Last edited by evilsoup; March 25th, 2012 at 01:15 AM.

  7. #7
    Join Date
    May 2005
    Location
    Indiana
    Beans
    1,933
    Distro
    Hardy Heron (Ubuntu Development)

    Re: how to associate a file type with an application?

    There is no more Custom Command in Ubuntu 11.10 and later. Now if you want to add a custom command you have to go through the hassle of manually creating a .desktop file and putting it in ~/.local/share/applications.

    I have no idea why they would make an upgrade be harder to do.
    Today you are You, that is truer than true. There is no one alive who is Youer than You. - Dr. Seuss

  8. #8
    Join Date
    Mar 2012
    Beans
    130

    Re: how to associate a file type with an application?

    Ahh...that explains why my properties window wasn't looking/acting like evilsoup's.

    I hesitate to ask, but...what is involved in making this .desktop file?

  9. #9
    Join Date
    Sep 2007
    Location
    Oklahoma, USA
    Beans
    2,049
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: how to associate a file type with an application?

    You create desktop files with a text editor such as gedit or nano, save them with an extension of ".desktop", and make them executable.

    Here's a sample from my own system for a special script that I wrote. The key items are "Name=" which specifies how the program is shown in menus or on the desktop, "Exec=" which is the CLI command to launch the program (with full pathname, not just the program name itself), and "Icon=" which specifies the icon to associate with it. You can simply copy the other lines, except for "Terminal=" which should be true if it's a CLI program and false if it runs in the desktop.
    Code:
    [Desktop Entry]
    Version=1.0
    Encoding=UTF-8
    Type=Application
    Name=Watcher
    Comment=Notify when FTPed file arrives
    Categories=Application;
    Exec=/home/jk/bin/watcher
    Icon=gnome-fs-network
    Terminal=true
    StartupNotify=false
    It's important NOT to leave spaces on either side of the "=" character of each line.

    Someone else will have to tell you exactly where the file should be saved; I'm on an older version and use Xubuntu rather than Ubuntu, but the spec for desktop files themselves hasn't changed.
    --
    Jim Kyle in Oklahoma, USA
    Linux Counter #259718
    Howto mark thread: https://wiki.ubuntu.com/UnansweredPo.../SolvedThreads

  10. #10
    Join Date
    Jul 2005
    Location
    England
    Beans
    Hidden!

    Re: how to associate a file type with an application?

    I had absolutely no idea that ubuntu/gnome-3/unity had "progressed" so far that a simple thing like a custom command box has now gone from this option in file properties.

    How on earth can gnome devs remove this sort of thing; or is it simply a case of not quite being there yet, like a lot of other configuration options?

    I am so glad I still run 10.04!!
    DISTRO: Xubuntu 12.04-64bit --- Code-tags --- Boot-Repair --- Grub2 wiki & Grub2 Basics --- RootSudo

Page 1 of 2 12 LastLast

Tags for this Thread

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
  •