File / Application association using a custom command is gone?

In previous Ubuntus when you want to select/change an application to open a specific file (right-click/open with other application or properties) you were able to write a custom command to open the file. This was very useful, but now in 11.10 I can't find this option, it only shows me a list of applications and a button to look for applications in Internet.

Is there a way to restore the command line to write custom commands to open files?


Solution 1:

As I found on http://blog.whatgeek.com.pt/?p=319 you can use mimeopen -d /path/to/file to configure a custom application on the cli. It will be used by gnome3 then.

$ mimeopen -d foo.matroska 
Please choose a default application for files of type application/x-matroska

    1) VLC media player  (vlc)
    2) Banshee  (banshee)
    3) Movie Player  (totem)
    4) Other...

use application #4
use command: mplayer
Opening "foo.matroska" with mplayer  (application/x-matroska)

Solution 2:

I have cooked this little script to allow our users to open a file with a program of their choice.

https://github.com/gecos-team/openwith

This package includes:

1) A little shell script that prompts you to choose a binary (using a simple Zenity dialog). This script should be named /usr/bin/openwith

#/bin/sh

DEFAULT="/usr/bin/"

FILE=`zenity --file-selection --filename=$DEFAULT --title="Open with..."`

case $? in
         0)
                "$FILE" "$1";;

esac

2) An openwith.desktop file you must place in /usr/share/applications/ so you can choose "openwith" when right-click on a file in Nautilus.

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon=application-default-icon
Name=a program of your choice...
Name[es_ES]=un programa a elegir...
Comment=Open a file with a selected program
Comment[es_ES]=Abre un archivo con el programa seleccionado
Exec=/usr/bin/openwith %f

Solution 3:

Extending this idea, try creating .desktop files for the mimeopen -a and mimeopen -d commands. This restores the ability to open via a custom command to the right context menu, albeit you have to dig down in the menu a bit to get at it.