diff --git a/.ruff.toml b/.ruff.toml
new file mode 100644
index 0000000000000000000000000000000000000000..71de868235494b222a9d12a06aa937ea71a98a4c
--- /dev/null
+++ b/.ruff.toml
@@ -0,0 +1 @@
+line-length = 100
diff --git a/docs/phosh.rst b/docs/phosh.rst
index 8ee7fcb019e95eab5abb33b9f636912b953a1756..06960d205d91682d73946022873dce4deac002a9 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/meson.build b/meson.build
index d18c012004041c6972a8c11de790ba86c5164320..390d89842b282a41d3b44c5d8169f2699283cceb 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)
diff --git a/src/dbus/meson.build b/src/dbus/meson.build
index 6c5c91f049a339d6202588f43e3370eaf02efc92..c1c41d673eba8273bc0552d174c153f2c4aba148 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 0000000000000000000000000000000000000000..dfc033eb3c5a84ec35f466e8479dc4943f2a00d2
--- /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 0000000000000000000000000000000000000000..5a8257b91c9f911f29f6deeda3fb6e523677d51d
--- /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 0000000000000000000000000000000000000000..4eb0948d12e3bfbaf5438e5b24a81a54e1e494e2
--- /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/log.c b/src/log.c
deleted file mode 100644
index 4b78ea6f9175d2333990b43ab1328a33f408c394..0000000000000000000000000000000000000000
--- 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 fbbb5a540ae950344e5a69bfac3ebd9c72af1077..0000000000000000000000000000000000000000
--- 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 7adf14ae853871ef6929db0dc9b5048d1347ff30..d0b3c53f0b0c42568db18dac192ea2a41f1bd2b5 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 aafd4162ac816a997f4681ac2003037a2ce7aa4c..116c813dbd9b30f9559c549038bfee134089a69d 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',
@@ -158,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',
@@ -219,6 +219,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',
@@ -241,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',
diff --git a/src/shell.c b/src/shell.c
index ec424b96e2c1be2e651e8d6024597ae71dca23b9..f7b1331449c7db917093ed9ce8a1b8b41a153ebe 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"
@@ -128,6 +129,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 +148,7 @@ typedef struct
PhoshDragSurface *home;
gboolean overview_visible;
GPtrArray *faders; /* for final fade out */
+ GStrv log_domains;
PhoshOsdWindow *osd;
gint osd_timeoutid;
@@ -197,6 +200,7 @@ typedef struct
PhoshConnectivityManager *connectivity_manager;
PhoshMprisManager *mpris_manager;
PhoshBrightnessManager *brightness_manager;
+ PhoshDebugControl *debug_control;
/* sensors */
PhoshSensorProxyManager *sensor_proxy_manager;
@@ -478,6 +482,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 +529,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 +567,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;
@@ -558,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);
@@ -620,6 +654,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);
}
@@ -789,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 ();
@@ -872,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);
@@ -1346,6 +1389,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 +1436,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");
diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py
index d06fecc7df2cec68f188e1563fde4e9c977437eb..ec442a72f3a9741c8f1889c45c1438d3319953ba 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 4b0f507794cf0c1e5b997f2b1be3b264c2b1f5f8..ca449d4863ecfcda2f325c6da1ab3596b0bb885c 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
diff --git a/tests/test-gtk-mount-manager.c b/tests/test-gtk-mount-manager.c
index f5e2d3cc08c649c897e57c71e8d7b68689886478..825980ea4965ba735972ea3d9f6b5a2d74b22683 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 2ce997db8a28531343743427a313cab7ceb0e429..f12d39372c7a6c2bec9b3dc587c21253e9c1c5d2 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 1bc01a32bd9cf5459b742fcbfc78e64fb28572a6..143257fb8207b66c2c0f69b249a5ea7c385da846 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 5e84d0671a66e4d676b1c3e8df92ad255a3bfcfd..76b8e8539d6658b4a71c895ff5aea5fa5592aa56 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,12 +69,12 @@ 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 */
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 5133373ca08404f57de04bb4727be316f076fa6d..e8324b7dfdb504b66377db3f76534c4f88f3499e 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,11 +155,12 @@ 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 ();
- 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);
}
/**
@@ -191,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 afbea400e9e5d9927683b1bde03f69103d6a6094..af01dcf7776a6e123009f678e05139d8928d3b9b 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;