~rjarry/aerc-discuss

27 8

displaying images within aerc

Details
Message ID
<CM956SJEQATX.1077SDYWS2HLV@mashenka>
DKIM signature
missing
Download raw message
Hi,

I was looking at filters and I tried the example for the images. I found
that although it sounds great, the resolution is so bad that it's
useless (I often send around plots where this resolution makes it
impossible to decide what's going on).

Since I'm on kitty, I tried filtering to the icat kitten. I managed to get
the following outputs:

- success, but then the image is forever stuck to the part of the
  terminal where it first appeared
- absolutely random things start to print on the terminal, the image is
  then opened in the system viewer, the aerc terminal is absolutely
  broken

I was not able to consistently reproduce either results, so may be
dependent on the specific image.

I tried also not specifying a filter, but piping from aerc, where I got
the following error:
Terminal does not support reporting screen sizes via the TIOCGWINSZ ioctl

Does anybody have a working solution, to show an image in proper
resolution within the aerc terminal (I'm not tied to kitty in this
matter, as long as I can get it to run under Ubuntu)? Or does anybody
have an idea how to make this work or where to start looking?

icat: https://sw.kovidgoyal.net/kitty/kittens/icat/

Thanks,
Bence

p.s.: Thanks for all the help I already got, you're great :)

--
+36305425054
bence.ferdinandy.com
Rene Schallner <rene@renerocks.ai>
Details
Message ID
<CM95K4ZR4OGR.1LEPBSF5K9HDT@ryzen>
In-Reply-To
<CM956SJEQATX.1077SDYWS2HLV@mashenka> (view parent)
DKIM signature
missing
Download raw message
On Thu Aug 18, 2022 at 2:10 PM CEST, Bence Ferdinandy wrote:
> Since I'm on kitty, I tried filtering to the icat kitten. 

...

> - success, but then the image is forever stuck to the part of the
> terminal where it first appeared
> - absolutely random things start to print on the terminal, the image is
> then opened in the system viewer, the aerc terminal is absolutely
> broken

> I was not able to consistently reproduce either results, so may be
> dependent on the specific image.

Or maybe dependent on what aerc does to the terminal / TTY. If both
aerc and icat think they're in control of the tty, weird things are
bound to happen.

> I tried also not specifying a filter, but piping from aerc, where I got
> the following error:
> Terminal does not support reporting screen sizes via the TIOCGWINSZ
> ioctl

I haven't tried any of the above but looked at the website of icat. You
might want to check out icat's command line options. 

Especially this paragraph sounds relevant (from [1]):

| If you are trying to integrate icat into a complex program like a file
| manager or editor, there are a few things to keep in mind. icat works by
| communicating over the TTY device, it both writes to and reads from the
| TTY. So it is imperative that while it is running the host program does
| not do any TTY I/O. Any key presses or other input from the user on the
| TTY device will be discarded. At a minimum, you should use the --silent
| and --transfer-mode command line arguments. To be really robust you
| should consider writing proper support for the kitty graphics protocol
| in the program instead. Nowadays there are many libraries that have
| support for it.

Hope this helps. Maybe one day I'll look into displaying imgs in the
terminal, too. So far, I haven't had a pressing need for it.

Up until now, the most similar usecase was piping HTML parts (with embedded
images) to vib [2]. But if you wanted sth like that, you'd easily be
able to pipe images to feh [3].

[1] : https://sw.kovidgoyal.net/kitty/kittens/icat/
[2] : https://sr.ht/~renerocksai/vib 
[3] : https://feh.finalrewind.org/
Details
Message ID
<CM95PABLAOFS.3AI6BYIVSDMSM@marty>
In-Reply-To
<CM956SJEQATX.1077SDYWS2HLV@mashenka> (view parent)
DKIM signature
missing
Download raw message
Did you try catimg?

https://man.archlinux.org/man/community/catimg/catimg.1.en

[filters]
image/*=catimg -
Details
Message ID
<CM95WT4PX43C.1XZM0A9VQ7N0F@marty>
In-Reply-To
<CM95PABLAOFS.3AI6BYIVSDMSM@marty> (view parent)
DKIM signature
missing
Download raw message
Robin Jarry, Aug 18, 2022 at 14:34:
> [filters]
> image/*=catimg -

My bad, this is piped to pager, it needs an extra argument to work:

[filters]
image/*=catimg -w$(tput cols) -
Details
Message ID
<CM9FSLQNTY8A.3TZTVEQNI8I2@mashenka>
In-Reply-To
<CM95K4ZR4OGR.1LEPBSF5K9HDT@ryzen> (view parent)
DKIM signature
missing
Download raw message
On Thu Aug 18, 2022 at 2:27 PM CEST, Rene Schallner wrote:
> Or maybe dependent on what aerc does to the terminal / TTY. If both
> aerc and icat think they're in control of the tty, weird things are
> bound to happen.

quite likely I guess

>
> I haven't tried any of the above but looked at the website of icat. You
> might want to check out icat's command line options.
>
> Especially this paragraph sounds relevant (from [1]):
>
> | If you are trying to integrate icat into a complex program like a file
> | manager or editor, there are a few things to keep in mind. icat works by
> | communicating over the TTY device, it both writes to and reads from the
> | TTY. So it is imperative that while it is running the host program does
> | not do any TTY I/O. Any key presses or other input from the user on the
> | TTY device will be discarded. At a minimum, you should use the --silent
> | and --transfer-mode command line arguments. To be really robust you
> | should consider writing proper support for the kitty graphics protocol
> | in the program instead. Nowadays there are many libraries that have
> | support for it.

I didn't realize the _imperative_ part was how important until you
called my attention to why everything gets mangled :D

I now have a solution, which works:
in [filters]:
    image/*=kitty +kitten icat --silent --transfer-mode stream

This now reliable outputs the image, but unless you do something with it
it gets stuck there forever (well, until you close aerc). The solution
to this is to call 
    :exec kitty +kitten icat --silent --clear
while still in the pager, after you exit the pager back to the inbox
screen all seems to be lost and the picture is there forever.

Since this must not be forgotten: is it possible to have a specific
binding for the context of being in the pager on image/* mimetype? I'd
rebind q to first call the above exec and then exit the pager.

> Up until now, the most similar usecase was piping HTML parts (with embedded
> images) to vib [2]. But if you wanted sth like that, you'd easily be
> able to pipe images to feh [3].
>
> [1] : https://sw.kovidgoyal.net/kitty/kittens/icat/
> [2] : https://sr.ht/~renerocksai/vib
> [3] : https://feh.finalrewind.org/

Two question unrelated to the topic:
1)What's the benefit of vib over just going O and opening the html in
  a browser?
2)I've noticed that many of you use this footnote style links and
  I guessing it's not done manually: what do you use for that?

Thanks,
Bence


--
+36305425054
bence.ferdinandy.com
Details
Message ID
<CM9GHJB6F22B.YYDJ7FKE2G2E@mashenka>
In-Reply-To
<CM95WT4PX43C.1XZM0A9VQ7N0F@marty> (view parent)
DKIM signature
missing
Download raw message
On Thu Aug 18, 2022 at 2:44 PM CEST, Robin Jarry wrote:
> Robin Jarry, Aug 18, 2022 at 14:34:
> My bad, this is piped to pager, it needs an extra argument to work:
>
> [filters]
> image/*=catimg -w$(tput cols) -

This is what is actually in the example configuration for aerc, so
I started with this, but the output is very pixelated, to the point of
being not useful for me mostly. I think it's kind of okay, to figure out
if out of the 5 images attached to the email, which 1 is the actual
thing and what is 3 banners and a company logo, but you'd definitely
need to actually open that one image in something else, that's why I'm
trying to get kitty to do the job (and it seems it can be).

Thanks,
Bence


--
+36305425054
bence.ferdinandy.com
Rene Schallner <rene@renerocks.ai>
Details
Message ID
<CM9GZLV5IMEZ.231IXDOFD7P1G@ryzen>
In-Reply-To
<CM9FSLQNTY8A.3TZTVEQNI8I2@mashenka> (view parent)
DKIM signature
missing
Download raw message
On Thu Aug 18, 2022 at 10:28 PM CEST, Bence Ferdinandy wrote:

> I now have a solution, which works:
> in [filters]:
> image/*=kitty +kitten icat --silent --transfer-mode stream
>
> This now reliable outputs the image, but unless you do something with it
> it gets stuck there forever (well, until you close aerc). The solution
> to this is to call
> :exec kitty +kitten icat --silent --clear
> while still in the pager, after you exit the pager back to the inbox
> screen all seems to be lost and the picture is there forever.
>
> Since this must not be forgotten: is it possible to have a specific
> binding for the context of being in the pager on image/* mimetype? I'd
> rebind q to first call the above exec and then exit the pager.

As a workaround, I'd try to wrap both kitty calls in a shell script and
use that as a filter. After displaying the img, wait for a (certain?
unbound?) keypress, then execute the --clear thing. 

> > [3] : https://feh.finalrewind.org/
>
> Two question unrelated to the topic:
> 1)What's the benefit of vib over just going O and opening the html in
> a browser?

🤦 I had never tried that 🤣! Well, I still like it because I can
specify a certain browser, e.g. qutebrowser, just for aerc-stuff. The
--cleanup option is handy - and if you happen to view in browser a lot,
the --output option lets you leave the same single browser window / tab
open and pipe email after email into (no new windows, tabs) it, by
piping into the same output file. Having a constant output file name
enables you to set a bookmark to aerc output in the browser. (if you use
--output).

Well, it was a nice zig exercise, but to be honest, using O on HTML
parts gives you 90% or more of what vib can do - so, in a way, vib only
exists because I am stupid 😊.

> 2)I've noticed that many of you use this footnote style links and
> I guessing it's not done manually: what do you use for that?

You guessed wrong - in my case. I don't mind typing [n] and [n]:. I used
to just paste links on new lines, preceded and followed by empty lines,
which kind of broke the text flow unnecessarily. I found out that
footnote style works much better in e-mails most of the time, for my
taste.
Details
Message ID
<CM9H3IVRYS6C.1E2G0VOLAB6P1@grinningface>
In-Reply-To
<CM9GHJB6F22B.YYDJ7FKE2G2E@mashenka> (view parent)
DKIM signature
missing
Download raw message
On Thu Aug 18, 2022 at 5:01 PM EDT, Bence Ferdinandy wrote:
> On Thu Aug 18, 2022 at 2:44 PM CEST, Robin Jarry wrote:
> > Robin Jarry, Aug 18, 2022 at 14:34:
> > My bad, this is piped to pager, it needs an extra argument to work:
> >
> > [filters]
> > image/*=catimg -w$(tput cols) -
>
> This is what is actually in the example configuration for aerc, so
> I started with this, but the output is very pixelated, to the point of
> being not useful for me mostly. I think it's kind of okay, to figure out
> if out of the 5 images attached to the email, which 1 is the actual
> thing and what is 3 banners and a company logo, but you'd definitely
> need to actually open that one image in something else, that's why I'm
> trying to get kitty to do the job (and it seems it can be).

It’s also worth noting that catimg does not appear pixelated when using
a terminal emulator that supports sixel graphics.

Cheers,
-- 
DJ Chase
They, Them, Theirs
Rene Schallner <rene@renerocks.ai>
Details
Message ID
<CM9HDFNUWYOX.2QJIXYFTNXSXR@ryzen>
In-Reply-To
<CM956SJEQATX.1077SDYWS2HLV@mashenka> (view parent)
DKIM signature
missing
Download raw message
On Thu Aug 18, 2022 at 2:10 PM CEST, Bence Ferdinandy wrote:

> icat: https://sw.kovidgoyal.net/kitty/kittens/icat/

You might also want to check out Ueberzug [1]. It is a bit more
involved, but with it you can do all sorts of stuff, including playing
videos, pre-viewing PDFs, etc. It creates some sort of X11 overlay
(child window) at a given position.

Here is an example of what it looks like when using it in my
telekasten.nvim [4] plugin, "browsing media files":

https://user-images.githubusercontent.com/30892199/145457923-d3e3a20b-9a33-42d1-aa21-3de6b2295737.png

I recommend checking out the `scripts/vimg` [3] script in
telescope-media-files.nvim [2] for an example of how to render all sorts
of media at specific terminal coordinates.

-Rene

[1] : https://github.com/seebye/ueberzug
[2] : https://github.com/nvim-telescope/telescope-media-files.nvim
[3] : https://github.com/nvim-telescope/telescope-media-files.nvim/blob/master/scripts/vimg
[4] : https://sr.ht/~renerocksai/telekasten.nvim/
Details
Message ID
<CM9PSR9PHXR3.1C0E8VGSNAUIJ@deepthought>
In-Reply-To
<CM9HDFNUWYOX.2QJIXYFTNXSXR@ryzen> (view parent)
DKIM signature
missing
Download raw message
On Thu Aug 18, 2022 at 5:43 PM EDT, Rene Schallner wrote:
> You might also want to check out Ueberzug [1].

In my experience ueberzug does not play nicely with kitty when using
kitty's built-in tabs and windows. Here's an example of ncspot's[0]
album
cover feature which uses ueberzug: https://bp.tjf.sh/11c

I can't say for sure whether this is a bug in ueberzug itself or in how
ncspot uses ueberzug, so YMMV.

[0]: https://github.com/hrkfdn/ncspot/
Jens Grassel <jens@wegtam.com>
Details
Message ID
<CM9TDD9Q985L.2ZSNWU7YXV2HD@bianca-beakley.nowhere.wegtam.com>
In-Reply-To
<CM956SJEQATX.1077SDYWS2HLV@mashenka> (view parent)
DKIM signature
missing
Download raw message
Hi,

On Thu Aug 18, 2022 at 2:10 PM CEST, Bence Ferdinandy wrote:
> Hi,
>
> I was looking at filters and I tried the example for the images. I found
> that although it sounds great, the resolution is so bad that it's
> useless (I often send around plots where this resolution makes it
> impossible to decide what's going on).

for me using viu works quite well across a multitude of systems and
terminals.

```
image/svg+xml=convert -format svg - png:- | viu -
image/*=viu -s -
```

Kind regards,

Jens

-- 
Wegtam GmbH, CTO 2022-08-19 09:04
Homepage : https://www.wegtam.com

It's very inconvenient to be mortal -- you never know when everything may
suddenly stop happening.
Details
Message ID
<CM9YHPM78FE7.MI6E50TL7QGN@mashenka>
In-Reply-To
<CM9TDD9Q985L.2ZSNWU7YXV2HD@bianca-beakley.nowhere.wegtam.com> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 9:07 AM CEST, Jens Grassel wrote:
> ```
> image/svg+xml=convert -format svg - png:- | viu -
> image/*=viu -s -
> ```
Do you have dotfiles I can take a look at? On kitty, putting these two
lines in just prints characters on screen.


--
+36305425054
bence.ferdinandy.com
Details
Message ID
<CM9YXG1MDE3E.24LYID8H9SE3I@mashenka>
In-Reply-To
<CM9GZLV5IMEZ.231IXDOFD7P1G@ryzen> (view parent)
DKIM signature
missing
Download raw message
> 🤦 I had never tried that 🤣! Well, I still like it because I can
> specify a certain browser, e.g. qutebrowser, just for aerc-stuff. The
> --cleanup option is handy - and if you happen to view in browser a lot,
> the --output option lets you leave the same single browser window / tab
> open and pipe email after email into (no new windows, tabs) it, by
> piping into the same output file. Having a constant output file name
> enables you to set a bookmark to aerc output in the browser. (if you use
> --output).

That actually sounds pretty good, I might look into it later :)
> You guessed wrong - in my case. I don't mind typing [n] and [n]:. I used
> to just paste links on new lines, preceded and followed by empty lines,
> which kind of broke the text flow unnecessarily. I found out that
> footnote style works much better in e-mails most of the time, for my
> taste.

:D This is how you get opinions based on yourself 😅 On the other hand
the pandoc vim plugin seems to support autoformatting to this. I've been
thinking on switching over to that for markdown support for some time
now.


--
+36305425054
bence.ferdinandy.com
Details
Message ID
<CM9YN74PWC1A.3COXT6WTP31IJ@Archetype>
In-Reply-To
<CM9YHPM78FE7.MI6E50TL7QGN@mashenka> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 1:07 PM CEST, Bence Ferdinandy wrote:
> Do you have dotfiles I can take a look at? On kitty, putting these two
> lines in just prints characters on screen.
It's not exactly in line with the "show image in terminal", but
completely in line with the UNIX philosopy, so here's my filter list:

	[filters]
	application/json=jq -C
	application/x-tar=~/.config/aerc/filters/list-archive
	application/zip=~/.config/aerc/filters/list-archive
	application/pdf=zathura -
	audio/*=mpv -
	image/*=feh -


-- 
Moritz Poldrack
https://moritz.sh
Details
Message ID
<CM9Z9LQ02AUZ.1TVDLJDM32LZ5@mashenka>
In-Reply-To
<CM9PSR9PHXR3.1C0E8VGSNAUIJ@deepthought> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 6:19 AM CEST, Thomas Faughnan wrote:
> On Thu Aug 18, 2022 at 5:43 PM EDT, Rene Schallner wrote:
> > You might also want to check out Ueberzug [1].

Uberzeug seems cool, but also looks very daunting :D Quote from their
website: "The user is expected to have knowledge of theoretical computer
science."
> In my experience ueberzug does not play nicely with kitty when using
> kitty's built-in tabs and windows. Here's an example of ncspot's[0]
> album
> cover feature which uses ueberzug: https://bp.tjf.sh/11c
>
> I can't say for sure whether this is a bug in ueberzug itself or in how
> ncspot uses ueberzug, so YMMV.

tbh: I don't think kitty places nicely with mostly anything not
particularly written for kitty.


--
+36305425054
bence.ferdinandy.com
Details
Message ID
<CM9ZC3DS0JK9.PFSZ5EYJW0RC@grinningface>
In-Reply-To
<CM9YN74PWC1A.3COXT6WTP31IJ@Archetype> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 7:15 AM EDT, Moritz Poldrack wrote:
> It's not exactly in line with the "show image in terminal", but
> completely in line with the UNIX philosopy, so here's my filter list:
>
> 	[filters]
> 	application/json=jq -C
> 	application/x-tar=~/.config/aerc/filters/list-archive
> 	application/zip=~/.config/aerc/filters/list-archive
> 	application/pdf=zathura -
> 	audio/*=mpv -
> 	image/*=feh -

See also xdg-open(1).

Cheers,
-- 
DJ Chase
They, Them, Theirs
Details
Message ID
<CM9ZDPNNKJWN.2SYNG9EC9CF5R@mashenka>
In-Reply-To
<CM9H3IVRYS6C.1E2G0VOLAB6P1@grinningface> (view parent)
DKIM signature
missing
Download raw message
On Thu Aug 18, 2022 at 11:30 PM CEST, DJ Chase wrote:
> It’s also worth noting that catimg does not appear pixelated when using
> a terminal emulator that supports sixel graphics.

I tried using contour (which is based on my tests, actually a lot faster
than kitty), but catimg still pixelates (if we're talking about this:
[1]. I also tried with img2sixel. It works very nice in just the terminal, but
I haven't been able to get pictures to show in aerc unfortunately. Maybe
aerc terminal is eating up the sixels? 

[1]: https://github.com/posva/catimg
--
+36305425054
bence.ferdinandy.com
Details
Message ID
<CM9ZG8LWBZ5L.WB4AHK8FUZ54@mashenka>
In-Reply-To
<CM9ZC3DS0JK9.PFSZ5EYJW0RC@grinningface> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 1:47 PM CEST, DJ Chase wrote:
> On Fri Aug 19, 2022 at 7:15 AM EDT, Moritz Poldrack wrote:
> > It's not exactly in line with the "show image in terminal", but
> > completely in line with the UNIX philosopy, so here's my filter list:
> >
> > 	[filters]
> > 	application/json=jq -C
> > 	application/x-tar=~/.config/aerc/filters/list-archive
> > 	application/zip=~/.config/aerc/filters/list-archive
> > 	application/pdf=zathura -
> > 	audio/*=mpv -
> > 	image/*=feh -

thanks! I might also just stick with something like this

> See also xdg-open(1).

or yeah, xdg-open

I just _feel_ it should be able to work, but I might have to wait a few
years, before it's trivial to set up ...

Thanks,
Bence

--
+36305425054
bence.ferdinandy.com
Details
Message ID
<CMA0FUJLMVAP.QJLCU1KUVR0Z@Archetype>
In-Reply-To
<CM9ZC3DS0JK9.PFSZ5EYJW0RC@grinningface> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 1:47 PM CEST, DJ Chase wrote:
> See also xdg-open(1).
That wouldn't work with a filter, since xdg-open does not accept piping
files in.

-- 
Moritz Poldrack
https://moritz.sh
Jens Grassel <jens@wegtam.com>
Details
Message ID
<CMA0V61QEFK3.1H21TZRWNE0I3@bianca-beakley.nowhere.wegtam.com>
In-Reply-To
<CM9YHPM78FE7.MI6E50TL7QGN@mashenka> (view parent)
DKIM signature
missing
Download raw message
Hi,

On Fri Aug 19, 2022 at 1:07 PM CEST, Bence Ferdinandy wrote:
> On Fri Aug 19, 2022 at 9:07 AM CEST, Jens Grassel wrote:
> > ```
> > image/svg+xml=convert -format svg - png:- | viu -
> > image/*=viu -s -
> > ```
> Do you have dotfiles I can take a look at? On kitty, putting these two
> lines in just prints characters on screen.

no dotfiles for viu but I use this with alacritty and also with sakura so 
maybe it is a kitty issue?

Kind regards,

Jens

-- 
Wegtam GmbH, CTO 2022-08-19 14:57
Homepage : https://www.wegtam.com

I'm dressing up in an ill-fitting IVY-LEAGUE SUIT!!  Too late...
Rene Schallner <rene@renerocks.ai>
Details
Message ID
<CMA1CAAR8POA.QZYB9FYAEWL8@ryzen>
In-Reply-To
<CM9PSR9PHXR3.1C0E8VGSNAUIJ@deepthought> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 6:19 AM CEST, Thomas Faughnan wrote:

> On Thu Aug 18, 2022 at 5:43 PM EDT, Rene Schallner wrote:
> > You might also want to check out Ueberzug [1].
>
> In my experience ueberzug does not play nicely with kitty when using
> kitty's built-in tabs and windows. Here's an example of ncspot's[0]
> album

We're talking about aerc here, so I ncspot problems are not an ideal way
to assess feasibility. I use ueberzug inside of tmux inside of neovim
inside of telescope preview panes and the only difficult thing was to
calculate the x and y coordinates (in characters).

Also, I don't use kitty tabs and windows, prefer tmux. Which also is
beside the point. 

If you decided to try it, I'd recommend starting by installing it via
pip, and using a script like the mentioned vimg. 

However, someone mentioned viu, that seems a much easier route to go.
Rene Schallner <rene@renerocks.ai>
Details
Message ID
<CMA1DBC7DTFY.1ULLOHVTIB0SY@ryzen>
In-Reply-To
<CM9TDD9Q985L.2ZSNWU7YXV2HD@bianca-beakley.nowhere.wegtam.com> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 9:07 AM CEST, Jens Grassel wrote:

> for me using viu works quite well across a multitude of systems and
> terminals.

...

> Homepage : https://www.wegtam.com

I would have preferred a link to viu. My initial web search returned
Swiss eyewear 😊
Rene Schallner <rene@renerocks.ai>
Details
Message ID
<CMA1VTWK8F1T.K2EW4PE6633V@ryzen>
In-Reply-To
<CM9YXG1MDE3E.24LYID8H9SE3I@mashenka> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 1:28 PM CEST, Bence Ferdinandy wrote:

> That actually sounds pretty good, I might look into it later :)

Sure! 

> > I don't mind typing [n] and [n]:.
>
> :D This is how you get opinions based on yourself 😅 On the other hand
> the pandoc vim plugin seems to support autoformatting to this. I've been
> thinking on switching over to that for markdown support for some time
> now.

BTW cerc's html filters do the same, using `w3m
display_link_numbers=true`. So you might be able to pipe your e-mail
text through w3m or pandoc, back into vim, to replace links by
enumerated references and stick them to the bottom. However, after
cutting out the links and replacing them by references, the text needs
to be re-flowed. Piping it back into vim is probably a good idea, to
quick-check if link substitution and re-formatting worked out OK.

As I usually don't send millions of links in e-mails, it still seems
like an overkill to me. 

I don't really see how it's going to save me any work when composing an
e-mail: I start writing a few lines. Let's say: two. Then I copy a URL
from the browser, switch back to aerc/vim, and paste the link. Using
reference style, I just jump to the end of the message `G` before
pasting the link, then `I` to the beginning of the line, typing `[1] :`.
Then I jump to the end of my prose, `.` the `[1] : `, and delete the `:
` part with `C` - or I don't `.` it and instead just type `[1]` myself. 

Now, if I didn't do that, I'd just paste the link inline. That would
most likely look super ugly. So I'd terminate the current line, add an
extra empty line, then paste the link, then add another extra line, and
then continue with the prose in a new line, mid-sentence.

That's hardly any less keystrokes. If I then went to reformat the text
through pandoc or something, it would replace the links by their
references and add them to the bottom of the message. Now I'm left with
references on their own lines (where the links used to be). So I need to
reflow the text...

Am I missing something here? To me it appears that you are trying to
optimize something on a very theoretical basis. If you just typed [1],
[2], and [3] in your mail and added the links after having finished
writing your message, you'd see how quick and easy it is.

The only case I can think of where link substitution makes sense is,
when I paste something from my markdown notes into an e-mail. 

Just my 2 cents. Actually, I might have missed the obvious (again 😊).
-Rene
Details
Message ID
<CMA3YKAP10Q8.37BA9E6VWA112@grinningface>
In-Reply-To
<CMA0FUJLMVAP.QJLCU1KUVR0Z@Archetype> (view parent)
DKIM signature
missing
Download raw message
On Fri Aug 19, 2022 at 8:39 AM EDT, Moritz Poldrack wrote:
> On Fri Aug 19, 2022 at 1:47 PM CEST, DJ Chase wrote:
> > See also xdg-open(1).
> That wouldn't work with a filter, since xdg-open does not accept piping
> files in.

	#!/bin/sh

	FILE="$(mktemp)"
	cat >"$FILE"
	xdg-open "$FILE"

mktemp isn’t actually part of POSIX though, so here’s a more-complex but
portable script:

	#!/bin/sh

	umask -S u=rw,g=,o= >/dev/null
	unset FILE
	trap 'rm -f "$FILE"' INT TERM HUP EXIT
	FILE="/tmp/$$.$USER.$(awk 'BEGIN{srand(); print rand()}')"
	cat >"$FILE"

	xdg-open "$FILE"

Cheers,
-- 
DJ Chase
They, Them, Theirs
Details
Message ID
<CMCE4UBZ5LLH.1CFVPOAGQZ46C@mashenka>
In-Reply-To
<CMA0V61QEFK3.1H21TZRWNE0I3@bianca-beakley.nowhere.wegtam.com> (view parent)
DKIM signature
missing
Download raw message
So as a sort-of closing update on this:

tldr; I'm going to go with catimg which should be enough to decide if
the image needs opening in the system viewer, but the way to go would be
to have the built-in terminal support kitty graphics protocal or sixels
or both.

Bit longer:

I now have 9 different terminal emulators installed and read up a bit on
terminal graphics protocols (I'm keeping an eye on contour[1] as it is
really "blazingly" fast, a lot faster than at least in catting a long
file and wezterm[2] as it's seems very full featured, e.g. it has the
kitty keyboard protocol[3] and both graphics protocols).

As far as I am currently aware, there are two graphics protocols for
terminals that are able to produce "normal" images: the kitty graphics
protocol[4] and sixels[5]. As far as I understand, when I'm viewing
emails in aerc it uses the built-in terminal emulator to show anything,
so I tested things with `:terminal` and using `notcurses-info` from the
notcurses library[6] which made in very clear, that the built-in
terminal doesn't support any of the graphics protocols, no matter which
host terminal it is running in, so showing nice images in the built-in
terminal is _not_ possible. I think when I half-managed to show
a "proper" image with kitty icat it was rendered on the host terminal,
instead built-in one, so I think no wonder it was pretty fragile when
interacting with aerc.

I believe the built-in terminal is not aerc's own, so I think my last
question in the matter is where to take this issue? I'm seeing that
maybe everything goes back to libvterm[7]? In that case a fix might be
going with something notcurses based instead of curses. Which might mean
it is not going to happen for a long time and I'll need to instead look
into something complicated like ueberzug as a workaround.

[1]: https://github.com/contour-terminal/contour
[2]: https://wezfurlong.org/wezterm/features.html
[3]: https://sw.kovidgoyal.net/kitty/keyboard-protocol/
[4]: https://sw.kovidgoyal.net/kitty/graphics-protocol/
[5]: https://saitoha.github.io/libsixel/
[6]: https://github.com/dankamongmen/notcurses
[7]: https://github.com/TragicWarrior/libvterm

Best,
Bence

--
+36305425054
bence.ferdinandy.com
Details
Message ID
<CNN0M3VTZFTA.1LNN24BLQ1MTF@arch>
In-Reply-To
<CM9YHPM78FE7.MI6E50TL7QGN@mashenka> (view parent)
DKIM signature
missing
Download raw message
I had the same issues when using viu with kitty.
What i ended up using is this long filter:

image/*=kitty +kitten icat --stdin=yes --silent --transfer-mode stream --hold --place=120x120@0x7 && kitty +kitten icat --silent --transfer-mode stream --clear

I know that it looks awful, but its good enough for a quick view i guess.
Now icat waits for a key press before exiting and then it clears the image.
Also i had to reposition the image after the top headers and before the
statusline, otherwise the UI becomes a little messy.
Details
Message ID
<CNO4YUEE4151.5BURXV551JWB@mashenka>
In-Reply-To
<CNN0M3VTZFTA.1LNN24BLQ1MTF@arch> (view parent)
DKIM signature
missing
Download raw message
On Sun Oct 16, 2022 at 106:08, Julio B wrote:
> I had the same issues when using viu with kitty.
> What i ended up using is this long filter:
>
> image/*=kitty +kitten icat --stdin=yes --silent --transfer-mode stream --hold --place=120x120@0x7 && kitty +kitten icat --silent --transfer-mode stream --clear
>
> I know that it looks awful, but its good enough for a quick view i guess.
> Now icat waits for a key press before exiting and then it clears the image.
> Also i had to reposition the image after the top headers and before the
> statusline, otherwise the UI becomes a little messy.

Wow, it seems to really work, thanks! This will make my life a lot easier :)



--
+36305425054
bence.ferdinandy.com
Details
Message ID
<COI44JUNWA44.3FARP9F4FU6VX@mashenka>
In-Reply-To
<CNO4YUEE4151.5BURXV551JWB@mashenka> (view parent)
DKIM signature
missing
Download raw message
On Mon Oct 17, 2022 at 12:45, Bence Ferdinandy wrote:
>
> On Sun Oct 16, 2022 at 106:08, Julio B wrote:
> > I had the same issues when using viu with kitty.
> > What i ended up using is this long filter:
> >
> > image/*=kitty +kitten icat --stdin=yes --silent --transfer-mode stream --hold --place=120x120@0x7 && kitty +kitten icat --silent --transfer-mode stream --clear
> >
> > I know that it looks awful, but its good enough for a quick view i guess.
> > Now icat waits for a key press before exiting and then it clears the image.
> > Also i had to reposition the image after the top headers and before the
> > statusline, otherwise the UI becomes a little messy.
>
> Wow, it seems to really work, thanks! This will make my life a lot easier :)

I made an addition to this, since I had problems with very large images flowing
all over aerc:

image/*=convert - -resize 1000x500\>  - | kitty +kitten icat --stdin=yes --silent --transfer-mode stream --hold --place=120x120@0x7 && kitty +kitten icat --silent --transfer-mode stream --clear

This will resize the image if needed so that it's never wider than 1000 and
never taller than 500 but doesn't touch it if not needed.A

Best,
Bence

--
+36305425054
bence.ferdinandy.com
Reply to thread Export thread (mbox)