osc: kitty notifications: updated support for icons

This implements the suggested protocol discussed in
https://github.com/kovidgoyal/kitty/issues/7657.

Icons are handled by loading a cache. Both in-band PNG data, and
symbolic names are allowed.

Applications use a graphical ID to reference the icon both when
loading the cache, and when showing a notification.

* 'g' is the graphical ID
* 'n' is optional, and assigns a symbolic name to the icon
* 'p=icon' - the payload is icon PNG data. It needs to be base64
  encoded, but this is *not* implied. I.e. the application *must* use
  e=1 explicitly.

To load an icon (in-band PNG data):

    printf '\e]99;g=123:p=icon;<base64-encoded-png-data>\e\\'

or (symbolic name)

    printf '\e]99;g=123:n=firefox:p=icon;\e\\'

Of course, we can combine the two, assigning *both* a symbolic
name, *and* PNG data:

    printf '\e]99;g=123:n=firefox:p=icon;<base64-encoded-png>\e\\'

Then, to use the icon in a notification:

    printf '\e]99;g=123;this is a notification\e\\'

Foot also allows a *symbolic* icon to be defined and used at the same
time:

    printf '\e]99;g=123:n=firefox;this is a notification\e\\'

This obviously won't work with PNG data, since it uses the payload
portion of the escape sequence.
This commit is contained in:
Daniel Eklöf 2024-07-23 11:29:05 +02:00
parent c7cffea9ee
commit ccb184ae64
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 245 additions and 49 deletions

View file

@ -802,6 +802,7 @@ struct terminal {
/* Notifications that either haven't been sent yet, or have been
sent but not yet dismissed */
tll(struct notification) notifications;
struct notification_icon notification_icons[32];
char *foot_exe;
char *cwd;