From a7bb564c7996e789c897dd65a5e1b53e95e0d208 Mon Sep 17 00:00:00 2001 From: noise Date: Sat, 28 Feb 2026 19:12:09 +0300 Subject: [PATCH] ref: remove unnecessary dbus permission --- jp.angeltech.MoeMoji.json | 3 +-- src/moemoji-application.c | 25 ++++++------------------- src/moemoji-application.h | 1 - 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/jp.angeltech.MoeMoji.json b/jp.angeltech.MoeMoji.json index 457e703..5f80f4b 100644 --- a/jp.angeltech.MoeMoji.json +++ b/jp.angeltech.MoeMoji.json @@ -8,8 +8,7 @@ "--share=ipc", "--socket=fallback-x11", "--socket=wayland", - "--talk-name=org.kde.StatusNotifierWatcher", - "--own-name=org.kde.StatusNotifierItem-2-1" + "--talk-name=org.kde.StatusNotifierWatcher" ], "modules": [ { diff --git a/src/moemoji-application.c b/src/moemoji-application.c index a9e8dab..c32b567 100644 --- a/src/moemoji-application.c +++ b/src/moemoji-application.c @@ -266,16 +266,6 @@ static const GDBusInterfaceVTable sni_vtable = { .set_property = NULL, }; -static void on_sni_bus_name_acquired(GDBusConnection *connection, - const gchar *name, - G_GNUC_UNUSED gpointer user_data) { - g_dbus_connection_call( - connection, "org.kde.StatusNotifierWatcher", "/StatusNotifierWatcher", - "org.kde.StatusNotifierWatcher", "RegisterStatusNotifierItem", - g_variant_new("(s)", name), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, - NULL); -} - static void update_tray_icon(MoeMojiApplication *self) { AdwStyleManager *sm = adw_style_manager_get_default(); gboolean dark = adw_style_manager_get_dark(sm); @@ -334,11 +324,12 @@ static void setup_sni(MoeMojiApplication *self) { g_warning("dbusmenu register: %s", error->message); g_error_free(error); } - g_autofree gchar *bus_name = - g_strdup_printf("org.kde.StatusNotifierItem-%d-1", getpid()); - self->sni_bus_name_id = g_bus_own_name_on_connection( - self->dbus_conn, bus_name, G_BUS_NAME_OWNER_FLAGS_NONE, - on_sni_bus_name_acquired, NULL, NULL, NULL); + const gchar *unique_name = g_dbus_connection_get_unique_name(self->dbus_conn); + g_dbus_connection_call( + self->dbus_conn, "org.kde.StatusNotifierWatcher", "/StatusNotifierWatcher", + "org.kde.StatusNotifierWatcher", "RegisterStatusNotifierItem", + g_variant_new("(s)", unique_name), NULL, G_DBUS_CALL_FLAGS_NONE, -1, + NULL, NULL, NULL); } static void on_shortcuts_activated(GDBusProxy *proxy, const gchar *sender_name, @@ -561,10 +552,6 @@ static void moemoji_application_dispose(GObject *object) { self->menu_registration_id); self->menu_registration_id = 0; } - if (self->sni_bus_name_id > 0) { - g_bus_unown_name(self->sni_bus_name_id); - self->sni_bus_name_id = 0; - } g_clear_object(&self->shortcuts_proxy); g_clear_pointer(&self->shortcuts_session_path, g_free); g_clear_pointer(&self->icon_theme_path, g_free); diff --git a/src/moemoji-application.h b/src/moemoji-application.h index 1b0c4fc..cd16ebd 100644 --- a/src/moemoji-application.h +++ b/src/moemoji-application.h @@ -11,7 +11,6 @@ struct _MoeMojiApplication { gboolean shortcuts_bound; GDBusConnection *dbus_conn; guint sni_registration_id; - guint sni_bus_name_id; guint menu_registration_id; gchar *icon_theme_path; const gchar *tray_icon_name;