Because I tend to want to have the computer do different things for the same mime type depending on where it is located or other metadata, libferris lets you tell it what to do based on any arbitrary predicate, instead of a mimetype == value test.
Like most things, this is setup and edited using... drum roll... a filesystem. The filtered bindings are evaluated before the normal mimetype value tests, and if a filtered binding is found it is used instead of any "generic" mimetype based action.
So, for the Qt SDK, I can have double click run the QML application and middle click open the source in emacs with a setup like the one below. Notice that I restrict the override to only /usr/local/qt URLs so I don't go handing QML files from arbitrary sources to qmlviewer. For those new to libferris the "| ferris-redirect" is like the shell ">" but can operate on any virtual filesystem object directly, without using FUSE etc.
fmkdir mime://filtered-bindings/qt-qml
fmkdir mime://filtered-bindings/qt-qml/actions
echo '(&(url=~file:/*usr/local/qt.*)(name-extension==qml))' \
| ferris-redirect mime://filtered-bindings/qt-qml/ffilter
ftouch mime://filtered-bindings/qt-qml/actions/open
echo -n misc/qmlviewer \
| ferris-redirect -a ferris-appname mime://filtered-bindings/qt-qml/actions/open
ftouch mime://filtered-bindings/qt-qml/actions/edit
echo -n emacs \
| ferris-redirect -a ferris-appname mime://filtered-bindings/qt-qml/actions/edit
These actions are used in the ego file manager as well as from the command line with
$ ferris-file-action -v foourl.qml
to view. Of course, alias fv="ferris-file-action -v" is your friend.
1 comment:
Nice blog you have here and I love it because now I know what to do when I encounter a file like these. Thank you for sharing it to us.
http://www.filecure.com
Post a Comment