You are not logged in.

#176 2016-12-30 02:41:07

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,380
Website

Re: mimeo: open files by mimetype or file name

Sorry for the delayed response.

Without an example, I do not know what you were trying to do (e.g. clear all associations for a MIME-type, all associations for a desktop file or a combination of MIME-types and a desktop file). Looking at the code I found 2 bugs that prevented clearing all associations for a given MIME-type. Those have been fixed and the following now works: "mimeo --clear foo/bar".

The default behavior for clearing a desktop's associations may be counter-intuitive: "mimeo --clear foo.desktop" will remove "foo.desktop" from all MIME-types listed in the desktop file. To completely clear "foo.desktop", use "mimeo --clear 'glob:*' foo.desktop". I have updated the help message to make this clearer. I hesitated to make this behavior the default with this update but the current behavior is coherent with the other operations and keeps the common function simple.

If neither the bug fix nor the usage clarification address your issue, please post a specific example with relevant entries from the mimeapps.list file.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#177 2017-01-27 23:46:38

Alad
Wiki Admin/IRC Op/TU
From: Bagelstan
Registered: 2014-05-04
Posts: 1,874
Website

Re: mimeo: open files by mimetype or file name

I'm having an issue when a document has a subtype of a particular mime type, i.e. image/vnd.djvu+multipage instead of image/vnd.djvu:

[archie@thinkpad ~]$ mimeo --show-all KnuthII.djvu
WARNING: failed to determine command precursor for KnuthII.djvu
WARNING: failed to determine command(s) for KnuthII.djvu
[archie@thinkpad ~]$ mimeo -m KnuthII.djvu
KnuthII.djvu
  image/vnd.djvu+multipage
[archie@thinkpad ~]$ file --mime-type KnuthII.djvu
KnuthII.djvu: image/vnd.djvu

cf. this qpdfview bug where the author decided to match all subtypes:

https://bugs.launchpad.net/qpdfview/+bug/1515018

Not sure if a given desktop file should contain subtypes of a given MIME type, or if the opener should simply count those as part of the main mime type. Also the guy who broke it:

https://mail.gnome.org/archives/commits … 07514.html


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Grand reopening: December 1st 2018)

Offline

#178 2017-01-29 12:13:46

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,380
Website

Re: mimeo: open files by mimetype or file name

I was unaware that MIME-types may consist of the following:

Wikipedia wrote:
top-level type name / subtype name [ ; parameters ]
top-level type name / [ tree. ] subtype name [ +suffix ] [ ; parameters ]

When I have the time, I will add a full MIME-type parser to handle the different components and default to using the main type if no association exists for the subtype. In the meantime, just add associations for each fully qualified type.

I may also add an option to create associations directly from a path argument.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#179 2017-01-29 14:45:45

Alad
Wiki Admin/IRC Op/TU
From: Bagelstan
Registered: 2014-05-04
Posts: 1,874
Website

Re: mimeo: open files by mimetype or file name

Nice, looking forward to the change. big_smile


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Grand reopening: December 1st 2018)

Offline

#180 2017-02-09 23:51:55

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,380
Website

Re: mimeo: open files by mimetype or file name

Both changes have been implemented. If testing for filepath arguments leads to conflicts then I will revert to the previous behavior and add an option to enable this new behavior.

Usage example:

mimeo --prefer /path/to/some/movie.mkv vlc.desktop

Qualified MIME-types (e.g. foo/bar+wuz) will default to unqualified associations (e.g. foo/bar) if no qualified associations are found.

Let me know if you find a bug.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#181 2017-11-01 22:48:00

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,901
Website

Re: mimeo: open files by mimetype or file name

Hmm, mimeo does not use ~/.config/mimeo.conf for me, I have to specify it with the -a option.

Even when I try to run it with

XDG_CONFIG_HOME="$HOME/.config" mimeo foobar

it does not use the config.


**EDIT** (Reading is hard)

--filepath-help showed me the way...

 custom associations, in order:
   /home/carnager/.config/mimeo/associations.txt
   /etc/xdg/mimeo/associations.txt

Last edited by Rasi (2017-11-01 23:31:36)


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#182 2018-09-17 23:42:49

Sathors
Member
Registered: 2011-02-23
Posts: 49

Re: mimeo: open files by mimetype or file name

Maybe a dumb question, but is there any way to open terminal applications (like vim) using mimeo, but in the same shell instead of opening another window?

Currently I have my default arguments set to "--term 'urxvtc -e %s'", but it creates another window with urxvt.

Offline

#183 2018-10-16 14:46:20

arnaudv6
Member
Registered: 2016-02-25
Posts: 51

Re: mimeo: open files by mimetype or file name

Sathors, could you describe a bit more what steps you are following?

Offline

#184 2018-10-31 20:04:44

Sathors
Member
Registered: 2011-02-23
Posts: 49

Re: mimeo: open files by mimetype or file name

For example, I have text/plain associated to neovim.

With my default arguments ("--term 'urxvtc -e %s'") set in .config/mimeo/default_arguments.txt, when I issue a

mimeo my_file.txt

, it opens another instance of urxvt and opens neovim there. I would like for mimeo to open neovim in the same shell, then once I quit the neovim process, get the prompt back.

I have tried many different things and I was not able to get it to work.

This problem is independant of neovim itself, I only want to open --term commands in the same shell.

Offline

#185 2018-11-04 03:16:52

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,380
Website

Re: mimeo: open files by mimetype or file name

