diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 731622f89..b4049b9d9 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -1316,7 +1316,7 @@ typedef struct GLFWLayerShellConfig { } GLFWLayerShellConfig; typedef struct GLFWDBUSNotificationData { - const char *app_name, *icon, *summary, *body, **actions; size_t num_actions; + const char *app_name, *icon, *summary, *body, *category, **actions; size_t num_actions; int32_t timeout; uint8_t urgency; uint32_t replaces; } GLFWDBUSNotificationData; diff --git a/glfw/linux_notify.c b/glfw/linux_notify.c index 66c5dfb40..98de7f086 100644 --- a/glfw/linux_notify.c +++ b/glfw/linux_notify.c @@ -177,6 +177,7 @@ glfw_dbus_send_user_notification(const GLFWDBUSNotificationData *n, GLFWDBusnoti check_call(dbus_message_iter_close_container, &array, &dict); \ } append_sv_dictionary_entry("urgency", DBUS_TYPE_BYTE, n->urgency); + if (n->category && n->category[0]) append_sv_dictionary_entry("category", DBUS_TYPE_STRING, n->category); check_call(dbus_message_iter_close_container, &args, &array); APPEND(args, DBUS_TYPE_INT32, n->timeout) diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index e3566cda0..e6d2f13b5 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -555,6 +555,7 @@ def dbus_send_notification( timeout: int = -1, urgency: int = 1, replaces: int = 0, + category: str = '', ) -> int: pass @@ -569,7 +570,7 @@ def cocoa_send_notification( body: str, category: MacOSNotificationCategory, categories: tuple[MacOSNotificationCategory, ...], - image_path: str = "", + image_path: str = '', urgency: int = 1, ) -> None: pass diff --git a/kitty/glfw-wrapper.h b/kitty/glfw-wrapper.h index eb08b69e5..30800fa2b 100644 --- a/kitty/glfw-wrapper.h +++ b/kitty/glfw-wrapper.h @@ -1054,7 +1054,7 @@ typedef struct GLFWLayerShellConfig { } GLFWLayerShellConfig; typedef struct GLFWDBUSNotificationData { - const char *app_name, *icon, *summary, *body, **actions; size_t num_actions; + const char *app_name, *icon, *summary, *body, *category, **actions; size_t num_actions; int32_t timeout; uint8_t urgency; uint32_t replaces; } GLFWDBUSNotificationData; diff --git a/kitty/glfw.c b/kitty/glfw.c index 4fd8d3e5c..9572aa7c2 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -2086,10 +2086,10 @@ static PyObject* dbus_send_notification(PyObject *self UNUSED, PyObject *args, PyObject *kw) { int timeout = -1, urgency = 1; unsigned int replaces = 0; GLFWDBUSNotificationData d = {0}; - static const char* kwlist[] = {"app_name", "app_icon", "title", "body", "actions", "timeout", "urgency", "replaces", NULL}; + static const char* kwlist[] = {"app_name", "app_icon", "title", "body", "actions", "timeout", "urgency", "replaces", "category", NULL}; PyObject *actions = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kw, "ssssO!|iiI", (char**)kwlist, - &d.app_name, &d.icon, &d.summary, &d.body, &PyDict_Type, &actions, &timeout, &urgency, &replaces)) return NULL; + if (!PyArg_ParseTupleAndKeywords(args, kw, "ssssO!|iiIs", (char**)kwlist, + &d.app_name, &d.icon, &d.summary, &d.body, &PyDict_Type, &actions, &timeout, &urgency, &replaces, &d.category)) return NULL; if (!glfwDBusUserNotify) { PyErr_SetString(PyExc_RuntimeError, "Failed to load glfwDBusUserNotify, did you call glfw_init?"); return NULL; diff --git a/kitty/notifications.py b/kitty/notifications.py index 613ce9728..9db41861a 100644 --- a/kitty/notifications.py +++ b/kitty/notifications.py @@ -727,7 +727,7 @@ class FreeDesktopIntegration(DesktopIntegration): actions[str(i+1)] = b desktop_notification_id = dbus_send_notification( app_name=nc.application_name or 'kitty', app_icon=app_icon, title=nc.title, body=body, actions=actions, - timeout=nc.timeout, urgency=nc.urgency.value, replaces=replaces_dbus_id) + timeout=nc.timeout, urgency=nc.urgency.value, replaces=replaces_dbus_id, category=(nc.notification_types or ('',))[0]) if debug_desktop_integration: log_error(f'Requested creation of notification with {desktop_notification_id=}') if existing_desktop_notification_id and replaces_dbus_id: