From 482c096f7e7e3e021b8f5088d6e5a8fd47f32edf Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Sat, 21 Mar 2026 10:14:28 -0400 Subject: daemon: Add force-display setting to override notification suppression Add a new 'force-display' gsettings and checkbox that, when enabled, shows all notifications regardless of urgency, fullscreen, or screensaver state. Do Not Disturb still takes precedence. Fixes #199 --- src/capplet/mate-notification-properties.c | 3 +++ src/capplet/mate-notification-properties.ui | 16 ++++++++++++++++ src/common/constants.h | 1 + src/daemon/daemon.c | 12 +++++++----- 4 files changed, 27 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/capplet/mate-notification-properties.c b/src/capplet/mate-notification-properties.c index f81dd2c..a12ff20 100644 --- a/src/capplet/mate-notification-properties.c +++ b/src/capplet/mate-notification-properties.c @@ -49,6 +49,7 @@ typedef struct { GtkWidget* timeout_spin; GtkWidget* persistence_checkbox; GtkWidget* countdown_checkbox; + GtkWidget* force_display_checkbox; NotifyNotification* preview1; NotifyNotification* preview2; @@ -502,6 +503,7 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di dialog->timeout_spin = GTK_WIDGET(gtk_builder_get_object(builder, "timeout_spin")); dialog->persistence_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "enable_persistence_check")); dialog->countdown_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "show_countdown_check")); + dialog->force_display_checkbox = GTK_WIDGET(gtk_builder_get_object(builder, "force_display_check")); g_object_unref (builder); @@ -518,6 +520,7 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di g_settings_bind (dialog->gsettings, GSETTINGS_KEY_DEFAULT_TIMEOUT, timeout_adjustment, "value", G_SETTINGS_BIND_DEFAULT); g_settings_bind (dialog->gsettings, GSETTINGS_KEY_ENABLE_PERSISTENCE, dialog->persistence_checkbox, "active", G_SETTINGS_BIND_DEFAULT); g_settings_bind (dialog->gsettings, GSETTINGS_KEY_SHOW_COUNTDOWN, dialog->countdown_checkbox, "active", G_SETTINGS_BIND_DEFAULT); + g_settings_bind (dialog->gsettings, GSETTINGS_KEY_FORCE_DISPLAY, dialog->force_display_checkbox, "active", G_SETTINGS_BIND_DEFAULT); notification_properties_dialog_setup_themes (dialog); notification_properties_dialog_setup_positions (dialog); diff --git a/src/capplet/mate-notification-properties.ui b/src/capplet/mate-notification-properties.ui index 9b461bf..0c802e5 100644 --- a/src/capplet/mate-notification-properties.ui +++ b/src/capplet/mate-notification-properties.ui @@ -347,6 +347,22 @@ 2 + + + Force Display All Notifications + True + True + False + start + True + Show all notifications regardless of urgency, fullscreen, or screensaver state. Do Not Disturb still takes precedence. + + + False + True + 3 + + diff --git a/src/common/constants.h b/src/common/constants.h index 1a81977..972cd7f 100644 --- a/src/common/constants.h +++ b/src/common/constants.h @@ -32,6 +32,7 @@ #define GSETTINGS_KEY_ENABLE_PERSISTENCE "enable-persistence" #define GSETTINGS_KEY_SHOW_COUNTDOWN "show-countdown" #define GSETTINGS_KEY_HISTORY_ENABLED "history-enabled" +#define GSETTINGS_KEY_FORCE_DISPLAY "force-display" #define NOTIFICATION_BUS_NAME "org.freedesktop.Notifications" #define NOTIFICATION_BUS_PATH "/org/freedesktop/Notifications" diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 4f1aa11..3cdd72d 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -1834,8 +1834,10 @@ static gboolean notify_daemon_notify_handler(NotifyDaemonNotifications *object, #endif /* HAVE_X11 */ /* fullscreen_window is assumed to be false on Wayland, as there is no trivial way to check */ + gboolean force_display = g_settings_get_boolean (daemon->gsettings, GSETTINGS_KEY_FORCE_DISPLAY); + /* If on DnD or screensaver, suppress and close notification */ - if (do_not_disturb || (screensaver_active (GTK_WIDGET (nw)) && urgency != URGENCY_CRITICAL)) + if (do_not_disturb || (!force_display && screensaver_active (GTK_WIDGET (nw)) && urgency != URGENCY_CRITICAL)) { _NotifyPendingClose *notification_data; @@ -1848,12 +1850,12 @@ static gboolean notify_daemon_notify_handler(NotifyDaemonNotifications *object, } else { - /* Show if critical or no fullscreen window */ - if (urgency == URGENCY_CRITICAL || !fullscreen_window) + /* Show if critical, force-display, or no fullscreen window */ + if (force_display || urgency == URGENCY_CRITICAL || !fullscreen_window) theme_show_notification (nw); - /* Play sound unless low urgency during fullscreen */ - if (sound_file != NULL && !(fullscreen_window && urgency == URGENCY_LOW)) + /* Play sound unless low urgency during fullscreen (when not force-display) */ + if (sound_file != NULL && (force_display || !(fullscreen_window && urgency == URGENCY_LOW))) sound_play_file (GTK_WIDGET (nw), sound_file); } -- cgit v1.2.1