View Full Version : [ubuntu] make click behaviour dependant on file extenxion

January 2nd, 2011, 01:33 AM
Is there any way to make the response to mouse clicks of any sort vary according to the file extension? For instance, the biggest motivation to this question is that I would like to be able to name some text files filename.txt and others filename.sh and have a double click open with gedit in the first case and run it in the second case. I know I can set it to do one or the other or even ask which but that is a real pain compared to being able to just double click and get it to do what I want. If I want to edit filename.sh or run finename.txt I'd like to be able to do that with a right click context menu but this is less important. For rarely done things I can always rename the file if that is what it takes. But running scripts and reading text files are things we all do very often so bypassing that choose menu would be very helpful. I get the impression some 'nixers like to brag on the OS not needing extensions (which isn't entirely true, some file types are NOT handled correctly if the OS doesn't get a hint through the extension and some are handled incorrectly if the extension is wrong) while to me this default handling of txt files seems more a limitation than a feature. On a related note, is there any way to get gedit or other editors to save files as filename.txt by default?

There are other examples of how this extension dependent behavior setting could be useful such as renaming some media files with an arbitrary extension to force them to open in a particular player or even be used as entering arguments in a script so a generic solution to this along the lines of a config file somewhere where you could say "files with extension .ext17 should elicit such-and-such a response on double left clicking and THIS menu on right clicking" would be good. But the only area that where it seriously inconveniences me is the above example of txt vs sh or even bat (which of course I would want to open under wine).

TIA for any suggestions.