Merge branch 'verbose' into 'main'
feedbackd: Add --verbose, --replace and --version options See merge request agx/feedbackd!205
This commit is contained in:
+15
-8
@@ -17,17 +17,24 @@ currently active feedback theme.
|
|||||||
Each theme consists of up to three profile sections named `full`,
|
Each theme consists of up to three profile sections named `full`,
|
||||||
`quiet` and `silent` containing event names and their associated
|
`quiet` and `silent` containing event names and their associated
|
||||||
feedback. They can reference another theme via the `parent-name`
|
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
|
`Event Naming Specifiaction
|
||||||
<https://gitlab.freedesktop.org/agx/feedbackd/-/blob/main/doc/Event-naming-spec-0.0.0.md>`_
|
<https://gitlab.freedesktop.org/agx/feedbackd/-/blob/main/doc/Event-naming-spec-0.0.0.md>`_.
|
||||||
|
|
||||||
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)``.
|
``fbd-theme-validate(1)``.
|
||||||
|
|
||||||
For details on how to create or modify feedback themes see
|
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
|
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.
|
- `event-name`: The sound event name to use.
|
||||||
- `media-role`: The media role to set played audio stream. Defaults to `event`.
|
- `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
|
VibraRumble feedback
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
@@ -61,7 +68,7 @@ The `VibraRumble` feedback uses a single property
|
|||||||
- `duration`: The duration of the rumble in ms.
|
- `duration`: The duration of the rumble in ms.
|
||||||
- `mangitude`: The relative magnitude of the rumble (``[0, 1]``).
|
- `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
|
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.
|
each component. E.g. `#00FFFF` corresponds to cyan color.
|
||||||
- `frequency`: The LEDs blinkinig frequency in mHz.
|
- `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
|
See also
|
||||||
========
|
========
|
||||||
|
|||||||
@@ -38,6 +38,15 @@ Options
|
|||||||
``-h``, ``--help``
|
``-h``, ``--help``
|
||||||
print help and exit
|
print help and exit
|
||||||
|
|
||||||
|
``-v``, ``--verbose``
|
||||||
|
print verbose information
|
||||||
|
|
||||||
|
``-r``, ``--replace``
|
||||||
|
replace a running instance
|
||||||
|
|
||||||
|
``--version``
|
||||||
|
print version and exit
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020 Purism SPC
|
* Copyright (C) 2020 Purism SPC
|
||||||
|
* 2023-2026 Phosh.mobi e.V.
|
||||||
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.0+
|
* SPDX-License-Identifier: GPL-3.0+
|
||||||
|
*
|
||||||
* Author: Guido Günther <agx@sigxcpu.org>
|
* Author: Guido Günther <agx@sigxcpu.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define G_LOG_DOMAIN "fbd"
|
#define G_LOG_DOMAIN "fbd"
|
||||||
|
|
||||||
|
#include "fbd-config.h"
|
||||||
|
|
||||||
#include "fbd.h"
|
#include "fbd.h"
|
||||||
#include "fbd-feedback-manager.h"
|
#include "fbd-feedback-manager.h"
|
||||||
#include "fbd-haptic-manager.h"
|
#include "fbd-haptic-manager.h"
|
||||||
@@ -16,7 +21,7 @@
|
|||||||
#include <glib-unix.h>
|
#include <glib-unix.h>
|
||||||
|
|
||||||
static GMainLoop *loop;
|
static GMainLoop *loop;
|
||||||
|
static gboolean name_acquired;
|
||||||
|
|
||||||
static GDebugKey debug_keys[] =
|
static GDebugKey debug_keys[] =
|
||||||
{
|
{
|
||||||
@@ -82,29 +87,40 @@ bus_acquired_cb (GDBusConnection *connection,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
name_acquired_cb (GDBusConnection *connection,
|
name_acquired_cb (GDBusConnection *connection,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
g_debug ("Service name '%s' was acquired", name);
|
g_debug ("Service name '%s' was acquired", name);
|
||||||
|
name_acquired = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
name_lost_cb (GDBusConnection *connection,
|
name_lost_cb (GDBusConnection *connection,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
/* Note that we're not allowing replacement, so once the name acquired, the
|
int *ret = user_data;
|
||||||
* process won't lose it. */
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
g_warning ("Could not get the session bus. Make sure "
|
g_warning ("Could not get the session bus. Make sure "
|
||||||
"the message bus daemon is running!");
|
"the message bus daemon is running!");
|
||||||
} else {
|
*ret = EXIT_FAILURE;
|
||||||
if (connection)
|
goto out;
|
||||||
g_warning ("Could not acquire the '%s' service name", name);
|
|
||||||
else
|
|
||||||
g_debug ("DBus connection close");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
g_main_loop_quit (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,18 +128,36 @@ name_lost_cb (GDBusConnection *connection,
|
|||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
g_autoptr(GError) err = NULL;
|
g_autoptr (GError) err = NULL;
|
||||||
g_autoptr(GOptionContext) opt_context = NULL;
|
gboolean opt_verbose = FALSE, opt_replace = FALSE, opt_version = FALSE;
|
||||||
|
g_autoptr (GOptionContext) opt_context = NULL;
|
||||||
g_autoptr (FbdFeedbackManager) manager = NULL;
|
g_autoptr (FbdFeedbackManager) manager = NULL;
|
||||||
|
gboolean ret = EXIT_SUCCESS;
|
||||||
const char *debugenv;
|
const char *debugenv;
|
||||||
|
GOptionEntry options[] = {
|
||||||
|
{ "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 }
|
||||||
|
};
|
||||||
|
|
||||||
opt_context = g_option_context_new ("- A daemon to trigger event feedback");
|
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)) {
|
if (!g_option_context_parse (opt_context, &argc, &argv, &err)) {
|
||||||
g_warning ("%s", err->message);
|
g_warning ("%s", err->message);
|
||||||
g_clear_error (&err);
|
g_clear_error (&err);
|
||||||
return 1;
|
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 });
|
||||||
|
|
||||||
debugenv = g_getenv ("FEEDBACKD_DEBUG");
|
debugenv = g_getenv ("FEEDBACKD_DEBUG");
|
||||||
fbd_debug_flags = g_parse_debug_string (debugenv,
|
fbd_debug_flags = g_parse_debug_string (debugenv,
|
||||||
debug_keys,
|
debug_keys,
|
||||||
@@ -140,13 +174,16 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
g_bus_own_name (FB_DBUS_TYPE,
|
g_bus_own_name (FB_DBUS_TYPE,
|
||||||
FB_DBUS_NAME,
|
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,
|
bus_acquired_cb,
|
||||||
name_acquired_cb,
|
name_acquired_cb,
|
||||||
name_lost_cb,
|
name_lost_cb,
|
||||||
NULL,
|
&ret,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ if get_option('daemon')
|
|||||||
|
|
||||||
config_h = configuration_data()
|
config_h = configuration_data()
|
||||||
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
|
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'))
|
config_h.set('FBD_USE_MEDIA_ROLES', get_option('media-roles'))
|
||||||
configure_file(output: 'fbd-config.h', configuration: config_h)
|
configure_file(output: 'fbd-config.h', configuration: config_h)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user