From ef5dd5abca40c420c0ea3325b8063bc13e3bda02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 6 Dec 2022 17:52:33 +0100 Subject: [PATCH 1/5] theme-expander: Also log initial theme file --- src/fbd-theme-expander.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fbd-theme-expander.c b/src/fbd-theme-expander.c index 2979e3b..3cce7af 100644 --- a/src/fbd-theme-expander.c +++ b/src/fbd-theme-expander.c @@ -133,7 +133,7 @@ fbd_theme_expander_find_device_theme_path (FbdThemeExpander *self, const char *t theme_path = fbd_theme_expander_find_theme_in_xdg_data (compatible); if (theme_path) { - g_info ("Loading themefile for compatible '%s' at: %s", compatible, theme_path); + g_debug ("Loading themefile for compatible '%s' at: %s", compatible, theme_path); return g_steal_pointer (&theme_path); } } @@ -367,6 +367,7 @@ fbd_theme_expander_load_theme_files (FbdThemeExpander *self, GError **err) } } + g_info ("Loading theme file at '%s'", self->theme_file); theme = fbd_feedback_theme_new_from_file (self->theme_file, err); if (theme == NULL) return NULL; From b64ce1290caf84dc184e796a2d1640ea5c9555ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 6 Dec 2022 17:23:23 +0100 Subject: [PATCH 2/5] Add theme validator Recursively loads a given theme file. --- meson.build | 2 + src/fbd-theme-validate.c | 89 ++++++++++++++++++++++++++++++++++++++++ src/meson.build | 9 ++++ 3 files changed, 100 insertions(+) create mode 100644 src/fbd-theme-validate.c diff --git a/meson.build b/meson.build index 3b63564..35b8f7a 100644 --- a/meson.build +++ b/meson.build @@ -28,6 +28,7 @@ endif prefix = get_option('prefix') +bindir = join_paths(prefix, get_option('bindir')) datadir = join_paths(prefix, get_option('datadir')) libdir = join_paths(prefix, get_option('libdir')) girdir = join_paths(prefix, join_paths(datadir, 'gir-1.0')) @@ -90,6 +91,7 @@ endif global_c_args = [ '-DFEEDBACKD_THEME_DIR="@0@"'.format(feedbackd_theme_dir), '-DLIBFEEDBACK_COMPILATION', + '-DFBD_VERSION="@0@"'.format(meson.project_version()), ] add_project_arguments( diff --git a/src/fbd-theme-validate.c b/src/fbd-theme-validate.c new file mode 100644 index 0000000..94ba171 --- /dev/null +++ b/src/fbd-theme-validate.c @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2022 Guido Günther + * + * SPDX-License-Identifier: GPL-3.0+ + */ + +#define G_LOG_DOMAIN "fbd" + +#include "fbd-theme-expander.h" + +#include + +#define BLURP "- A validator for feedback themes" + +static void +print_version (void) +{ + g_print ("%s %s " BLURP "\n", g_get_prgname(), FBD_VERSION); + exit (0); +} + +static void +log_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data) +{ + g_print ("%s\n", message); +} + + +int main(int argc, char *argv[]) +{ + g_autoptr (GError) err = NULL; + g_autoptr (GOptionContext) opt_context = NULL; + g_autoptr (FbdThemeExpander) expander = NULL; + g_autoptr (FbdFeedbackTheme) theme = NULL; + g_autofree char *theme_file = NULL; + const char *compatible = NULL; + gboolean version = FALSE; + GStrv args = NULL; + const char *compatibles[] = { NULL, NULL }; + int ret = EXIT_FAILURE; + + const GOptionEntry options [] = { + {"version", 0, 0, G_OPTION_ARG_NONE, &version, + "Show version information", NULL}, + {"compatible", 0, 0, G_OPTION_ARG_STRING, &compatible, + "The device compatible", NULL}, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args, NULL, NULL }, + G_OPTION_ENTRY_NULL, + }; + + opt_context = g_option_context_new ("THEME-FILE " BLURP); + 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 (version) { + print_version (); + } + + g_log_set_handler ("fbd-theme-expander", G_LOG_LEVEL_INFO | G_LOG_FLAG_RECURSION, + log_handler, NULL); + + if (!args) { + g_printerr ("%s: No theme file given\n", g_get_prgname ()); + g_printerr ("Try \"%s --help\" for more information.", g_get_prgname ()); + g_printerr ("\n"); + return 1; + } + + compatibles[0] = compatible; + theme_file = *args; + expander = fbd_theme_expander_new (compatibles, NULL, theme_file); + theme = fbd_theme_expander_load_theme_files (expander, &err); + if (theme == NULL) { + g_printerr ("Validation of '%s' failed \n\n", theme_file); + g_printerr ("error: %s\n\n", err->message); + } else { + g_print ("Validation successful.\n"); + ret = EXIT_SUCCESS; + } + + return ret; +} diff --git a/src/meson.build b/src/meson.build index 4a2db09..9a30fad 100644 --- a/src/meson.build +++ b/src/meson.build @@ -80,4 +80,13 @@ executable( install_dir: libexecdir, ) +executable( + 'fbd-theme-validate', + sources : ['fbd-theme-validate.c'], + include_directories : fbd_inc, + dependencies : fbd_dep, + install : true, + install_dir: bindir, +) + endif From 2e7483c775b6dc2085b4d4555b0021deea42f498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 7 Dec 2022 10:58:50 +0100 Subject: [PATCH 3/5] ci: Use bookworm image for package build too No need to fight against old glib and friends in PureOS --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6a71037..42cf82b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -65,9 +65,9 @@ test:native-debian-bookworm: variables: - $PKG_ONLY == "1" -package:deb-pureos-byzantium:arm64: +package:deb-debian-bookwarm:arm64: variables: - L5_DOCKER_IMAGE: pureos/byzantium + L5_DOCKER_IMAGE: debian:bookworm extends: .l5-build-debian-package tags: - librem5:arm64 From 584d4ddb6fed168135483c1e54f932318955ac8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 7 Dec 2022 11:44:05 +0100 Subject: [PATCH 4/5] doc: Convert manpages to rst This will make it more fun to add details and more manpages. --- debian/control | 3 +- doc/fbcli.rst | 49 +++++++++++++++++++++++ doc/fbcli.xml | 100 ---------------------------------------------- doc/feedbackd.rst | 42 +++++++++++++++++++ doc/feedbackd.xml | 76 ----------------------------------- doc/meson.build | 41 ++++++++++--------- meson_options.txt | 2 +- 7 files changed, 113 insertions(+), 200 deletions(-) create mode 100644 doc/fbcli.rst delete mode 100644 doc/fbcli.xml create mode 100644 doc/feedbackd.rst delete mode 100644 doc/feedbackd.xml diff --git a/debian/control b/debian/control index 1b504d9..1e14235 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,6 @@ Maintainer: Guido Günther Build-Depends: dbus, debhelper-compat (= 12), - docbook-xsl , dh-sequence-gir, gsettings-desktop-schemas , gi-docgen , @@ -17,8 +16,8 @@ Build-Depends: libjson-glib-dev, meson, pkg-config, + python3-docutils , valac, - xsltproc , Standards-Version: 4.4.0 Homepage: https://source.puri.sm/Librem5/feedbackd diff --git a/doc/fbcli.rst b/doc/fbcli.rst new file mode 100644 index 0000000..8d439a2 --- /dev/null +++ b/doc/fbcli.rst @@ -0,0 +1,49 @@ +.. _fbcli(1): + +===== +fbcli +===== + +------------------------ +Emit events to feedbackd +------------------------ + +SYNOPSIS +-------- +| **fbcli** [OPTIONS...] + + +DESCRIPTION +----------- + +``fbcli`` can be used to submit events to ``feedbackd`` to trigger +audio, visual or haptic feedback. + +OPTIONS +======= + +``-h``, ``--help`` + print help and exit + +``-E=EVENT``; ``--event=EVENT`` + Submit the given event to ``feedbackd``. Valid events are listes in + the event naming spec at + `https://source.puri.sm/Librem5/feedbackd/-/blob/main/Event-naming-spec-0.0.0.md`__ + +``-t=TIMEOUT``; ``--timeout=TIMEOUT`` + The timeout in seconds after which feedback for the given event should + be stopped. + +``-P=PROFILE``; ``--profile=PROFILE`` + The feedback profile (``full``, ``quiet``, ``silent``) + to use for the given event. If no event is specified then the global + feedback profile is changed. + +``-w=TIMEOUT``; ``--watch=TIMEOUT`` + Maximum timeout to wait for the feedback for the given event to end and + ``fbcli`` to exit. + +See also +======== + +``feedbackd(8)`` diff --git a/doc/fbcli.xml b/doc/fbcli.xml deleted file mode 100644 index 282e045..0000000 --- a/doc/fbcli.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - -fbcli -feedbackd - - -Developer -Guido -Günther - - - - - -fbcli -1 -User Commands - - - -fbcli -Emit events to feedbackd - - - - -fbcli -OPTION - - - -Description -fbcli can be used to submit events to feedbackd -to trigger audio, visual or haptic feedback. - - - -Options - - - -, - -print help and exit - - - - - - - - Submit the given event to feedbackd. Valid events are - listes in the event naming spec at - - - - - - - - - The timeout in seconds after which feedback for the given event should - be stopped. - - - - - - - - The feedback profile (full, quiet, silent) - to use for the given event. If no event is specified then the global - feedback profile is changed. - - - - - - - - Maximum timeout to wait for the feedback for the given event to end and - fbcli to exit. - - - - - - - - -See also - - -feedbackd -1 - - - - diff --git a/doc/feedbackd.rst b/doc/feedbackd.rst new file mode 100644 index 0000000..51fffa4 --- /dev/null +++ b/doc/feedbackd.rst @@ -0,0 +1,42 @@ +.. _feedbackd(8): + +========= +feedbackd +========= + +-------------------------------------- +A daemon to provide feedback on events +-------------------------------------- + +SYNOPSIS +-------- +| **feedbackd** [OPTIONS...] + + +DESCRIPTION +=========== + +``Feedbackd`` is a daemon that runs in the users session to trigger +event feedback such as playing a sound, trigger a haptic motor or blink +a LED. + +The feedback triggered by a given event is determined by the feedback theme in +use. Events are submitted via a DBus API. + +Any feedback triggered by a client via an event will be stopped latest when the +client disconnects from DBus. This makes sure all feedbacks get canceled if the +app that triggered it crashes. + +For details refer to the event and feedback theme specs at +``__ + +Options +======= + +``-h``, ``--help`` + print help and exit + +See also +======== + +``fbcli(1)`` diff --git a/doc/feedbackd.xml b/doc/feedbackd.xml deleted file mode 100644 index 6717cf6..0000000 --- a/doc/feedbackd.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - -feedbackd -feedbackd - - -Developer -Guido -Günther - - - - - -feedbackd -1 -User Commands - - - -feedbackd -A daemon to provide feedback on events - - - - -feedbackd -OPTION - - - -Description - - feedbackd is a daemon that runs in the users - session to trigger event feedback such as playing a sound, trigger - a haptic motor or blink a LED. - - - The feedback triggered by a given event is determined by the feedback - theme in use. Events are submitted via a DBus API. - - - Any feedback triggered by a client via an event will be stopped latest - when the client disconnects from DBus. This makes sure all feedbacks - get canceled if the app that triggered it crashes. - - - For details - refer to the event and feedback theme specs at - - - - -Options - - - -, - -print help and exit - - - - - - -See also - - -fbcli -1 - - - - diff --git a/doc/meson.build b/doc/meson.build index b4a2a27..fc72ed1 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -50,31 +50,30 @@ endif if get_option('man') manpages = [ - 'fbcli', - 'feedbackd', + ['fbcli', 1], + ['feedbackd', 8], ] - xsltproc = find_program('xsltproc', required : true) - xsltproc_command = [ - xsltproc, - '--nonet', - '--stringparam', 'man.output.quietly', '1', - '--stringparam', 'funcsynopsis.style', 'ansi', - '--stringparam', 'man.th.extra1.suppress', '1', - '--stringparam', 'man.authors.section.enabled', '0', - '--stringparam', 'man.copyright.section.enabled', '0', - '-o', '@OUTPUT@', - 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl', - '@INPUT@', + rst2man = find_program('rst2man', 'rst2man.py', required: false) + rst2man_flags = [ + '--syntax-highlight=none', ] - man1_dir = get_option('mandir') + '/man1' - foreach page : manpages - custom_target(page + '-man', - input : page + '.xml', - output : page + '.1', - command: xsltproc_command, + foreach manpage: manpages + man_name = manpage[0] + man_section = manpage[1] + + custom_target('man-@0@'.format(man_name), + input: '@0@.rst'.format(man_name), + output: '@0@.@1@'.format(man_name, man_section), + command: [ + rst2man, + rst2man_flags, + '@INPUT@', + ], + capture: true, install: true, - install_dir: man1_dir) + install_dir: get_option('mandir') / 'man@0@'.format(man_section), + ) endforeach endif diff --git a/meson_options.txt b/meson_options.txt index 4d1b4f0..59e2281 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -9,7 +9,7 @@ option('gtk_doc', description: 'Whether to generate the API reference for Libfeedback') option('man', type: 'boolean', value : false, - description : 'generate man pages (requires xsltproc)') + description : 'generate man pages (requires rst2man)') option('tests', type: 'boolean', value: true, description: 'Whether to compile unit tests') From 49f697b232928d28d329f46c955aa28e4d2f77b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 7 Dec 2022 12:27:56 +0100 Subject: [PATCH 5/5] doc: Add manual page for fbd-theme-validate --- doc/fbd-theme-validate.rst | 56 ++++++++++++++++++++++++++++++++++++++ doc/meson.build | 1 + 2 files changed, 57 insertions(+) create mode 100644 doc/fbd-theme-validate.rst diff --git a/doc/fbd-theme-validate.rst b/doc/fbd-theme-validate.rst new file mode 100644 index 0000000..c32391c --- /dev/null +++ b/doc/fbd-theme-validate.rst @@ -0,0 +1,56 @@ +.. _fbd-theme-validate(1): + +================== +fbd-theme-validate +================== + +------------------------- +Validate feedbackd themes +------------------------- + +SYNOPSIS +-------- +| **fbd-theme-validate** [OPTIONS...] + + +DESCRIPTION +----------- + +``fbd-theme-validate`` parses and validates the given feedbackd theme +file. If the theme specifies parent themes then these are parsed and +validates as well. + +OPTIONS +======= + +``-h``, ``--help`` + print help and exit + +``--version`` + print version information and exit + +``--compatible=COMPATIBLE`` + Specify the device compatible to use. Specify this if you validate a user + theme and want to simulate how it would look like on a device with compatible + ```COMPATIBLE```. + +EXAMPLES +======== + +Validate a custom theme in the users home directory the same way as it would be +loaded on a Librem 5: + +:: + + fbd-theme-validate --compatible=purism,librem5 ~/.config/feedbackd/themes/custom.json + +Validate the device theme for a OnePlus 6T: + +:: + + fbd-theme-validate /usr/share/feedbackd/themes/oneplus,fajita.json + +See also +======== + +``feedbackd(8)`` ``fbcli(1)`` diff --git a/doc/meson.build b/doc/meson.build index fc72ed1..dd16d8b 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -51,6 +51,7 @@ endif if get_option('man') manpages = [ ['fbcli', 1], + ['fbd-theme-validate', 1], ['feedbackd', 8], ]