Re: mimeo: open files by mimetype or file name

Yeah, that's clear... I just don't know what the best solution is. I did some research before switching my hashbangs over to use env, and it seemed that the consensus was that using env was the best compromise on most systems. I'm not opposed to reverting to direct paths but I need to research it again.

Can you just create a mimeo clone with #!/usr/bin/python2 in the meantime?

Re: mimeo: open files by mimetype or file name

Is mimeo arch specific? If so, what's wrong with making it the direct python2 path?If it's not arch specific and you want it for more systems then you have to use the packaging system to change that line for you.E.g. if you want to distribute it as an egg (on pypi, etc), then you most likely will have somethin like this in your setup.py:---entry_points = dict( console_scripts = [ "mimeo = Mimeo:main" ], ),---then setuptools/distribute will generate the /usr/bin/mimeo file (with a fix python interpreter) for you.

Hope that helps, Daniel

PS: Of course I just changed the header 'by hand', but thought it might help to fix it in the upstream.

Re: mimeo: open files by mimetype or file name

Hi Xyne,

first of all thank you for making mimeo available.

I couldn't find a solution to my problem yet I would really appreciate your help.

I use a tcl script program named A Plasmid Editor (http://biologylabs.utah.edu/jorgensen/wayned/ape/) with tclklik to open/edit essentially text/plain mime-type files that have extensions .ape .dna etc. I have created an ape.desktop file which executes " tclkit /path/to/script/ApE.tcl". In pcmanfm I can right click and choose this "program" to open such files with ApE, however,

1) I would like to be able to open them with double click of the icon in pcmanfm2) also be able to open them using the "file:///path/to/ape_file.dna" links in libreoffice documents.

I am not sure if the solution to 1 and 2 are the same. At least for the first part I tried change the tclkit.desktop "Exec=" line from "tclkit %f" to "tclkit /path/to/script/ApE.tcl" (anyway this is the only tcl script currently I am using) and I put the following lines to ~/.config/mimeo.conf:

Re: mimeo: open files by mimetype or file name

Hi,

shugoshin wrote:

At least for the first part I tried change the tclkit.desktop "Exec=" line from "tclkit %f" to "tclkit /path/to/script/ApE.tcl"

Why did you omit "%f" from the new command? That's the placeholder for the file name. Normally the filename will be added to the end of the command if no placeholder is found, but I would keep it if the original Exec line included it.