@Sathors
The "--term" option determines how terminal applications are opened. If you set it to "urxvtc -e %s",then every time mimeo detects that a file should be opened with vim in the terminal, it will run "urxvtc -e vim ..." and launch a new urxvt window. Just omit that option to have to run vim directly in the same terminal (and return to it when vim exits).

Note that by removing that option, any non-terminal application that launches a terminal application via mimeo will not show it to the user (and will probably freeze waiting for the command to finish). I suggest leaving your current default arguments and creating a separate alias for working in a terminal.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#186 2018-11-05 16:08:28

Sathors
Member
Registered: 2011-02-23
Posts: 49

Re: mimeo: open files by mimetype or file name

@Xyne

I have removed everything from my default_arguments.

But now when I run

mimeo my_file.txt

, it does open neovim in the current shell, but hitting any key gets me back to the prompt. It seems that mimeo is not waiting for neovim to quit. The key I hit while seeing nvim interface is actually written on the prompt. The neovim session gets killed when hitting the key.

Any idea?

Offline

#187 2018-11-18 00:02:53

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,380
Website

Re: mimeo: open files by mimetype or file name

Sathors wrote:

@Xyne
Any idea?


Nope. Does the same happen with regular vim?


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#188 2018-11-19 15:33:12

Sathors
Member
Registered: 2011-02-23
Posts: 49

Re: mimeo: open files by mimetype or file name

Well at least by using vim, I am beginning to see a real error.

+ ~$ mimeo --command work/gtd/retrospectives.md
vim work/gtd/retrospectives.md
+ ~$ mimeo work/gtd/retrospectives.md  
Vim: Error reading input, exiting...              
                                      
Vim: Finished.
+ ~$ vim work/gtd/retrospectives.md 

So mimeo explicitly states that it will run `vim work/gtd/retrospectives.md`. When I run mimeo (with vim instead of nvim), I get exactly the same behavior (vim terminates on first keyboard input), but at least the error gets echoed explicitly in the terminal. When I run the command myself, everything works as expected.

Just to be sure I disabled my .vimrc and my .vim directory.

Could it be something with the TERM variable that mimeo sets or something along those lines?

Last edited by Sathors (2018-11-19 15:34:40)

Offline

#189 2018-11-22 08:11:49

Kampfpudding
Member
Registered: 2018-04-29
Posts: 6

Re: mimeo: open files by mimetype or file name

Hey Xyne,

although you said that the problem with 'file://' paths has been fixed I still seem to have problems
with it. I didn't find anything in this thread (or anywhere else for that matter) that could resole
my issue. I hope I haven't overlooked something.

Qutebrowser denied to open files instead of saving them so I tried opening those with xdg-open which
resulted in

WARNING: failed to determine command precursor for file://

I dug through Mime.py a little and thought I could do a very dirty fix. Just to get it running for
now. I think the culprit might be line 1642 which evaluates to false (since I don't have any custom
mimeo associations).

So I know that I can add associations for specific protocols such as 'http://'. This should work
fine for 'file://' just as well but the problem is that I still would need to differentiate between
PDFs, PNGs, HTMLs etc.

Is there any way of making this work again? I would like to keep this as flexibel as possible
so that I don't have to specify 'file:// {filetype}' for everything I want to open from qutebrowser.

For the record: xdg-open from the xdg-utils package works fine. I would still prefer mimeo though. It's just a little more intuitive.

Thanks so much
Lukas

Last edited by Kampfpudding (2018-11-22 09:06:43)

Offline

#190 2018-11-25 00:53:55

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 6,380
Website

Re: mimeo: open files by mimetype or file name

@Sathors
I have updated Mimeo to handle terminal commands without a user-provided terminal option. To prevent hanging programs that use mimeo internally, it will check that both stdin and stdout are interactive and exit with an error if not.

@Kampfpudding
Can you provide an example? The error message that you posted indicates that something is passing the argument "file://" without any path to mimeo, which is the only way that I can reproduce the error. Opening file URIs works if they are valid:

> mimeo -c file:///tmp/test.txt file:///tmp/foo.htm
vim /tmp/test.txt
qutebrowser file:///tmp/foo.htm

Paths are extracted from file URIs and handled the same way as regular path arguments, which included MIME-type detection, so no additional configuration is required. The above example was run without a custom associations file.

I suspect there is an error in your qutebrowser and/or xdg-open configuration.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#191 2018-11-26 00:45:56

Sathors
Member
Registered: 2011-02-23
Posts: 49

Re: mimeo: open files by mimetype or file name

@Xyne
Thank you, it is now working perfectly!

Offline

#192 2018-11-26 09:57:55

Kampfpudding
Member
Registered: 2018-04-29
Posts: 6

Re: mimeo: open files by mimetype or file name

Sure:

mimeo -c file:///tmp/qutebrowser-downloads-zjd8ds9u/tmp2j_uj0zm_Checkliste-Barrierefreies-PDF.pdf

This PDF has been downloaded with qutebrowser. I chose "Open" instead of "Store", that's why it was put into /tmp.

Running this command I get

WARNING: failed to determine command precursor for file:///tmp/qutebrowser-downloads-zjd8ds9u/tmp2j_uj0zm_Checkliste-Barrierefreies-PDF.pdf

Since it seems to work for everybody else I'd assume it's a problem on my end. I'll try to dig a bit deeper. Debugging my system should really not be your responsibility smile

Offline

Board footer

Powered by FluxBB