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

'm' keypress image viewer crashes and/or doesn't detect available/suitable image viewers #392

Open
draeath opened this issue Aug 1, 2023 · 4 comments

Comments

@draeath
Copy link

draeath commented Aug 1, 2023

A picture is worth a thousand words, so here's what it looks like. I can't really tell if this is a problem with my environment (ImageMagick has really stupid binary names) or toot itself.

what

To replicate:

  1. Launch toot tui
  2. hit g and select "Global public timeline."
  3. Scroll to any post that contains an media attachment URL
  4. Press m

My brain skipped a few steps, for some reason I expected this to pop up the 'mute' that we see when we first press a to see the poster's account information.

I have absolutely no idea why IMageMagick is popping up, and this key is not documented in the TUI's help screen or in the status bar. Also note the error in the status bar:

display: attempt to perform an operation not allowed by the security policy `HTTPS' @ error/constitute.c/IsCoderAuthorized/454.


Some environmental details:

  • OpenSUSE tumbleweed (snapshot 20230730-0)
  • toot v0.38.1 installed via pip, within a python 3.11 venv
  • toot is running inside konsole via an X.org session

package ImageMagick-7.1.1.12-1.1.x86_64 installed, which provides these binaries in my path:

  • /usr/bin/animate
  • /usr/bin/compare
  • /usr/bin/composite
  • /usr/bin/conjure
  • /usr/bin/convert
  • /usr/bin/display
  • /usr/bin/identify
  • /usr/bin/import
  • /usr/bin/magick
  • /usr/bin/magick-script
  • /usr/bin/mogrify
  • /usr/bin/montage
  • /usr/bin/stream
@draeath
Copy link
Author

draeath commented Aug 1, 2023

I removed ImageMagick and retried, and I receive a fun traceback that exposes what this is (trying to) accomplish. It looks like it's trying to open an image viewer.

I don't know how/why it tries to use ImageMagick for this - that seems like the wrong tool. Additionally, it throws a traceback and kills toot, instead of handling the condition better.

Additionally, it doesn't seem to be aware of KDE's image viewer(s)?

Traceback (most recent call last):
File "/home/draeath/.venvs/default/bin/toot", line 8, in <module>
    sys.exit(main())
            ^^^^^^
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/toot/console.py", line 961, in main
    run_command(app, user, command_name, args)
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/toot/console.py", line 943, in run_command
    return fn(app, user, parsed_args)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/toot/commands.py", line 571, in tui
    TUI.create(app, user, args).run()
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/toot/tui/app.py", line 149, in run
    self.loop.run()
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/urwid/main_loop.py", line 287, in run
    self._run()
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/urwid/main_loop.py", line 385, in _run
    self.event_loop.run()
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/urwid/main_loop.py", line 1494, in run
    reraise(*exc_info)
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/urwid/compat.py", line 58, in reraise
    raise value
File "/usr/lib64/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/urwid/raw_display.py", line 416, in <lambda>
    wrapper = lambda: self.parse_input(
                    ^^^^^^^^^^^^^^^^^
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/urwid/raw_display.py", line 515, in parse_input
    callback(processed, processed_codes)
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/urwid/main_loop.py", line 412, in _update
    self.process_input(keys)
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/urwid/main_loop.py", line 513, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/urwid/container.py", line 1135, in keypress
    return self.body.keypress( (maxcol, remaining), key )
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/toot/tui/timeline.py", line 196, in keypress
    self.tui.show_media(status)
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/toot/tui/app.py", line 518, in show_media
    show_media(urls)
File "/home/draeath/.venvs/general/lib64/python3.11/site-packages/toot/tui/utils.py", line 73, in show_media
    raise Exception("Cannot find an image viewer")
Exception: Cannot find an image viewer

@draeath draeath changed the title 'm' keypress on timeline with media attachment pops up ImageMagick logo 'm' keypress image viewer crashes and/or doesn't detect available/suitable image viewers Aug 1, 2023
@draeath
Copy link
Author

draeath commented Aug 1, 2023

Putting the viewer detection itself aside, this exception should probably be handled with a status line message instead of being unhandled.

The docstring here seems quite on-point :D

I might suggest disabling this until it's cleaned up or refined? Or again, at least handling the exception better.

@draeath
Copy link
Author

draeath commented Aug 1, 2023

I suggest:

  1. remove or deprioritize display from the list, since ImageMagick seems it doesn't understand what to do with a URL
  2. add gwenview to cover KDE users, it fills the same niche as eog does for Gnome. If given a URL as an argument, it does the correct thing and displays the image correctly. (tested with gwenview 23.04.3)

@draeath
Copy link
Author

draeath commented Aug 1, 2023

Looks like display is at the end of the list.

Submitted PR #393 to add gwenview between it and eog

It might be worth adding a few popular web browsers to that list as well, below the dedicated image viewers. Firefox tests fine being used this way, though ideally one could add additional arguments and the current method of testing for them would break if you just added it to the string. That sort of thing would probably be best left to after a means to configure a custom viewer.

Edit: actually I bet it's a good idea to just use xdg-open or similar and let the user's environment elect the viewer to launch...

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

No branches or pull requests

1 participant