[SOLVED] New MIME registration from UI file properties

Suggestions and feedback for Linux Mint and the forums
Forum rules
Do not post support questions here. Before you post read: Where to post ideas & feature requests
Post Reply
vittopascu
Level 1
Level 1
Posts: 30
Joined: Mon Mar 11, 2019 7:01 pm

[SOLVED] New MIME registration from UI file properties

Post by vittopascu »

Hello Everyone,

I have been using linux mint for about a year now and I am very happy with it. I would like to thank all the developers for the great work they are doing. I am an electronics engineer and I run my own company entirely on linux mint. One feature that I really miss is a simple way to register a new extension as mime type in the system.

For my work I have several project files from software like Modelsim, Vivado, LT-Spice (through wine) and so on. All these files have unusual file extensions but are fundamentally all text files, but each should be opened with a different program when double clicking. Since the extensions are not listed among the default mime types, these files are all opened by default with a text editor when double clicking. Changing the default program for one type will change it for all files of the same type, meaning all text files. For example, changing the default program for .mpf files to modelsim will make all .txt .vhdl .c .cpp and so on open in modelsim.

To overcome the problem I have made a script to register a new extension as custom mime type with the system, but it doesn't always work and also it is something that industrial engineers need to do quickly, often and without tinkering too much with the system. In windows the type is identified by the extension so the operation is as simple as selecting the "open with" option for a file with such extension.

My suggestion is, in file properties, where the mime type is listed, there could be an option like "register a new mime type with current file extension" or something like that. Such option could suggest a default name for the new mime type that could be overridden by the user with a name of his or her choice and then register it with the system. Or otherwise at least a GUI utility to register mime types easily, not necessarily integrated in the file manager.

Would this be a possibility?

Thanks a lot
Last edited by vittopascu on Thu Sep 12, 2019 11:06 am, edited 1 time in total.
User avatar
all41
Level 19
Level 19
Posts: 9520
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: New MIME registration from UI file properties

Post by all41 »

+1 to upvote this suggestion
Everything in life was difficult before it became easy.
gm10

Re: New MIME registration from UI file properties

Post by gm10 »

Usually it's up to the application developer/maintainer to ensure that the package registers its file extensions upon installation. That's also the way it works on Windows.

But it's an interesting suggestion. if you want it integrated into the file manager your best bet is to request that feature upstream with whatever file manager you are using. I'm not sure it's enough of a general interest feature to be accepted though.

Otherwise a standalone tool would be fairly simple to create, and like most things on Linux that means somebody has already done it. Here's just the first google result I got: http://rox.sourceforge.net/desktop/MIME-Editor, I'm sure you can find more.
vittopascu
Level 1
Level 1
Posts: 30
Joined: Mon Mar 11, 2019 7:01 pm

Re: New MIME registration from UI file properties

Post by vittopascu »

Thank you very much for your suggestion. An utility like the one you suggested would be fantastic, however getting it to work it requires way more tinkering that I am able to perform, and I think a lot of people might be on my same level of incompetence. Would you be so kind to guide me through the process? Especially this ROX library and rox-filer got me quite confused. Thank you again :)
gm10

Re: New MIME registration from UI file properties

Post by gm10 »

vittopascu wrote: Mon May 13, 2019 5:38 pm Thank you very much for your suggestion. An utility like the one you suggested would be fantastic, however getting it to work it requires way more tinkering that I am able to perform, and I think a lot of people might be on my same level of incompetence. Would you be so kind to guide me through the process? Especially this ROX library and rox-filer got me quite confused. Thank you again :)
Today's your lucky day, I went a step or two further even, I packaged the thing for you into a stand-alone version. Figured it might be useful to have around and probably ends up being simpler than trying to walk you through using the original. ;)

Open the .zip and install the .deb inside (just double click on it), then just run MIME-Editor from your menu:
edit: see post below
Last edited by gm10 on Tue May 14, 2019 7:47 am, edited 1 time in total.
vittopascu
Level 1
Level 1
Posts: 30
Joined: Mon Mar 11, 2019 7:01 pm

Re: New MIME registration from UI file properties

Post by vittopascu »

Wow, thank you so much! I was able to install the .deb package but when running the app (from the search bar) the window just flashes, I think I can read "scanning... please wait" and then closes with no further notice. I am running linux mint 19.1 cinnamon 4.0.10 and kernel 4.15.0-48-lowlatency. Any Idea what I might be doing wrong?

Could it actually be that my previous messy activity with registering mime types might be throwing the application off?
gm10

Re: New MIME registration from UI file properties

Post by gm10 »

Possible. Also remember the tool is from 2009, maybe something changed in the meantime that it doesn't support. It seemed to work just fine on my system so I didn't look into it any further. Maybe try to find a more recent tool. Otherwise try to run that one from the command line and see if it gives some info:

Code: Select all

/usr/lib/rox-mime-editor/AppRun
vittopascu
Level 1
Level 1
Posts: 30
Joined: Mon Mar 11, 2019 7:01 pm

Re: New MIME registration from UI file properties

Post by vittopascu »

Thank you for you suggestion. Here is the output of the console:

vpascucci@vpascucci-desktop:~$ /usr/lib/rox-mime-editor/AppRun
Traceback (most recent call last):
File "/usr/lib/rox-mime-editor/type.py", line 274, in scan_file
scanner.parse(path, user)
File "/usr/lib/rox-mime-editor/type.py", line 225, in parse
parser.ParseFile(file(path))
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0
Traceback (most recent call last):
File "/usr/lib/rox-mime-editor/AppRun", line 20, in <module>
box.update()
File "/usr/lib/rox-mime-editor/editor.py", line 91, in update
type.init()
File "/usr/lib/rox-mime-editor/type.py", line 334, in init
scan_file(os.path.join(packages_dir, package), False)
File "/usr/lib/rox-mime-editor/type.py", line 276, in scan_file
rox.report_exception()
File "/usr/lib/rox-mime-editor/rox/__init__.py", line 184, in report_exception
_excepthook(type, value, tb)
File "/usr/lib/rox-mime-editor/rox/__init__.py", line 190, in _excepthook
import debug
ImportError: No module named debug
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/rox-mime-editor/rox/__init__.py", line 190, in _excepthook
import debug
ImportError: No module named debug

Original exception was:
Traceback (most recent call last):
File "/usr/lib/rox-mime-editor/AppRun", line 20, in <module>
box.update()
File "/usr/lib/rox-mime-editor/editor.py", line 91, in update
type.init()
File "/usr/lib/rox-mime-editor/type.py", line 334, in init
scan_file(os.path.join(packages_dir, package), False)
File "/usr/lib/rox-mime-editor/type.py", line 276, in scan_file
rox.report_exception()
File "/usr/lib/rox-mime-editor/rox/__init__.py", line 184, in report_exception
_excepthook(type, value, tb)
File "/usr/lib/rox-mime-editor/rox/__init__.py", line 190, in _excepthook
import debug
ImportError: No module named debug


So I suppose I should install the "debug" python module, which I did through PyCharm that I use for all my python scripting. However I still get the same issue. Could it be a python version difference?
gm10

Re: New MIME registration from UI file properties

Post by gm10 »

Oh, you do python? Could have figured the original script out yourself then. ;)

The debug script not being there was a packaging mistake of mine (I didn't package their full library, had missed the late import for this one). Try this, hopefully I didn't miss anything else:
rox-mime-editor_0.6+build2_all.deb.zip
(41.43 KiB) Downloaded 129 times
vittopascu
Level 1
Level 1
Posts: 30
Joined: Mon Mar 11, 2019 7:01 pm

Re: New MIME registration from UI file properties

Post by vittopascu »

I "do" Python is a gross overstatement :lol: I just plot some arrays occasionally.

Sorry for the late reply. Thank you again for your huge help. Unfortunately I am away for work at the moment and I don't have access to my linux machine. I will try it on Friday as soon as I come back to the office.

Greetings!
vittopascu
Level 1
Level 1
Posts: 30
Joined: Mon Mar 11, 2019 7:01 pm

Re: New MIME registration from UI file properties

Post by vittopascu »

I am happy to announce that the package works like charm. I think I speak for all engineers that are stuck with ill-supported, 20-years-old software to do their daily work, when I say that your help is most appreciated. Thank you very much. Special thanks to the original author of this wonderful tool, I hope he will one day read this post and know how much I appreciate his work.

I wish this tool would be bundled by default with more distributions, at least with Ubuntu and Mint...
gm10

Re: New MIME registration from UI file properties

Post by gm10 »

Happy to help. :)

I could submit it to Ubuntu's repositories I guess, not sure I want to maintain it though. Plus it would only reach LM 20.
vittopascu
Level 1
Level 1
Posts: 30
Joined: Mon Mar 11, 2019 7:01 pm

Re: New MIME registration from UI file properties

Post by vittopascu »

gm10 wrote: Fri May 24, 2019 10:04 am Plus it would only reach LM 20.
What exactly do you mean by that? Will this not be usable for very long?
gm10

Re: New MIME registration from UI file properties

Post by gm10 »

Ubuntu doesn't add new software to released versions of their OS, so it would never arrive in LM 19 / Ubuntu 18.04. And yes, it takes a long time, so it's not a given that I'd even get it in in time for LM 20 / Ubuntu 20.04. Typically you have to get it into Debian's repositories first and then request a sync to Ubuntu's universe repository, but to get it into either you have to get it reviewed first, which can take time.
vittopascu
Level 1
Level 1
Posts: 30
Joined: Mon Mar 11, 2019 7:01 pm

Re: New MIME registration from UI file properties

Post by vittopascu »

I understand. I am super happy with it, I will hold on to it forever, unless a more "official" alternative ever pops up. I love it so much that, should it ever become incompatible with new linux releases, I would give up upgrading rather than losing this tool
gm10

Re: New MIME registration from UI file properties

Post by gm10 »

That much, hmm? Maybe I'll port the thing to Python 3 and GTK3 one of these days (instead of deprecated and soon no longer supported Python 2 and GTK2 that its currently using) and throw it on my GitHub for posterity. ;)
Post Reply

Return to “Suggestions & Feedback”