In any case, editing the desktop file is not the way to do this. It will be overwritten on update and break any application that uses it (which is probably none, but it's bad practice nevertheless). You can create custom desktop files with mimeo (see below), or you can just copy the tcl desktop file to ~/.local/share/applications, rename it and edit it as you wish.

shugoshin wrote:

and I put the following lines to ~/.config/mimeo.conf:

/usr/bin/tclkit
\.dna$
\.ape$

The syntax is correct but I would also add "%f" or "%F" to the command in mimeo.conf. You have also omitted "/path/to/script/ApE.tcl" from the command. Nevertheless, it should try to open those files with tclkit. If it is still opening them with leafpad then you have misconfigured something.

Make sure that there are no syntax errors mimeo.conf and that the file is readable by the user running mimeo. If you are using sudo or any other command that changes the effective user ID then you need to edit that user's mimeo.conf.

Check the command that mimeo is trying to use by passing it the "-c" option, as shown in the example above. If you do not get the same output that I did for the same configuration file then you have done something wrong.

I would also check what mimetype mimeo reports for .dna and .ape files, as it may be different than the type reported by some other commands.

mimeo -m ape_file.dna

If it is unique(-ish), then create a custom desktop with mimeo and associate it with that mimetype

After that you could either create a preference for that desktop file directly in pcmanfm if it detects the same mimetype, or you could create a preference for mimeo if it detects something else. You could also remove the above lines from mimeo.conf if the mimetype is unique.

If the mimetype truly is text/plain then use the mimeo.conf posted above and configure pcmanfm to open .ape and .dna files with mimeo. Do not use mimeo to set a preference for mimeo. This will likely create an infinite loop or invoke the end of days. Mimeo will catch .ape and .dna files by name and pass other text/plain types to your preferred text editor.

Finally, for libreoffice, regardless of the method used above, you should just need to specify mimeo as the file opener for those documents.

Re: mimeo: open files by mimetype or file name

Hey,

thanks for this nice contribution, Xyne! However, I'm not quite sure whether this is useful to me: I'm mainly concerned with links clicked in libreoffice not to open in chromium. However, I wasn't able to achieve this with mimeo. I also didn't get 'mimeo http://www.example.com' to open in another browser than chromium, also I run '--clear' '--purge' '--unprefer' chromium.desktop several times and '--prefer dwb.desktop' -> no avail. Only setting it in ~/.config/mimeo.conf as file-assoc helped.

But then, how do I make other programmes such as libreoffice use mimeo, i.e. how do I set mimeo to be the default handler for associations? Because libreoffice still opened links with chromium.

Only setting x-scheme-handler/http to dwb.desktop in xdg-mime proved successful, so I wonder whether xdg-utils have become better or whether I just wasn't using mimeo correctly?

Re: mimeo: open files by mimetype or file name

@jakobThe '--prefer' option requires a MIME-type matcher. See 'mimeo --mimeman-help' for the syntax. You need to tell it exactly which MIME-types to preferentially associate with dwb. You can also check the detected MIME-type of a file with 'mimeo -m <filepath>'.

The problem in your case is that a URL is not a file, so there is no MIME-type. This is exactly what the configuration file is for. If you want to open arbitrary strings and commands, you need to include them in that file. There are not hard-coded types in mimeo, so when you pass it a URL, all it sees is a string that it compares against patterns in the configuration file. If nothing matches then it checks for a file of the same name to get a MIME-type. If there is no file then it fails.

As for setting mimeo as the default opening in e.g. libreoffice, I have no idea as generally do not use it. Each application will have its own preference manager, e.g. my email client has been configured to use mimeo.

Maybe xdg-utils-mimeo would help. I have never used it myself so I do not know.

Re: mimeo: open files by mimetype or file name

Wow, that was a quick answer, thx alot for that! Due to procrastination reasons, I'll reply equally fast

Xyne wrote:

@jakobThe '--prefer' option requires a MIME-type matcher. See 'mimeo --mimeman-help' for the syntax. You need to tell it exactly which MIME-types to preferentially associate with dwb. You can also check the detected MIME-type of a file with 'mimeo -m <filepath>'.

The problem in your case is that a URL is not a file, so there is no MIME-type. This is exactly what the configuration file is for. If you want to open arbitrary strings and commands, you need to include them in that file. There are not hard-coded types in mimeo, so when you pass it a URL, all it sees is a string that it compares against patterns in the configuration file. If nothing matches then it checks for a file of the same name to get a MIME-type. If there is no file then it fails.

I see, that explains why I needed mimeo.conf. I was deceived by mimeo's readiness to output something to 'mimeo -d http://' and thought that I could use http:// as a proper MIME-type, so a clear misunderstanding on my part.

Xyne wrote:

As for setting mimeo as the default opening in e.g. libreoffice, I have no idea as generally do not use it. Each application will have its own preference manager, e.g. my email client has been configured to use mimeo.

Maybe xdg-utils-mimeo would help. I have never used it myself so I do not know.

Hm, I think it is easier then to stick to xdg-open, since it is more standard, upstream-maintained and additionally, xdg-utils-mimeo (according to AUR comments) doesn't seem to compile anymore.

Re: mimeo: open files by mimetype or file name

Hi Xyne, been using mimeo with xdg-utils-mimeo for a while now and just now running into a bit of a fix as I'm spending more time in ranger than nautilus.

Xournal files have extension .xoj but their mimetype is application/x-gzip. Any way to match xournal.desktop to files of extension xoj rather than all x-gzip files (which would of course include all my *.gz files which I don't want xournal to be default for)?

Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Re: mimeo: open files by mimetype or file name

Thanks! I refused to believe there wasn't documentation on this, so I read and reread mimeo -h and finally found mimeo --assoc-help

Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

EDIT2: 'normal' xdg-utils still works, so I'm not sure whether mimeo needs some form of an update.

Last edited by ngoonee (2013-02-13 02:20:59)

Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Re: mimeo: open files by mimetype or file name

Nope, no warning at all. Update works, thanks. Still getting the warning: environment variable "XDG_CONFIG_DIRS" is not set though.

Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Re: mimeo: open files by mimetype or file name

This one is fine, thanks

Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Re: mimeo: open files by mimetype or file name

/usr/bin/mplayer "$(youtube-dl -g %u)" works just fine on its own. It's only when run within mimeo that $(youtube-dl [..]) isn't executed (probably because the double quotes are replaced by single quotes).

Re: mimeo: open files by mimetype or file name

Ram-Z wrote:

/usr/bin/mplayer "$(youtube-dl -g %u)" works just fine on its own. It's only when run within mimeo that $(youtube-dl [..]) isn't executed (probably because the double quotes are replaced by single quotes).

I forgot shlex.split doesn't like single quotes. Here is the proper command