From 2bd817dafef58a09f4d1c78de9868e22badfe0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 15 Nov 2025 17:44:19 +0100 Subject: [PATCH 1/9] ruff: Set line length MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This lets meson test -C _build/ --suite lint --print-errorlogs pass again. Signed-off-by: Guido Günther Part-of: --- .ruff.toml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .ruff.toml diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 000000000..71de86823 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1 @@ +line-length = 100 -- GitLab From f86be98fafc15629e30f9b44fec14fcba236f442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 9 Nov 2025 11:20:22 +0100 Subject: [PATCH 2/9] tests: Indent fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gbp-Dch: Ignore Signed-off-by: Guido Günther Part-of: --- tests/test-shell.c | 2 +- tests/testlib-full-shell.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test-shell.c b/tests/test-shell.c index 5e84d0671..5f01494c1 100644 --- a/tests/test-shell.c +++ b/tests/test-shell.c @@ -75,7 +75,7 @@ phosh_test_get_shell (GLogLevelFlags *saved_flags) /* Drop warnings from the fatal log mask since there's plenty * when running without recommended DBus services */ flags = g_log_set_always_fatal (0); - g_log_set_always_fatal(flags & ~G_LOG_LEVEL_WARNING); + g_log_set_always_fatal (flags & ~G_LOG_LEVEL_WARNING); shell = phosh_shell_new (); g_assert_true (PHOSH_IS_SHELL (shell)); diff --git a/tests/testlib-full-shell.c b/tests/testlib-full-shell.c index 5133373ca..1f205a967 100644 --- a/tests/testlib-full-shell.c +++ b/tests/testlib-full-shell.c @@ -163,7 +163,8 @@ phosh_test_full_shell_setup (PhoshTestFullShellFixture *fixture, gconstpointer d /* Run shell in a thread so we can sync call to the DBus interfaces */ fixture->queue = g_async_queue_new (); - fixture->comp_and_shell = g_thread_new ("comp-and-shell-thread", phosh_test_full_shell_thread, fixture); + fixture->comp_and_shell = g_thread_new ("comp-and-shell-thread", + phosh_test_full_shell_thread, fixture); } /** -- GitLab From bc7b94ead46e84884591df0f3b452000420abdc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 9 Nov 2025 10:14:50 +0100 Subject: [PATCH 3/9] build: Bump minimum glib version to 2.80 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Needed for `g_log_writer_default_set_debug_domains` Signed-off-by: Guido Günther Part-of: --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index d18c01200..390d89842 100644 --- a/meson.build +++ b/meson.build @@ -48,7 +48,7 @@ else sysconfdir = get_option('sysconfdir') endif -glib_ver = '2.76' +glib_ver = '2.80' glib_ver_str = 'GLIB_VERSION_@0@'.format(glib_ver.replace('.', '_')) glib_ver_cmp = '>=@0@'.format(glib_ver) -- GitLab From fc9b1a1e6f0358d998c9fd7681e496f2e1a1d14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 9 Nov 2025 11:01:54 +0100 Subject: [PATCH 4/9] tests: Use g_log_writer_default_set_debug_domains directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No need to go through a custom implementation Signed-off-by: Guido Günther Part-of: --- tests/test-gtk-mount-manager.c | 1 - tests/test-idle-manager.c | 1 - tests/test-lockscreen.c | 1 - tests/test-shell.c | 3 +-- tests/testlib-full-shell.c | 24 ++++++++++-------------- tests/testlib-full-shell.h | 4 ++-- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/tests/test-gtk-mount-manager.c b/tests/test-gtk-mount-manager.c index f5e2d3cc0..825980ea4 100644 --- a/tests/test-gtk-mount-manager.c +++ b/tests/test-gtk-mount-manager.c @@ -7,7 +7,6 @@ */ #include "phosh-gtk-mountoperation-dbus.h" -#include "log.h" #include "shell-priv.h" #include "testlib-full-shell.h" diff --git a/tests/test-idle-manager.c b/tests/test-idle-manager.c index 2ce997db8..f12d39372 100644 --- a/tests/test-idle-manager.c +++ b/tests/test-idle-manager.c @@ -7,7 +7,6 @@ */ #include "phosh-idle-dbus.h" -#include "log.h" #include "shell-priv.h" #include "testlib-full-shell.h" diff --git a/tests/test-lockscreen.c b/tests/test-lockscreen.c index 1bc01a32b..143257fb8 100644 --- a/tests/test-lockscreen.c +++ b/tests/test-lockscreen.c @@ -4,7 +4,6 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -#include "log.h" #include "testlib-wait-for-shell-state.h" #include "testlib-full-shell.h" diff --git a/tests/test-shell.c b/tests/test-shell.c index 5f01494c1..76b8e8539 100644 --- a/tests/test-shell.c +++ b/tests/test-shell.c @@ -8,7 +8,6 @@ #include "testlib-compositor.h" -#include "log.h" #include "shell-priv.h" #include "background-manager.h" #include "phosh-wayland.h" @@ -70,7 +69,7 @@ phosh_test_get_shell (GLogLevelFlags *saved_flags) gtk_init (NULL, NULL); hdy_init (); - phosh_log_set_log_domains ("all"); + g_log_writer_default_set_debug_domains ((const char * const[]){ "all", NULL }); /* Drop warnings from the fatal log mask since there's plenty * when running without recommended DBus services */ diff --git a/tests/testlib-full-shell.c b/tests/testlib-full-shell.c index 1f205a967..e8324b7df 100644 --- a/tests/testlib-full-shell.c +++ b/tests/testlib-full-shell.c @@ -10,11 +10,12 @@ #include "testlib-full-shell.h" #include "fake-clock.h" -#include "log.h" #include "shell-priv.h" -#include #include +#include +#include + /** * PhoshTestFullShellFixture: @@ -67,7 +68,7 @@ phosh_test_full_shell_thread (gpointer data) hdy_init (); cui_init (TRUE); - phosh_log_set_log_domains (fixture->log_domains); + g_log_writer_default_set_debug_domains ((const char *const *)fixture->log_domains); /* Drop warnings from the fatal log mask since there's plenty * when running without recommended DBus services */ @@ -105,7 +106,7 @@ phosh_test_full_shell_thread (gpointer data) while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, FALSE); - phosh_log_set_log_domains (NULL); + g_log_writer_default_set_debug_domains (NULL); return NULL; } @@ -113,14 +114,9 @@ PhoshTestFullShellFixtureCfg * phosh_test_full_shell_fixture_cfg_new (const char *log_domains) { PhoshTestFullShellFixtureCfg *self = g_new0 (PhoshTestFullShellFixtureCfg, 1); - const char *domains; - - domains = g_getenv ("G_MESSAGES_DEBUG"); - if (domains != NULL && strlen (domains)) - log_domains = domains; - if (log_domains) - self->log_domains = g_strdup (log_domains); + if (!gm_str_is_null_or_empty (log_domains)) + self->log_domains = g_strsplit (log_domains, " ", -1); return self; } @@ -128,7 +124,7 @@ phosh_test_full_shell_fixture_cfg_new (const char *log_domains) void phosh_test_full_shell_fixture_cfg_dispose (PhoshTestFullShellFixtureCfg *self) { - g_clear_pointer (&self->log_domains, g_free); + g_clear_pointer (&self->log_domains, g_strfreev); g_free (self); } @@ -159,7 +155,7 @@ phosh_test_full_shell_setup (PhoshTestFullShellFixture *fixture, gconstpointer d g_setenv ("XDG_RUNTIME_DIR", fixture->tmpdir, TRUE); if (cfg->log_domains) - fixture->log_domains = g_strdup (cfg->log_domains); + fixture->log_domains = g_strdupv (cfg->log_domains); /* Run shell in a thread so we can sync call to the DBus interfaces */ fixture->queue = g_async_queue_new (); @@ -192,5 +188,5 @@ phosh_test_full_shell_teardown (PhoshTestFullShellFixture *fixture, gconstpointe phosh_test_remove_tree (file); g_free (fixture->tmpdir); - g_free (fixture->log_domains); + g_strfreev (fixture->log_domains); } diff --git a/tests/testlib-full-shell.h b/tests/testlib-full-shell.h index afbea400e..af01dcf77 100644 --- a/tests/testlib-full-shell.h +++ b/tests/testlib-full-shell.h @@ -15,13 +15,13 @@ typedef struct _PhoshTestFullShellFixture { GAsyncQueue *queue; PhoshTestCompositorState *state; GTestDBus *bus; - char *log_domains; + GStrv log_domains; char *tmpdir; } PhoshTestFullShellFixture; typedef struct _PhoshTestFullShellFixtureCfg { - char *log_domains; + GStrv log_domains; } PhoshTestFullShellFixtureCfg; -- GitLab From 7f462b40de5c9c268a39e2c0e4c99dd8e1b44e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 9 Nov 2025 10:15:19 +0100 Subject: [PATCH 5/9] shell: Track log domains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther Part-of: --- src/shell.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/shell.c b/src/shell.c index ec424b96e..eef60802a 100644 --- a/src/shell.c +++ b/src/shell.c @@ -128,6 +128,7 @@ enum { PROP_PRIMARY_MONITOR, PROP_SHELL_STATE, PROP_OVERVIEW_VISIBLE, + PROP_LOG_DOMAINS, PROP_LAST_PROP }; static GParamSpec *props[PROP_LAST_PROP]; @@ -146,6 +147,7 @@ typedef struct PhoshDragSurface *home; gboolean overview_visible; GPtrArray *faders; /* for final fade out */ + GStrv log_domains; PhoshOsdWindow *osd; gint osd_timeoutid; @@ -478,6 +480,29 @@ set_locked (PhoshShell *self, gboolean locked) } +static void +phosh_shell_set_log_domains (PhoshShell *self, const char *const *log_domains) +{ + PhoshShellPrivate *priv = phosh_shell_get_instance_private (self); + + g_return_if_fail (PHOSH_IS_SHELL (self)); + + if (!priv->log_domains && !log_domains) + return; + + if (priv->log_domains && log_domains && + g_strv_equal ((const char *const *)priv->log_domains, log_domains)) + return; + + g_strfreev (priv->log_domains); + priv->log_domains = g_strdupv ((GStrv)log_domains); + + g_log_writer_default_set_debug_domains (log_domains); + + g_object_notify_by_pspec (G_OBJECT (self), props[PROP_LOG_DOMAINS]); +} + + static void phosh_shell_set_property (GObject *object, guint property_id, @@ -502,6 +527,9 @@ phosh_shell_set_property (GObject *object, case PROP_OVERVIEW_VISIBLE: priv->overview_visible = g_value_get_boolean (value); break; + case PROP_LOG_DOMAINS: + phosh_shell_set_log_domains (self, g_value_get_boxed (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -537,6 +565,9 @@ phosh_shell_get_property (GObject *object, case PROP_OVERVIEW_VISIBLE: g_value_set_boolean (value, priv->overview_visible); break; + case PROP_LOG_DOMAINS: + g_value_set_boxed (value, priv->log_domains); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -620,6 +651,11 @@ phosh_shell_dispose (GObject *object) static void phosh_shell_finalize (GObject *object) { + PhoshShell *self = PHOSH_SHELL (object); + PhoshShellPrivate *priv = phosh_shell_get_instance_private (self); + + g_clear_pointer (&priv->log_domains, g_strfreev); + cui_uninit (); G_OBJECT_CLASS (phosh_shell_parent_class)->finalize (object); } @@ -1346,6 +1382,16 @@ phosh_shell_class_init (PhoshShellClass *klass) g_param_spec_boolean ("overview-visible", "", "", TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + /** + * PhoshShell:log-domains + * + * The current log domains + */ + props[PROP_LOG_DOMAINS] = + g_param_spec_boxed ("log-domains", "", "", + G_TYPE_STRV, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, PROP_LAST_PROP, props); @@ -1383,8 +1429,13 @@ static GDebugKey debug_keys[] = static void phosh_shell_init (PhoshShell *self) { + const char *messages_debug; PhoshShellPrivate *priv = phosh_shell_get_instance_private (self); + messages_debug = g_getenv ("G_MESSAGES_DEBUG"); + if (messages_debug) + priv->log_domains = g_strsplit (messages_debug, " ", -1); + cui_init (TRUE); gtk_icon_theme_add_resource_path (gtk_icon_theme_get_default (), "/mobi/phosh/icons"); -- GitLab From cafef312a425f0e2b22634b03cc3ea30d72b9701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 9 Nov 2025 09:35:36 +0100 Subject: [PATCH 6/9] debug-control: New DBus interface to control debug settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For now we allow to set log levels via DBus. This is similar to what we do in phoc. Signed-off-by: Guido Günther Part-of: --- src/dbus/meson.build | 7 + src/dbus/mobi.phosh.Shell.DebugControl.xml | 21 +++ src/debug-control.c | 186 +++++++++++++++++++++ src/debug-control.h | 26 +++ src/meson.build | 2 + 5 files changed, 242 insertions(+) create mode 100644 src/dbus/mobi.phosh.Shell.DebugControl.xml create mode 100644 src/debug-control.c create mode 100644 src/debug-control.h diff --git a/src/dbus/meson.build b/src/dbus/meson.build index 6c5c91f04..c1c41d673 100644 --- a/src/dbus/meson.build +++ b/src/dbus/meson.build @@ -116,6 +116,13 @@ dbus_client_protos = [ # dbus_server_protos = [ # Sorted by xml filename: + [ + 'phosh-dbus-debug-control', + 'mobi.phosh.Shell.DebugControl.xml', + 'mobi.phosh.Shell', + false, + false, + ], [ 'geoclue-agent-dbus', 'org.freedesktop.GeoClue2.Agent.xml', diff --git a/src/dbus/mobi.phosh.Shell.DebugControl.xml b/src/dbus/mobi.phosh.Shell.DebugControl.xml new file mode 100644 index 000000000..dfc033eb3 --- /dev/null +++ b/src/dbus/mobi.phosh.Shell.DebugControl.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + diff --git a/src/debug-control.c b/src/debug-control.c new file mode 100644 index 000000000..5a8257b91 --- /dev/null +++ b/src/debug-control.c @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2025 Phosh.mobi e.V. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Author: Guido Günther + */ + +#define G_LOG_DOMAIN "phosh-debug-control" + +#include "phosh-config.h" + +#include "debug-control.h" +#include "phosh-enums.h" +#include "shell-priv.h" + +#include + +#define DEBUG_CONTROL_DBUS_PATH "/mobi/phosh/Shell/DebugControl" +#define DEBUG_CONTROL_DBUS_NAME "mobi.phosh.Shell.DebugControl" + +/** + * PhoshDebugControl: + * + * DBus Debug control interface + */ + +enum { + PROP_0, + PROP_EXPORTED, + PROP_LAST_PROP +}; +static GParamSpec *props[PROP_LAST_PROP]; + +struct _PhoshDebugControl { + PhoshDBusDebugControlSkeleton parent; + + guint dbus_name_id; + gboolean exported; +}; + +static void phosh_dbus_debug_control_iface_init (PhoshDBusDebugControlIface *iface); + +G_DEFINE_TYPE_WITH_CODE (PhoshDebugControl, phosh_debug_control, + PHOSH_DBUS_TYPE_DEBUG_CONTROL_SKELETON, + G_IMPLEMENT_INTERFACE (PHOSH_DBUS_TYPE_DEBUG_CONTROL, + phosh_dbus_debug_control_iface_init)) + +static void +phosh_dbus_debug_control_iface_init (PhoshDBusDebugControlIface *iface) +{ +} + + +static void +on_bus_acquired (GDBusConnection *connection, const char *name, gpointer user_data) +{ + PhoshDebugControl *self = user_data; + g_autoptr (GError) err = NULL; + + if (g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self), + connection, + DEBUG_CONTROL_DBUS_PATH, + &err)) { + self->exported = TRUE; + g_object_notify_by_pspec (G_OBJECT (self), props[PROP_EXPORTED]); + g_debug ("Debug interface exported on '%s'", DEBUG_CONTROL_DBUS_NAME); + } else { + g_warning ("Failed to export on %s: %s", DEBUG_CONTROL_DBUS_NAME, err->message); + } +} + + +static void +phosh_debug_control_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + PhoshDebugControl *self = PHOSH_DEBUG_CONTROL (object); + + switch (property_id) { + case PROP_EXPORTED: + phosh_debug_control_set_exported (self, g_value_get_boolean (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +static void +phosh_debug_control_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + PhoshDebugControl *self = PHOSH_DEBUG_CONTROL (object); + + switch (property_id) { + case PROP_EXPORTED: + g_value_set_boolean (value, self->exported); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +static void +phosh_debug_control_dispose (GObject *object) +{ + PhoshDebugControl *self = PHOSH_DEBUG_CONTROL (object); + + if (self->exported) { + g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self)); + self->exported = FALSE; + } + g_clear_handle_id (&self->dbus_name_id, g_bus_unown_name); + + G_OBJECT_CLASS (phosh_debug_control_parent_class)->dispose (object); +} + + +static void +phosh_debug_control_class_init (PhoshDebugControlClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->get_property = phosh_debug_control_get_property; + object_class->set_property = phosh_debug_control_set_property; + object_class->dispose = phosh_debug_control_dispose; + + props[PROP_EXPORTED] = + g_param_spec_boolean ("exported", "", "", + FALSE, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, PROP_LAST_PROP, props); +} + + +static void +phosh_debug_control_init (PhoshDebugControl *self) +{ + g_object_bind_property (phosh_shell_get_default (), + "log-domains", + self, + "log-domains", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); +} + + +PhoshDebugControl * +phosh_debug_control_new (void) +{ + return g_object_new (PHOSH_TYPE_DEBUG_CONTROL, NULL); +} + + +void +phosh_debug_control_set_exported (PhoshDebugControl *self, gboolean exported) +{ + g_assert (PHOSH_IS_DEBUG_CONTROL (self)); + + if (self->exported == exported) + return; + + if (exported) { + self->dbus_name_id = g_bus_own_name (G_BUS_TYPE_SESSION, + DEBUG_CONTROL_DBUS_NAME, + G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | + G_BUS_NAME_OWNER_FLAGS_REPLACE, + on_bus_acquired, + NULL, + NULL, + self, + NULL); + } else { + g_clear_handle_id (&self->dbus_name_id, g_bus_unown_name); + self->exported = FALSE; + g_object_notify_by_pspec (G_OBJECT (self), props[PROP_EXPORTED]); + } +} diff --git a/src/debug-control.h b/src/debug-control.h new file mode 100644 index 000000000..4eb0948d1 --- /dev/null +++ b/src/debug-control.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2025 Phosh.mobi e.V. + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "phosh-dbus-debug-control.h" + +#include + +G_BEGIN_DECLS + + + +#define PHOSH_TYPE_DEBUG_CONTROL (phosh_debug_control_get_type ()) + +G_DECLARE_FINAL_TYPE (PhoshDebugControl, phosh_debug_control, PHOSH, DEBUG_CONTROL, + PhoshDBusDebugControlSkeleton) + +PhoshDebugControl *phosh_debug_control_new (void); +void phosh_debug_control_set_exported (PhoshDebugControl *self, + gboolean exported); + +G_END_DECLS diff --git a/src/meson.build b/src/meson.build index aafd4162a..a33af276a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -138,6 +138,7 @@ phosh_tool_headers = files( 'clamp.h', 'connectivity-info.h', 'connectivity-manager.h', + 'debug-control.h', 'default-media-player.h', 'docked-info.h', 'docked-manager.h', @@ -219,6 +220,7 @@ phosh_tool_sources = files( 'clamp.c', 'connectivity-info.c', 'connectivity-manager.c', + 'debug-control.c', 'default-media-player.c', 'docked-info.c', 'docked-manager.c', -- GitLab From 23549bfe16ba094ca9deda264b59336fdabfdcfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 9 Nov 2025 10:19:11 +0100 Subject: [PATCH 7/9] shell: Export debug control interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows to set log domains via DBus Signed-off-by: Guido Günther Part-of: --- docs/phosh.rst | 20 ++++++++++++++++++++ src/shell.c | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/docs/phosh.rst b/docs/phosh.rst index 8ee7fcb01..06960d205 100644 --- a/docs/phosh.rst +++ b/docs/phosh.rst @@ -49,6 +49,26 @@ e.g. gsettings set sm.puri.phosh.plugins lock-screen "['ticket-box', 'upcoming-events']" +DBUS INTERFACE +-------------- + +``phosh`` allows to enable and disable certain debug flags at runtime via DBus. To see a list of +available flags use: + +:: + + busctl --user introspect mobi.phosh.Shell.DebugControl /mobi/phosh/Shell/DebugControl mobi.phosh.Shell.DebugControl + +To toggle individual values: + +:: + + busctl --user set-property mobi.phosh.Shell.DebugControl /mobi/phosh/Shell/DebugControl mobi.phosh.Shell.DebugControl LogDomains as 2 phosh-shell phosh-brightness-manager + +Note that the flags are not considered stable API so can change +between releases. + + ENVIRONMENT VARIABLES --------------------- diff --git a/src/shell.c b/src/shell.c index eef60802a..f7b133144 100644 --- a/src/shell.c +++ b/src/shell.c @@ -29,6 +29,7 @@ #include "background.h" #include "brightness-manager.h" #include "drag-surface.h" +#include "debug-control.h" #include "shell-priv.h" #include "app-tracker.h" #include "batteryinfo.h" @@ -199,6 +200,7 @@ typedef struct PhoshConnectivityManager *connectivity_manager; PhoshMprisManager *mpris_manager; PhoshBrightnessManager *brightness_manager; + PhoshDebugControl *debug_control; /* sensors */ PhoshSensorProxyManager *sensor_proxy_manager; @@ -589,6 +591,7 @@ phosh_shell_dispose (GObject *object) g_clear_pointer (&priv->notification_banner, phosh_cp_widget_destroy); /* dispose managers in opposite order of declaration */ + g_clear_object (&priv->debug_control); g_clear_object (&priv->brightness_manager); g_clear_object (&priv->mpris_manager); g_clear_object (&priv->connectivity_manager); @@ -825,6 +828,7 @@ setup_idle_cb (PhoshShell *self) g_autoptr (GError) err = NULL; PhoshShellPrivate *priv = phosh_shell_get_instance_private (self); + priv->debug_control = phosh_debug_control_new (); priv->app_tracker = phosh_app_tracker_new (); priv->session_manager = phosh_session_manager_new (); priv->mode_manager = phosh_mode_manager_new (); @@ -908,6 +912,9 @@ setup_idle_cb (PhoshShell *self) /* Setup event hooks late so state changes in UI files don't trigger feedback */ phosh_feedback_manager_setup_event_hooks (priv->feedback_manager); + /* Export the debug interface late so everything is up when the name appears */ + phosh_debug_control_set_exported (priv->debug_control, TRUE); + /* Delay signaling to the compositor a bit so that idle handlers get a chance to run and the user can unlock right away. Ideally we'd not need this */ priv->startup_finished_id = g_timeout_add_seconds_once (1, on_startup_finished, self); -- GitLab From d9f628881c3c746c38d67ab492589667e6f84b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 9 Nov 2025 10:01:15 +0100 Subject: [PATCH 8/9] log: Drop custom log handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just use glib's default handler, we can set log domains via DBus now. Signed-off-by: Guido Günther Part-of: --- src/log.c | 141 ------------------------------------------------ src/log.h | 17 ------ src/main.c | 28 +--------- src/meson.build | 2 - 4 files changed, 1 insertion(+), 187 deletions(-) delete mode 100644 src/log.c delete mode 100644 src/log.h diff --git a/src/log.c b/src/log.c deleted file mode 100644 index 4b78ea6f9..000000000 --- a/src/log.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2020 Purism SPC - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - * Author: Guido Günther - */ - -#define G_LOG_DOMAIN "phosh-log" - -#include "phosh-config.h" -#include "log.h" - -#include - -/* these are emitted by the default log handler */ -#define DEFAULT_LEVELS (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE) -/* these are filtered by G_MESSAGES_DEBUG by the default log handler */ -#define INFO_LEVELS (G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG) - -static gboolean _log_writer_func_set; -static char *_log_domains; -G_LOCK_DEFINE_STATIC (_log_domains); - -static gboolean -log_is_old_api (const GLogField *fields, - gsize n_fields) -{ - return (n_fields >= 1 && - g_strcmp0 (fields[0].key, "GLIB_OLD_LOG_API") == 0 && - g_strcmp0 (fields[0].value, "1") == 0); -} - - -static void -_phosh_log_abort (gboolean breakpoint) -{ - if (breakpoint) - G_BREAKPOINT (); - else - g_abort (); -} - - -static GLogWriterOutput -phosh_log_writer_default (GLogLevelFlags log_level, - const GLogField *fields, - gsize n_fields, - gpointer unused) -{ - static gsize initialized = 0; - static gboolean stderr_is_journal = FALSE; - GLogLevelFlags always_fatal; - - g_return_val_if_fail (fields != NULL, G_LOG_WRITER_UNHANDLED); - g_return_val_if_fail (n_fields > 0, G_LOG_WRITER_UNHANDLED); - - G_LOCK (_log_domains); - - /* Disable debug message output unless specified in _log_domains. */ - if (!(log_level & DEFAULT_LEVELS) && !(log_level >> G_LOG_LEVEL_USER_SHIFT)) { - const char *log_domain = NULL; - gsize i; - - if ((log_level & INFO_LEVELS) == 0 || _log_domains == NULL) { - G_UNLOCK (_log_domains); - return G_LOG_WRITER_HANDLED; - } - - for (i = 0; i < n_fields; i++) { - if (g_strcmp0 (fields[i].key, "GLIB_DOMAIN") == 0) { - log_domain = fields[i].value; - break; - } - } - - if (strcmp (_log_domains, "all") != 0 && - (log_domain == NULL || !strstr (_log_domains, log_domain))) { - G_UNLOCK (_log_domains); - return G_LOG_WRITER_HANDLED; - } - } - - /* Need to retrieve this from glib via getting and resetting: - * https://gitlab.gnome.org/GNOME/glib/-/issues/2217 */ - always_fatal = g_log_set_always_fatal (0); - g_log_set_always_fatal (always_fatal); - - if ((log_level & always_fatal) && !log_is_old_api (fields, n_fields)) - log_level |= G_LOG_FLAG_FATAL; - - /* Try logging to the systemd journal as first choice. */ - if (g_once_init_enter (&initialized)) { - stderr_is_journal = g_log_writer_is_journald (fileno (stderr)); - g_once_init_leave (&initialized, TRUE); - } - - if (stderr_is_journal && - g_log_writer_journald (log_level, fields, n_fields, _log_domains) == - G_LOG_WRITER_HANDLED) - goto handled; - - if (g_log_writer_standard_streams (log_level, fields, n_fields, _log_domains) == - G_LOG_WRITER_HANDLED) - goto handled; - - G_UNLOCK (_log_domains); - return G_LOG_WRITER_UNHANDLED; - -handled: - /* Abort if the message was fatal. */ - if (log_level & G_LOG_FLAG_FATAL) { - _phosh_log_abort (!(log_level & G_LOG_FLAG_RECURSION)); - } - - G_UNLOCK (_log_domains); - return G_LOG_WRITER_HANDLED; -} - -/** - * phosh_log_set_log_domains: - * @domains: comma separated list of log domains. - * - * Set the current logging domains. This sets an appropriate log - * handler as well. - */ -void -phosh_log_set_log_domains (const char *domains) -{ - G_LOCK (_log_domains); - g_free (_log_domains); - _log_domains = g_strdup (domains); - G_UNLOCK (_log_domains); - - if (_log_writer_func_set) - return; - - g_log_set_writer_func ((GLogWriterFunc)phosh_log_writer_default, - NULL, NULL); - _log_writer_func_set = TRUE; -} diff --git a/src/log.h b/src/log.h deleted file mode 100644 index fbbb5a540..000000000 --- a/src/log.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2020 Purism SPC - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - * Author: Guido Günther - */ - -#pragma once - -#include - -G_BEGIN_DECLS - -void phosh_log_set_log_domains (const char *domains); - -G_END_DECLS diff --git a/src/main.c b/src/main.c index 7adf14ae8..d0b3c53f0 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2018 Purism SPC + * 2025 Phosh.mobi e.V. * * SPDX-License-Identifier: GPL-3.0-or-later * @@ -10,7 +11,6 @@ #include "phosh-config.h" -#include "log.h" #include "shell-priv.h" #include "phosh-wayland.h" #include "wall-clock.h" @@ -36,28 +36,6 @@ quit (gpointer unused) } -static gboolean -on_sigusr1_signal (gpointer unused) -{ - static gboolean logall = FALSE; - - if (logall) { - const char *domains; - - domains = g_getenv ("G_MESSAGES_DEBUG"); - g_message ("Enabling messages for %s", domains); - phosh_log_set_log_domains (domains); - logall = FALSE; - } else { - g_message ("Enabling all log messages"); - phosh_log_set_log_domains ("all"); - logall = TRUE; - } - - return G_SOURCE_CONTINUE; -} - - static gboolean on_shutdown_signal (gpointer unused) { @@ -153,8 +131,6 @@ main (int argc, char *argv[]) if (version) print_version (); - phosh_log_set_log_domains (g_getenv ("G_MESSAGES_DEBUG")); - textdomain (GETTEXT_PACKAGE); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); @@ -164,7 +140,6 @@ main (int argc, char *argv[]) g_unix_signal_add (SIGTERM, on_shutdown_signal, NULL); g_unix_signal_add (SIGINT, on_shutdown_signal, NULL); - g_unix_signal_add (SIGUSR1, on_sigusr1_signal, NULL); wall_clock = get_clock (); phosh_wall_clock_set_default (wall_clock); @@ -181,6 +156,5 @@ main (int argc, char *argv[]) gtk_main (); - phosh_log_set_log_domains (NULL); return EXIT_SUCCESS; } diff --git a/src/meson.build b/src/meson.build index a33af276a..116c813db 100644 --- a/src/meson.build +++ b/src/meson.build @@ -159,7 +159,6 @@ phosh_tool_headers = files( 'keypad.h', 'launcher-entry-manager.h', 'lockshield.h', - 'log.h', 'manager.h', 'media-player.h', 'mode-manager.h', @@ -243,7 +242,6 @@ phosh_tool_sources = files( 'launcher-entry-manager.c', 'layersurface.c', 'lockshield.c', - 'log.c', 'manager.c', 'media-player.c', 'metainfo-cache.c', -- GitLab From f962d7243220ec947d505de082ae22b01afad0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 9 Nov 2025 16:56:38 +0100 Subject: [PATCH 9/9] tests/integration: Use DBus call instead of timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that we have a DBus interface that is exported once the shell is up we can drop the timeout check in favor of a DBus call thus speeding up the tests. Signed-off-by: Guido Günther Part-of: --- tests/integration/__init__.py | 16 +++++++++++++--- tests/integration/test_dbus.py | 3 --- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index d06fecc7d..ec442a72f 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -7,12 +7,16 @@ # Author: Guido Günther +import dbus import time import fcntl import os import subprocess import tempfile import sys +from dbus.mainloop.glib import DBusGMainLoop + +DBusGMainLoop(set_as_default=True) def set_nonblock(fd): @@ -107,10 +111,16 @@ class Phosh: stderr: {self.stderr} stdout: {self.stdout}""" - print("Phosh ready") + bus = dbus.SessionBus() + proxy = bus.get_object( + "mobi.phosh.Shell.DebugControl", "/mobi/phosh/Shell/DebugControl" + ) + iface = dbus.Interface(proxy, "org.freedesktop.DBus.Properties") + props = iface.GetAll("mobi.phosh.Shell.DebugControl", timeout=5) + if "LogDomains" not in props: + return None - # TODO: Check availability on DBus - time.sleep(2) + print("Phosh ready") return self def wait_for_output( diff --git a/tests/integration/test_dbus.py b/tests/integration/test_dbus.py index 4b0f50779..ca449d486 100755 --- a/tests/integration/test_dbus.py +++ b/tests/integration/test_dbus.py @@ -15,15 +15,12 @@ import subprocess import dbusmock from collections import OrderedDict from dbusmock import DBusTestCase -from dbus.mainloop.glib import DBusGMainLoop from pathlib import Path from gi.repository import Gio from . import Phosh, set_nonblock -DBusGMainLoop(set_as_default=True) - class PhoshDBusTestCase(DBusTestCase): @classmethod -- GitLab