~sircmpwn/aerc

1

Image filter with ueberzug

Axel Dahlberg
Details
Message ID
<C9JJMIE4WXBQ.1D3S77FWZFVI@l390>
DKIM signature
pass
Download raw message
Has anyone setup filter to pipe image/* to something using ueberzug? I
started making something but struggeling a bit with making the image
dissappear correctly and to use correct size.
Details
Message ID
<C9VFCBPPTW4Q.2FPPTYL19PGEQ@calvin-pc-arch>
In-Reply-To
<C9JJMIE4WXBQ.1D3S77FWZFVI@l390> (view parent)
DKIM signature
pass
Download raw message
On Fri Feb 26, 2021 at 2:49 PM GMT, Axel Dahlberg wrote:
> Has anyone setup filter to pipe image/* to something using ueberzug? I
> started making something but struggeling a bit with making the image
> dissappear correctly and to use correct size.

I'm, also hacking something together and encountering a similar issue.
e.g. this is the gist of my filter I've hacked together:

        rows, columns = shutil.get_terminal_size(fallback=(80,80))
        with ueberzug.Canvas() as c:
            aerc_img = c.create_placement(
                'aerc', x=0, y=7, width=columns, height=rows/2, scaler=ueberzug.ScalerOption.COVER.value)
            aerc_img.path = filename
            aerc_img.visibility = ueberzug.Visibility.VISIBLE
            wait_for_input()

It works, but always uses the fallback size instead of detecting the
proper terminal size. Even if it worked it would be a bit of a hack as
you'd have to use hard-coded values in the positioning and the sizing to
account for the header and footer message UI. 

Some other issues I faced:

Getting keypress detection working was a pain as we don't seem to just
be able to read stdin. But the pynput package did the trick.

Because aerc caches the output and ueberzug uses child windows,
re-selecting an image attachment without closing the message first will
just result in a blank screen.

I don't think this could go much further unless filters were provided
with additional metadata and events perhaps. 

On the plus side - it's good enough for me right now :)
Reply to thread Export thread (mbox)