aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-07-22 18:45:49 +0200
committerdec05eba <dec05eba@protonmail.com>2024-07-22 18:45:49 +0200
commit462a3276cbf21231575c94de1482c44de703cf06 (patch)
tree1a7c9041c98156263cc525fb8453b70d5d3d6cb1
parent42bfe1315be1a851434c4675a0c2c38863bb8e6c (diff)
Hax: fix notification not showing on kde plasma when recording with desktop portal (kde doesn't allow this by default unless a config has been changed or notification is set as urgent)
-rw-r--r--TODO7
-rw-r--r--src/main.cpp36
2 files changed, 33 insertions, 10 deletions
diff --git a/TODO b/TODO
index 30b3e86..9065eea 100644
--- a/TODO
+++ b/TODO
@@ -28,7 +28,7 @@ Add refresh button for audio devices. Put it beside the "add" button. In the new
Gray out monitor capture on intel if plane is compressed. Show the user to desktop portal capture instead.
-Look at showmethekey https://github.com/AlynxZhou/showmethekey to see how to do global hotkeys without x11/wayland.
+Look at showmethekey https://github.com/AlynxZhou/showmethekey to see how to do global hotkeys without x11/wayland. The password prompt for this can be removed by using polkit rules, this is how SwayOSD does it.
A single flatpak can only be installed either system-wide or user, so there can be a check if it's installed system-wide or user and it will only match one. With this information we can guaranteed know the flatpak directory of the running gpu screen recorder instance. The command `flatpak info -l com.dec05eba.gpu_screen_recorder` can also be used and is available for all flatpak users.
@@ -43,4 +43,7 @@ Replay on startup should be its own page with its own settings for everything an
Maybe create gnome extension so that gnome users can see recording status, or mention to the user that it's a gnome limitation.
The system startup program should work like the gpu screen recorder systemd daemon but start gpu screen recorder gtk with a special argument to launch it into this
replay mode. The replay mode program should loop and launch gpu screen recorder, restarting it if it crashes. If it crashes show an error dialog to the user
- and if hotkeys cant be registered then also show an error. \ No newline at end of file
+ and if hotkeys cant be registered then also show an error.
+
+Notifications are not shown on kde plasma while using desktop portal capture (system-wide). This is a design choice by kde, see https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/blob/master/src/screencast.cpp?ref_type=heads#L41 . The DoNotDisturb.WhenScreenSharing config controls this. This can be bypassed by making the notification critical. Maybe notifications should be set as critical? but only on kde.
+ Maybe we should create our own notification system with gtk layer shell (which is supported by every platform except gnome wayland). \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index 90c642e..2c77c84 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -289,6 +289,13 @@ enum class GsrInfoExitStatus {
static GsrInfoExitStatus gsr_info_exit_status;
+enum class WaylandCompositor {
+ UNKNOWN,
+ HYPRLAND,
+ KDE // kwin
+};
+static WaylandCompositor wayland_compositor = WaylandCompositor::UNKNOWN;
+
struct Container {
const char *container_name;
const char *file_extension;
@@ -983,19 +990,26 @@ static void save_configs() {
}
static void show_notification(GtkApplication *app, const char *title, const char *body, GNotificationPriority priority) {
+ if(priority < G_NOTIFICATION_PRIORITY_URGENT) {
+ notification_timeout_seconds = 3.0;
+ } else {
+ notification_timeout_seconds = 10.0;
+ }
+
+ // KDE doesn't show notifications when using desktop portal capture unless either DoNotDisturb.WhenScreenSharing kde config
+ // has been changed by the user or if the priority for the notification is set as urgent
+ const std::string recording_window = record_area_selection_menu_get_active_id();
+ if((recording || replaying || streaming) && wayland_compositor == WaylandCompositor::KDE && recording_window == "portal")
+ priority = G_NOTIFICATION_PRIORITY_URGENT;
+
fprintf(stderr, "Notification: title: %s, body: %s\n", title, body);
GNotification *notification = g_notification_new(title);
g_notification_set_body(notification, body);
g_notification_set_priority(notification, priority);
g_application_send_notification(&app->parent, "gpu-screen-recorder", notification);
- showing_notification = true;
- if(priority < G_NOTIFICATION_PRIORITY_URGENT) {
- notification_timeout_seconds = 2.0;
- } else {
- notification_timeout_seconds = 10.0;
- }
notification_start_seconds = clock_get_monotonic_seconds();
+ showing_notification = true;
}
static bool window_has_atom(Display *display, Window window, Atom atom) {
@@ -4126,14 +4140,20 @@ static void activate(GtkApplication *app, gpointer) {
load_config();
if(gsr_info.system_info.display_server == DisplayServer::WAYLAND) {
+ if(gdk_wayland_display_query_registry(gdk_display_get_default(), "hyprland_global_shortcuts_manager_v1")) {
+ wayland_compositor = WaylandCompositor::HYPRLAND;
+ } else if(gdk_wayland_display_query_registry(gdk_display_get_default(), "org_kde_plasma_shell")) {
+ wayland_compositor = WaylandCompositor::KDE;
+ }
+
init_shortcuts_callback(false, nullptr);
// TODO:
// Disable global hotkeys on Hyprland for now. It crashes the hyprland desktop portal.
// When it's re-enabled on Hyprland it will need special handing where it does BindShortcuts immediately on startup
// instead of having a "register hotkeys" button. This needed because Hyprland doesn't remember registered hotkeys after
// the desktop portal is restarted (when the computer is restarted for example).
- const bool is_hyprland = gdk_wayland_display_query_registry(gdk_display_get_default(), "hyprland_global_shortcuts_manager_v1");
- if(is_hyprland) {
+
+ if(wayland_compositor == WaylandCompositor::HYPRLAND) {
const char *hotkeys_not_supported_text = "Global hotkeys have been disabled on your system because of a Hyprland bug.\nUse X11 or KDE Plasma on Wayland if you want to use hotkeys.";
gtk_label_set_text(GTK_LABEL(recording_hotkeys_not_supported_label), hotkeys_not_supported_text);
gtk_label_set_text(GTK_LABEL(replay_hotkeys_not_supported_label), hotkeys_not_supported_text);