Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open-actions mime inconsistent #3056

Closed
SolitudeSF opened this issue Oct 24, 2020 · 16 comments
Closed

open-actions mime inconsistent #3056

SolitudeSF opened this issue Oct 24, 2020 · 16 comments
Labels

Comments

@SolitudeSF
Copy link
Contributor

Describe the bug
Files with matching mime type dont invoke configured action.

To Reproduce
add

# Open text files without fragments in the editor
protocol file
mime text/*
action launch --type=overlay ${EDITOR} ${FILE_PATH}

to open-actions.conf

Certain text files (c source, html) open in overlay, other (markdown) - with default handler.

Environment details
OS: linux 5.9

kitty --debug-config ``` kitty 0.19.1 created by Kovid Goyal Linux soryegeton 5.9.1-zen2-1-zen #1 ZEN SMP PREEMPT Sun, 18 Oct 2020 02:45:20 +0000 x86_64 Void \r (\n) (\l) Loaded config files: /home/solitude/.local/etc/kitty/kitty.conf Running under: X11

Config options different from defaults:
active_border_color Color(red=48, green=48, blue=47)
adjust_line_height -1
allow_remote_control y
background Color(red=28, green=27, blue=25)
bold_font Iosevka Fixed SS04 Heavy
bold_italic_font Iosevka Fixed SS04 Heavy Italic
click_interval 0.5
clipboard_control frozenset({'write-clipboard', 'read-primary', 'write-primary', 'read-clipboard'})
color0 Color(red=28, green=27, blue=25)
color1 Color(red=239, green=47, blue=39)
color10 Color(red=152, green=188, blue=55)
color11 Color(red=254, green=208, blue=110)
color12 Color(red=104, green=168, blue=228)
color13 Color(red=255, green=92, blue=143)
color14 Color(red=83, green=253, blue=233)
color15 Color(red=252, green=232, blue=195)
color2 Color(red=81, green=159, blue=80)
color3 Color(red=251, green=184, blue=41)
color4 Color(red=44, green=120, blue=191)
color5 Color(red=224, green=44, blue=109)
color6 Color(red=10, green=174, blue=179)
color7 Color(red=145, green=129, blue=117)
color8 Color(red=45, green=44, blue=41)
color9 Color(red=247, green=83, blue=65)
cursor Color(red=252, green=232, blue=195)
cursor_blink_interval 0.5
cursor_shape 2
editor kak
env {'PAGER': 'kakpager', 'MANPAGER': 'less', 'LESSHISTFILE': '-'}
focus_follows_mouse True
font_family Iosevka Fixed SS04 Medium
font_size 12.0
foreground Color(red=252, green=232, blue=195)
inactive_border_color Color(red=48, green=48, blue=47)
italic_font Iosevka Fixed SS04 Medium Italic
mouse_hide_wait 0.0
remember_window_size False
repaint_delay 15
resize_draw_strategy 3
scrollback_pager ['kak', '-e', 'rmhl global/number-lines;rmhl global/wrap;exec INPUT_LINE_NUMBERg']
scrollback_pager_history_size 10485760
select_by_word_characters :@-./_~?&=%+#
selection_background Color(red=252, green=232, blue=195)
selection_foreground Color(red=28, green=27, blue=25)
shell elvish
strip_trailing_spaces always
symbol_map {(9211, 9214): '3270Medium Nerd Font Mono', (11096, 11096): '3270Medium Nerd Font Mono',(57856, 58025): '3270Medium Nerd Font Mono', (57504, 57507): '3270Medium Nerd Font Mono', (57520, 57535): '3270Medium Nerd Font Mono', (57536, 57544): '3270Medium Nerd Font Mono', (57548, 57551): '3270Medium Nerd Font Mono', (57552, 57554): '3270Medium Nerd Font Mono', (57556, 57556): '3270Medium Nerd Font Mono', (59136, 59333): '3270Medium Nerd Font Mono', (61440, 62176): '3270Medium Nerd Font Mono', (9829, 9829): '3270Medium Nerd Font Mono', (9889, 9889): '3270Medium Nerd Font Mono', (62464, 62632): '3270Medium Nerd Font Mono', (63100, 63100): '3270Medium Nerd Font Mono', (57344, 57354): '3270Medium Nerd Font Mono', (62208, 62227): '3270Medium Nerd Font Mono', (58874, 58923): '3270Medium Nerd Font Mono'}
tab_bar_style separator
tab_fade (0.15, 0.3, 0.45, 0.8)
url_style 2
window_border_width (1.0, 'pt')
Added shortcuts:
f1 KeyAction(func='create_marker', args=())
shift+f1 KeyAction(func='remove_marker', args=())
shift+control+g KeyAction(func='launch', args=['--type=overlay', '--cwd=current', 'tig'])
shift+control+f1 KeyAction(func='launch', args=['--type=overlay', '--stdin-source=@alternate_scrollback', '--stdin-add-formatting', 'kakpager'])
shift+control+f9 KeyAction(func='clear_terminal', args=['reset', True])
control+alt+enter KeyAction(func='launch', args=['--type=os-window', '--cwd=current'])
shift+control+alt+minus KeyAction(func='change_font_size', args=(False, '-', 2.0))
shift+control+alt+equal KeyAction(func='change_font_size', args=(False, '+', 2.0))
shift+control+alt+backspace KeyAction(func='change_font_size', args=(False, None, 0.0))
Changed shortcuts:
shift+control+n KeyAction(func='scroll_to_mark', args=[False, 0])
shift+control+p > f KeyAction(func='kitten', args=['hints', '--type=path --program=-'])
shift+control+p > l KeyAction(func='kitten', args=['hints', '--type=line --program=-'])
shift+control+p > n KeyAction(func='kitten', args=['hints', "--type=linenum --linenum-action=tab kak -e 'exec{line}g' {path}"])
shift+control+p > w KeyAction(func='kitten', args=['hints', '--type=word --program=-'])
shift+control+p > shift+f KeyAction(func='kitten', args=['hints', '--type=path'])
shift+control+u KeyAction(func='input_unicode_character', args=())
shift+control+escape KeyAction(func='kitty_shell', args=['overlay'])
shift+control+f10 KeyAction(func='clear_terminal', args=['clear', True])
shift+control+f11 KeyAction(func='clear_terminal', args=['scrollback', True])

</details>
@SolitudeSF SolitudeSF added the bug label Oct 24, 2020
@kovidgoyal
Copy link
Owner

What does:

python -c "import mimetypes; print(mimetypes.guess_type('a.md'))"

output

@SolitudeSF
Copy link
Contributor Author

(None, None)

@kovidgoyal
Copy link
Owner

You need to add an entry for md files to /etc/mime.types (or whatever your distro uses). It should be

python -c "import mimetypes; print(mimetypes.guess_type('a.md'))"
('text/markdown', None)

@SolitudeSF
Copy link
Contributor Author

thats unfortunate, file at least recognizes it as text/plain

@SolitudeSF
Copy link
Contributor Author

SolitudeSF commented Oct 25, 2020

thats pretty limiting, requires to edit pretty limited root owned file. other programs use whatever mechanism is responsible for ~/.local/share/mime/. at least you can edit it as user.

looks like PyXDG is used for properer mime handling. at least on linux, dont know what is used on macos.

@kovidgoyal
Copy link
Owner

You'd have to complain to python's stdlib developers. Or use the ext key
to match of file extensions to supplement whatever mime entries are
missing in your system mimetypes.

@SolitudeSF
Copy link
Contributor Author

that would mean i have to add extension of every file i ever need to open. id rather patch kitty myself in that case.

@kovidgoyal
Copy link
Owner

patch it to do what? If you dont have a definition for markdown files on
your system, how is kitty supposed to magically learn of it?

@SolitudeSF
Copy link
Contributor Author

SolitudeSF commented Oct 25, 2020

i do have, not in /etc/mime.types tho. https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html
thats what pyxdg queries, with fallback to identification by contents

@kovidgoyal
Copy link
Owner

yeah sorry, I am not parsing XML files just to read mime information,
talk about insanity. I will however, allow you to provide your own
definition via a mime.types file in the kitty config directory.

@SolitudeSF
Copy link
Contributor Author

SolitudeSF commented Oct 25, 2020

but you dont parse, some xdg piece is doing the parsing and caches the information.
i mean, its doesnt parse xml every time you need to query the mime.

kovidgoyal added a commit that referenced this issue Oct 25, 2020
…e missing from the system MIME database

Also allow the user to specify their own database via mime.types in the
kitty config directory. See #3056
@kovidgoyal
Copy link
Owner

caches the information where and how does one get at it? As far as I
know, xdg (which is a truly horrific pile of very badly written shell
scripts) only allows you to use the information via xdg-open, which is
useless for kitty.

@SolitudeSF
Copy link
Contributor Author

im not an expert on xdg garbage. i just know that without it everything is even worse.
https://pyxdg.readthedocs.io/en/latest/mime.html#xdg.Mime.get_type2

@SolitudeSF
Copy link
Contributor Author

SolitudeSF commented Oct 25, 2020

As far as I know, xdg (which is a truly horrific pile of very badly written shell scripts) only allows you to use the information via xdg-open, which is useless for kitty.

thats not true. there are multiple tools not tied to xdg-utils that query that information, at least gnome's gio.

@kovidgoyal
Copy link
Owner

That's nice, but I am not adding a dependency to do this. You are most
welcome to submit a patch to do whatever pyxdg does to read that
information, without any external deps. Relevant code goes into
guess_mime_type.py or simply add the mime-types you care about in
~/.config/kitty/mime.types

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 25, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants