From 405b887a82ec83cf8423378ae4f4f92226998905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 2 Jun 2021 17:50:29 +0200 Subject: [PATCH] =?UTF-8?q?osc:=20implement=20iTerm2=E2=80=99s=20OSC-9=20-?= =?UTF-8?q?=20desktop=20notifications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + doc/foot-ctlseqs.7.scd | 3 +++ osc.c | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 536dd96f..f01548e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ * `tweak.pua-double-width` option to `foot.ini`, letting you force _Private Usage Area_ codepoints to be treated as double-width characters. +* OSC 9 desktop notifications (iTerm2 compatible). ### Changed diff --git a/doc/foot-ctlseqs.7.scd b/doc/foot-ctlseqs.7.scd index 8755cbaa..68408644 100644 --- a/doc/foot-ctlseqs.7.scd +++ b/doc/foot-ctlseqs.7.scd @@ -579,6 +579,9 @@ All _OSC_ sequences begin with *\\E]*, sometimes abbreviated _OSC_. : Hyperlink (a.k.a HTML-like anchors). _id_ is optional; if assigned, all URIs with the same *ID* will be treated as a single hyperlink. An empty URI closes the hyperlink. +| \\E] 9 ; _msg_ \\E\\ +: iTerm2 +: Desktop notification, uses *notify* in *foot.ini*(5). | \\E] 10 ; _spec_ \\E\\ : xterm : Change the default foreground color to _spec_, a color in diff --git a/osc.c b/osc.c index f5aa86a2..7e934c72 100644 --- a/osc.c +++ b/osc.c @@ -521,7 +521,7 @@ osc_notify(struct terminal *term, char *string) const char *title = strtok_r(string, ";", &ctx); const char *msg = strtok_r(NULL, "\x00", &ctx); - notify_notify(term, title, msg); + notify_notify(term, title, msg != NULL ? msg : ""); } static void @@ -678,6 +678,11 @@ osc_dispatch(struct terminal *term) osc_uri(term, string); break; + case 9: + /* iTerm2 Growl notifications */ + osc_notify(term, string); + break; + case 10: case 11: case 17: