aboutsummaryrefslogtreecommitdiff
path: root/osc.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-08-04 12:16:56 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-08-04 12:20:35 +0000
commit63492624918cd23a5efdd9b8a8b4f057da66d961 (patch)
tree1e426fa797ec03ce3a00cb3c97f47cdf09b1de85 /osc.c
parentterm: reload_fonts(): don't ignore return value of thrd_join() (diff)
osc: kitty notifications: implement s=silent
This implements part of the new 's' (sound) parameter; the 'silent' value. When s=silent, we set the ${muted} template argument to "true". It is intended to set the 'suppress-sound' hint: notify-send --hint BOOLEAN:suppress-sound:${muted}
Diffstat (limited to 'osc.c')
-rw-r--r--osc.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/osc.c b/osc.c
index 28d8b7b8..50415570 100644
--- a/osc.c
+++ b/osc.c
@@ -609,6 +609,7 @@ kitty_notification(struct terminal *term, char *string)
char *icon_cache_id = NULL; /* The 'g' parameter */
char *symbolic_icon = NULL; /* The 'n' parameter */
char *category = NULL; /* The 't' parameter */
+ char *sound_name = NULL; /* The 's' parameter */
char *payload = NULL;
bool focus = true; /* The 'a' parameter */
@@ -739,7 +740,7 @@ kitty_notification(struct terminal *term, char *string)
char reply[128];
int n = xsnprintf(
reply, sizeof(reply),
- "\033]99;i=%s:p=?;p=%s:a=%s:o=%s:u=%s:c=1:w=1%s",
+ "\033]99;i=%s:p=?;p=%s:a=%s:o=%s:u=%s:c=1:w=1:s=silent%s",
reply_id, p_caps, a_caps, when_caps, u_caps, terminator);
xassert(n < sizeof(reply));
@@ -783,10 +784,15 @@ kitty_notification(struct terminal *term, char *string)
break;
}
- case 'f':
- free(app_id);
- app_id = base64_decode(value, NULL);
+ case 'f': {
+ /* App-name */
+ char *decoded = base64_decode(value, NULL);
+ if (decoded != NULL) {
+ free(app_id);
+ app_id = decoded;
+ }
break;
+ }
case 't': {
/* Type (category) */
@@ -805,6 +811,16 @@ kitty_notification(struct terminal *term, char *string)
break;
}
+ case 's': {
+ /* Sound */
+ char *decoded = base64_decode(value, NULL);
+ if (decoded != NULL) {
+ free(sound_name);
+ sound_name = decoded;
+ }
+ break;
+ }
+
case 'g':
/* graphical ID (see 'n' and 'p=icon') */
free(icon_cache_id);
@@ -946,6 +962,10 @@ kitty_notification(struct terminal *term, char *string)
}
}
+ if (sound_name != NULL) {
+ notif->muted = streq(sound_name, "silent");
+ }
+
/* Handled chunked payload - append to existing metadata */
switch (payload_type) {
case PAYLOAD_TITLE:
@@ -1067,6 +1087,7 @@ out:
free(symbolic_icon);
free(payload);
free(category);
+ free(sound_name);
}
void