You are not logged in.
https://xyne.dev/projects/mimeo
This was mostly inspired by this thread and the fact that I had already written most of the code for ObFilebrowser. This is mostly intended for use with Mimeman and PCManFM but it should work with anything that creates MIMEtype associations the same way.
*edit*
I've added URL support via an associations file which matches regexes against the arguments so it can be used for other things as well.
Feel free to share your ideas. Feedback is welcome as always.*
* Before the "but there's already an app to do this" posts start showing up, yeah, I know. They're all a bit different though and this is written to specifically work with apps that I use and is based on code that I had already written. It suits my needs (well, I don't actually use it, but if I did use an opener, this would be it) and I share it in case someone else finds it useful. If you know of a better app, use it.
/semi-professional re-inventor of the wheel
Last edited by Xyne (2012-09-04 16:26:24)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
well, I'll have to say: Thank you! it's a great wheel to reinvent, because the implementations there already are seem cryptic and inconsistent to me (as far as I could tell...)
Offline
… cryptic and inconsistent to me (as far as I could tell...)
mime handling in Linux IS cryptic and inconsistent!
Offline
I tried to use mimeo in conkeror and in mutt's mailcap and it fails to open any file. My guess is that I miss an environment variable? Or something else? Should I post more info? If I use it from the command line it works properly (eg. for a pdf file) ...
Offline
@tzervo
I don't use conkeror or mutt so I can't easily debug this. Have you actually configured mimetype associations for the files that you're trying to open? If not, you need to create them with mimeman (or pcmanfm).
I've just tested using mimeo from gmrun and that works, so I would expect it to work with other applications that invoke it.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
I have checked the file /usr/share/applications/mimeinfo.cache for the default application I want to run (eg. xpdf for pdf files) and it exists. I believe that running mimeo from the console (which indeed opens my pdf with xpdf) confirms that it is ok? Is there another check I should do regarding my mime configuration? Is the output of xdg-mime/xdg-open relevant? (I have no DE, just musca with a bunch of terminals mostly)
Offline
mimeo is fine, I think the problem is with conkeror (it also has issues with rox and pcmanfm - or I am doing something wrong). By the way, excellent app (both this and mimeman), it is DE-agnostic and does just what it is expected to do. I like it!
Offline
I asked about the associations in case you were trying to open other types of files via conkeror (i.e. not pdfs, which obviously work if you can open them directly with mimeo). The output of xdg-{mime,open} is irrelevant afaik.
I don't know how conkeror invokes applications, but you can try invoking this script to see which arguments it passes (or if it even runs at all):
#!/usr/bin/env python2
from sys import argv
print 'invoked script with ' + ', '.join(argv)
Sorry that I can't be of more help but I agree that this seems to be a conkeror problem.
Thanks for the feedback.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
OK, I found it. The problem with both mutt and conkeror is that they delete the temporary file (ie. the file I try to open) as soon as the external command terminates. In our case the external command is mimeo and not xpdf. So once mimeo does its job, the /tmp/*.pdf file is deleted and xpdf finds nothing to open. In conkeror the workaround is either to set
delete_temporary_files_for_command = false;
in conkerorrc, so that the file is still there (although manual cleaning is required afterwards) or another way to stall mimeo after it has called the application to open the file (a clever usage of "mimeo -c"; I am still working on it). I will return if I have something new either for this or for mimeo with mutt!!
EDIT
`mimeo -c %s` works in mutt's mailcap. It forks the actual command instead of mimeo so the file is there until the command terminates. I am beginning to like it veeeery much!
Last edited by tzervo (2010-01-27 04:59:46)
Offline
I actually had to check the help message of mimeo to see what "-c" does.
If conkeror works the same way, then maybe you could use this script:
#!/bin/bash
$(mimeo -c $1)
Btw, thanks for effectively documenting this.
Last edited by Xyne (2010-01-27 05:12:27)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
The script worked perfectly. Thanks a lot. (I named it "mimeoc" !! :-p)
Offline
what's wrong with xdg-mime?
http://portland.freedesktop.org/xdg-uti … -mime.html
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
Probably nothing. Try them both and draw your own conclusions. I wrote this to complement mimeman and obfilebrowser, and I wrote those to be compatible with mimetype handling in pcmanfm. As with most things I post, I personally find it useful and I share it in case others do (which, however few, some do).
Btw, phrasing your post the way you did is the same as if you had posted "what's wrong with Awesome?" in an Xmonad thread.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Btw, phrasing your post the way you did is the same as if you had posted "what's wrong with Awesome?" in an Xmonad thread.
Not really. Both are well-established projects with big communities and I know the differences.
Your project is new, whereas xdg-mime is well-established. And I have no clue what would be the difference between them.
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline
From what I have understood (although I am quite new to this), xdg-mime is a way for the big DE's (gnome, XFCE and KDE) to use the mime associations for their openers and their databases. If one does not use these DE's, one must "mask" his environment as one of these to be able to even use xdg-{mime,open}. Mimeo just uses mimeinfo.cache (both global and local) and can be used in any possible environment setup (according always to the freedesktop specs). Since I don't use KDE, gnome or XFCE I could not use xdg-{open,mime} (no gconf or kde-something here) whereas mimeo just read my mimeinfo.cache and worked out of the box (well, almost). I found out that this was the most KIS solution. Correct me if I understood something the wrong way...
Offline
xdg-open doesn't make use of the data created by xdg-mime. If it did, there probably wouldn't be much use for mimeo, but since it doesn't, this is very valuable.
Offline
Even if it did... In my example above, I have associated xpdf to pdf files. This is registered in mimeinfo.cache. Even then, "xdg-mime query default application/pdf" gives me no output. I have looked into xdg-mime (it is a bash script) and in line 447 it has a function for checking out which DE I have. What if I don't?
I tend to think of mimeo as pcmanfm without the file manager (it just parses mimeinfo.cache and opens the file, nothing more)!!! It is good for the command line, good for conkeror (pcmanfm had issues when I used it for handling MIME) and good for mutt. Before that, I used ugly ad-hoc patches and environmental variables (like BROWSER,PDF_READER etc) to have something like centralised mime handling/opening.
@Dieter: wouldn't it also be good as a file opener for using in conjunction with uzbl? Just one more small script that joes one job well?
Last edited by tzervo (2010-01-27 22:40:56)
Offline
I'm having a problem loading mimeo manually with video/x-matroska related files and having it freeze without the process being killed.
I noticed I got this output with Ctrl-C:
Traceback (most recent call last):
File "/usr/bin/mimeo", line 245, in <module>
main()
File "/usr/bin/mimeo", line 241, in main
launch( *getCmd(args[0]) )
File "/usr/bin/mimeo", line 125, in getCmd
mimetype = getMimetype(fpath)
File "/usr/bin/mimeo", line 117, in getMimetype
output = proc.communicate()[0]
File "/usr/lib/python2.6/subprocess.py", line 681, in communicate
stdout = self.stdout.read()
KeyboardInterrupt
EDIT: Actually since the file I was trying to load had escaped spaces, I put quotes around it and I got this error:
error: no mimetype association for troska
Last edited by Acecero (2010-02-05 23:37:27)
Offline
I think I've fixed the error due to spaces in the name.
Use mimeman or pcmanfm to create an association for troska files and then mimeo should detect it.
Last edited by Xyne (2010-02-06 04:59:01)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
The fixed update solved my problem. I also switch to pcmanfm to be safe.
Thanks Xyne.
Offline
I just found out about this great piece of software.
Thanks! it's great!
Offline
Is there a way to make it open multiple files (like pcmanfm?) I tried mimeo *mp3 on a bunch of mp3 files while having defined as application this simple script:
#! /bin/sh
xterm -e mplayer "$@"
The script by itself works but it seems that mimeo takes only the first file as an argument...
pcmanfm on the same example works.
Offline
@tzervo
I've updated mimeo to support multiple arguments. It will group them so that each unique command is called once with all the matching arguments. Let me know if it works as expected.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
It works excellent if there are no spaces in the absolute path of the files. With spaces it fails (mimeo -c "something with spaces"...)
EDIT
Another question: how do you determine the MIME type in mimeo? From what I've seen, xdg-open uses the command file, so it is impossible for me to define new types by extension for text files in $HOME/.mime.types. (I wanted to assosiate vtk files with paraview). Is there a way/suggestion to define text MIME by extension and then bind them to mimeo? (sorry if this is slightly off-topic)
EDIT EDIT
Since I suspect that there is no standard-conforming way to discriminate between the text/* files, I will probably point mimeo to a script that opens only text files by extension. (I wonder where $HOME/.mime.types could be used though....). Again thanks for this very useful app!
Last edited by tzervo (2010-02-23 18:10:54)
Offline
The only problem that I found with spaces was that it quoted arguments when launching applications, which it shouldn't have done. I've corrected that, but I don't understand what the problem with "mimeo -c ..." is/was.
Mimeo uses Python's mimetypes module to determine mimetypes. If that fails, it falls back on "file --mime-type". If you know of a way to get the mimetype by extension, I will consider implementing it.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline