From 37969cea8e243af6222f8c05471769e6db6ec774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 16 Jan 2026 16:24:59 +0100 Subject: [PATCH 1/6] feedback-themes: Improve manpage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explain relation between profiles, events and feedback a bit better. Signed-off-by: Guido Günther --- doc/feedback-themes.rst | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/doc/feedback-themes.rst b/doc/feedback-themes.rst index a20122d..46a5414 100644 --- a/doc/feedback-themes.rst +++ b/doc/feedback-themes.rst @@ -17,17 +17,24 @@ currently active feedback theme. Each theme consists of up to three profile sections named `full`, `quiet` and `silent` containing event names and their associated feedback. They can reference another theme via the `parent-name` -element to avoid repetition. +element to avoid repetition. If an event received by the daemon is not +present in the currently active theme or its parent theme it will be +ignored. -The events in the theme are named according to the +Each event maps to at most one feedback in each profile. The events +in the theme are named according to the `Event Naming Specifiaction -`_ +`_. -Feedback themes use a JSON format that can be validated with +There are two types of themes: *custom* themes and *device* themes. +They both use the same format but have different purpose. Custom +themes are meant to tweak feebackd's output to the user's needs while +device themes are meant to cater for hardware differences. Feedback +themes use a JSON format that can be validated with ``fbd-theme-validate(1)``. For details on how to create or modify feedback themes see -``feedbackd's documentation`` at https://gitlab.freedesktop.org/agx/feedbackd#feedback-theme +``feedbackd's documentation`` at https://gitlab.freedesktop.org/agx/feedbackd#feedback-theme. Feedback types -------------- @@ -49,7 +56,7 @@ are described in the ``Sound theme spec`` at https://freedesktop.org/wiki/Specif - `event-name`: The sound event name to use. - `media-role`: The media role to set played audio stream. Defaults to `event`. -`Sound` feedback is usually used in the `full` profile section of the the theme only. +`Sound` feedback is usually used in the `full` profile section of the theme only. VibraRumble feedback ~~~~~~~~~~~~~~~~~~~~ @@ -61,7 +68,7 @@ The `VibraRumble` feedback uses a single property - `duration`: The duration of the rumble in ms. - `mangitude`: The relative magnitude of the rumble (``[0, 1]``). -`VibraRumble` feedback is usually used in the `quiet` profile section of the the theme only. +`VibraRumble` feedback is usually used in the `quiet` profile section of the theme only. VibraPattern feedback ~~~~~~~~~~~~~~~~~~~~~ @@ -85,7 +92,7 @@ The `Led` feedback type uses two properties to specify the way a LED blinks. each component. E.g. `#00FFFF` corresponds to cyan color. - `frequency`: The LEDs blinkinig frequency in mHz. -`Led` feedback is usually used in the `silent` profile section of the the theme only. +`Led` feedback is usually used in the `silent` profile section of the theme only. See also ======== From 8d0c09522db200cd78082896feae07d3b9115cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 16 Jan 2026 16:17:37 +0100 Subject: [PATCH 2/6] feedbackd: Fix indent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gbp-Dch: Ignore Signed-off-by: Guido Günther --- src/fbd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fbd.c b/src/fbd.c index 655d05a..b12197a 100644 --- a/src/fbd.c +++ b/src/fbd.c @@ -82,16 +82,16 @@ bus_acquired_cb (GDBusConnection *connection, static void name_acquired_cb (GDBusConnection *connection, - const gchar *name, - gpointer user_data) + const gchar *name, + gpointer user_data) { g_debug ("Service name '%s' was acquired", name); } static void name_lost_cb (GDBusConnection *connection, - const gchar *name, - gpointer user_data) + const gchar *name, + gpointer user_data) { /* Note that we're not allowing replacement, so once the name acquired, the * process won't lose it. */ From 94b35f356a84e6dcff8a6c2d4f50e08e20eee8e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 15 Jan 2026 15:17:56 +0100 Subject: [PATCH 3/6] feedbackd: Add --verbose option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Easier to discover than `G_MESSAGES_DEBUG` Signed-off-by: Guido Günther --- doc/feedbackd.rst | 3 +++ src/fbd.c | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/feedbackd.rst b/doc/feedbackd.rst index a44f648..8869a67 100644 --- a/doc/feedbackd.rst +++ b/doc/feedbackd.rst @@ -38,6 +38,9 @@ Options ``-h``, ``--help`` print help and exit +``-v``, ``--verbose`` + print verbose information + Configuration ============= diff --git a/src/fbd.c b/src/fbd.c index b12197a..10fac2f 100644 --- a/src/fbd.c +++ b/src/fbd.c @@ -1,6 +1,9 @@ /* * Copyright (C) 2020 Purism SPC + * 2023-2026 Phosh.mobi e.V. + * * SPDX-License-Identifier: GPL-3.0+ + * * Author: Guido Günther */ @@ -112,18 +115,28 @@ name_lost_cb (GDBusConnection *connection, int main (int argc, char *argv[]) { - g_autoptr(GError) err = NULL; - g_autoptr(GOptionContext) opt_context = NULL; + g_autoptr (GError) err = NULL; + gboolean opt_verbose = FALSE; + g_autoptr (GOptionContext) opt_context = NULL; g_autoptr (FbdFeedbackManager) manager = NULL; const char *debugenv; + GOptionEntry options[] = { + { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, + "Print debug information during command processing", NULL }, + { NULL } + }; opt_context = g_option_context_new ("- A daemon to trigger event feedback"); + g_option_context_add_main_entries (opt_context, options, NULL); if (!g_option_context_parse (opt_context, &argc, &argv, &err)) { g_warning ("%s", err->message); g_clear_error (&err); return 1; } + if (opt_verbose) + g_log_writer_default_set_debug_domains ((const char *const[]){ "all", NULL }); + debugenv = g_getenv ("FEEDBACKD_DEBUG"); fbd_debug_flags = g_parse_debug_string (debugenv, debug_keys, From 722a8f1c90415b7c82090212e10b1095e39b6c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 15 Jan 2026 16:10:41 +0100 Subject: [PATCH 4/6] feedbackd: Allow replacement and an option for it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This brings us in line with e.g. the portals Signed-off-by: Guido Günther --- doc/feedbackd.rst | 3 +++ src/fbd.c | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/feedbackd.rst b/doc/feedbackd.rst index 8869a67..07586f8 100644 --- a/doc/feedbackd.rst +++ b/doc/feedbackd.rst @@ -41,6 +41,9 @@ Options ``-v``, ``--verbose`` print verbose information +``-r``, ``--replace`` + replace a running instance + Configuration ============= diff --git a/src/fbd.c b/src/fbd.c index 10fac2f..f7fee1f 100644 --- a/src/fbd.c +++ b/src/fbd.c @@ -116,13 +116,14 @@ int main (int argc, char *argv[]) { g_autoptr (GError) err = NULL; - gboolean opt_verbose = FALSE; + gboolean opt_verbose = FALSE, opt_replace = FALSE; g_autoptr (GOptionContext) opt_context = NULL; g_autoptr (FbdFeedbackManager) manager = NULL; const char *debugenv; GOptionEntry options[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, - "Print debug information during command processing", NULL }, + "Print debug information during command processing", NULL }, + { "replace", 'r', 0, G_OPTION_ARG_NONE, &opt_replace, "Replace a running instance", NULL }, { NULL } }; @@ -153,7 +154,8 @@ main (int argc, char *argv[]) g_bus_own_name (FB_DBUS_TYPE, FB_DBUS_NAME, - G_BUS_NAME_OWNER_FLAGS_NONE, + G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | + (opt_replace ? G_BUS_NAME_OWNER_FLAGS_REPLACE : 0), bus_acquired_cb, name_acquired_cb, name_lost_cb, From 4ca9cb364bcf96594c690629f3d50dadf10fa753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 15 Jan 2026 16:22:24 +0100 Subject: [PATCH 5/6] feedbackd: Exit with EXIT_FAILURE if we can't get the bus name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes usage in scritps and systemd units more robust. Signed-off-by: Guido Günther --- src/fbd.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/fbd.c b/src/fbd.c index f7fee1f..102616a 100644 --- a/src/fbd.c +++ b/src/fbd.c @@ -19,7 +19,7 @@ #include static GMainLoop *loop; - +static gboolean name_acquired; static GDebugKey debug_keys[] = { @@ -89,6 +89,7 @@ name_acquired_cb (GDBusConnection *connection, gpointer user_data) { g_debug ("Service name '%s' was acquired", name); + name_acquired = TRUE; } static void @@ -96,18 +97,28 @@ name_lost_cb (GDBusConnection *connection, const gchar *name, gpointer user_data) { - /* Note that we're not allowing replacement, so once the name acquired, the - * process won't lose it. */ + int *ret = user_data; + if (!name) { g_warning ("Could not get the session bus. Make sure " "the message bus daemon is running!"); - } else { - if (connection) - g_warning ("Could not acquire the '%s' service name", name); - else - g_debug ("DBus connection close"); + *ret = EXIT_FAILURE; + goto out; } + if (!connection) { + g_debug ("DBus connection close"); + goto out; + } + + if (name_acquired) { + g_message ("Name lost"); + } else { + g_warning ("Could not acquire the '%s' service name", name); + *ret = EXIT_FAILURE; + } + +out: g_main_loop_quit (loop); } @@ -119,6 +130,7 @@ main (int argc, char *argv[]) gboolean opt_verbose = FALSE, opt_replace = FALSE; g_autoptr (GOptionContext) opt_context = NULL; g_autoptr (FbdFeedbackManager) manager = NULL; + gboolean ret = EXIT_SUCCESS; const char *debugenv; GOptionEntry options[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, @@ -159,9 +171,11 @@ main (int argc, char *argv[]) bus_acquired_cb, name_acquired_cb, name_lost_cb, - NULL, + &ret, NULL); g_main_loop_run (loop); g_main_loop_unref (loop); + + return ret; } From f311f7614700477d457c3a247727771dcf237050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 15 Jan 2026 16:29:30 +0100 Subject: [PATCH 6/6] feedbackd: Add --version option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther --- doc/feedbackd.rst | 3 +++ src/fbd.c | 10 +++++++++- src/meson.build | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/feedbackd.rst b/doc/feedbackd.rst index 07586f8..47c4215 100644 --- a/doc/feedbackd.rst +++ b/doc/feedbackd.rst @@ -44,6 +44,9 @@ Options ``-r``, ``--replace`` replace a running instance +``--version`` + print version and exit + Configuration ============= diff --git a/src/fbd.c b/src/fbd.c index 102616a..48a9c0f 100644 --- a/src/fbd.c +++ b/src/fbd.c @@ -9,6 +9,8 @@ #define G_LOG_DOMAIN "fbd" +#include "fbd-config.h" + #include "fbd.h" #include "fbd-feedback-manager.h" #include "fbd-haptic-manager.h" @@ -127,7 +129,7 @@ int main (int argc, char *argv[]) { g_autoptr (GError) err = NULL; - gboolean opt_verbose = FALSE, opt_replace = FALSE; + gboolean opt_verbose = FALSE, opt_replace = FALSE, opt_version = FALSE; g_autoptr (GOptionContext) opt_context = NULL; g_autoptr (FbdFeedbackManager) manager = NULL; gboolean ret = EXIT_SUCCESS; @@ -136,6 +138,7 @@ main (int argc, char *argv[]) { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL }, { "replace", 'r', 0, G_OPTION_ARG_NONE, &opt_replace, "Replace a running instance", NULL }, + { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print program version", NULL }, { NULL } }; @@ -147,6 +150,11 @@ main (int argc, char *argv[]) return 1; } + if (opt_version) { + g_print (PACKAGE_NAME " " PACKAGE_VERSION "\n"); + return EXIT_SUCCESS; + } + if (opt_verbose) g_log_writer_default_set_debug_domains ((const char *const[]){ "all", NULL }); diff --git a/src/meson.build b/src/meson.build index fef2dc7..cbf4868 100644 --- a/src/meson.build +++ b/src/meson.build @@ -3,6 +3,7 @@ if get_option('daemon') config_h = configuration_data() config_h.set_quoted('PACKAGE_VERSION', meson.project_version()) + config_h.set_quoted('PACKAGE_NAME', meson.project_name()) config_h.set('FBD_USE_MEDIA_ROLES', get_option('media-roles')) configure_file(output: 'fbd-config.h', configuration: config_h)