Commit Graph
92 Commits
Author SHA1 Message Date
Guido Günther 83091be25d feedback-manager: Handle theme gsetting
Update the theme when the gsetting changes
2022-12-11 17:34:38 +01:00
Guido Günther f5757045aa manager: Don't load theme in constructor
Loading the theme can trigger calls to
fbd_feedback_manager_get_default() which then results in an endless look
as the object isn't fully initialized in constructed. Instead do
the setup in main() which has the advantage that the manager's life
cycle becomes more obvious too.
2022-12-11 17:34:38 +01:00
Guido Günther a75cdbbc59 theme-expander: Allow to set the theme to expand 2022-12-11 17:34:38 +01:00
Guido Günther 242519498a Recursively load themes
Themes (other than the default theme) can specify a `parent-name` in the
json file. This theme will be used as a base for the theme. Events and
profiles of the children override those in the parents.

For this we move the lookup code into it's separate class and also add
tests.

Closes: #38
2022-12-11 17:34:38 +01:00
Guido Günther 34f8733b2b build: Don't include main in lib
For that move the error quark to a separate file.
2022-12-08 10:05:47 +01:00
Guido Günther ba91939c85 Add gmobile library 2022-12-08 10:05:47 +01:00
Guido Günther ada82a0ed1 feedback-theme: Allow to get and set parent theme name
If set the parent theme's feedbackd and profiles should be merged into
this theme.
2022-12-08 10:05:47 +01:00
Guido Günther e10b2cc150 feedback-theme: Allow to update theme
New profiles are added, existing profiles updated. This will
allow to merge themes.
2022-12-08 10:05:47 +01:00
Guido Günther d7f97dca51 feedback-profile: Allow to update profiles
Allow to add feedbacks from a profile to another one
2022-12-08 10:05:47 +01:00
Guido Günther 29bbe38fb3 feedback-dummy: Add getter for duration
Useful in tests
2022-12-08 10:05:47 +01:00
Guido Günther 53677e29ef feedback-profile: Document hash types 2022-12-08 10:05:47 +01:00
Guido Günther 82a8b91096 feedback-theme: Allow to set name 2022-12-08 10:05:47 +01:00
Guido Günther 1d21bfa0dc feedback-theme: Use getter
Ensures we stay consistent with future changes
2022-12-08 10:05:47 +01:00
Guido Günther e6f1c351e2 feedback-theme: Fix indentation 2022-12-08 10:05:47 +01:00
Guido Günther c9404d871e feedback-theme: No need for constructed
We can do all that in init
2022-12-08 10:05:47 +01:00
Guido Günther 3c124e8ecd feedback-vibra: Fix indentation 2022-12-08 10:05:47 +01:00
Guido Günther 2e29f5baf1 fbd: Fix indentation 2022-11-11 09:50:19 +00:00
Guido Günther db13fc031d manager: Use FEEDBACKD_UDEV_ATTR
It was introduced in

a5b4f99 ("feedbackd: Support visual feedback via LEDs")
2022-11-11 09:50:19 +00:00
Evangelos Ribeiro Tzaras d739a33a5f feedback-manager: Complete DBus call before emitting "feedback-ended"
See previous commit adding the test (that now passes) for the reasoning.

Fixes: #62
2022-11-09 11:54:46 +01:00
Evangelos Ribeiro Tzaras 94001bba78 feedback-manager: Use guint for event id
The ID is inserted into a hashtable below with GUINT_TO_POINTER
and is set using self->next_id++ with next_id also being a guint,
so change the type accordingly.
2022-11-03 19:31:57 +01:00
Luca Weiss e16202eeb5 fbd-dev-leds: support for multicolor LEDs
Add support for multicolor LEDs as supported by the kernel.
Used by Qualcomm devices such as SHIFT 6mq, OnePlus 6, etc.

Documentation:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/sysfs-class-led-multicolor

Co-Developed-by: Dylan Van Assche <me@dylanvanassche.be>
2022-05-17 20:04:23 +02:00
Dylan Van Assche 510f1b6d6e fbd-dev-leds: rename var to max_brightness_percentage
Improve readability of the code.
2022-05-17 20:02:58 +02:00
Dylan Van Assche 572a027fa6 fbd-dev-leds: use define for max_brightness
All other attributes use a define, let's do the same for max_brightness.
2022-05-17 20:02:51 +02:00
Guido Günther 16bf78b5a4 manager: Don't sync DBus profile property
This will happen in on_feedbackd_setting_changed() once the
profile was adjusted.
2022-02-04 19:03:00 +01:00
Guido Günther 5c8cbfca39 manager: Sync profile with setting on startup
On startup the GSetting is the relevant input for selecting the profle.

Closes: #52
2022-02-04 19:03:00 +01:00
Guido Günther 2be41ec0ef manager: Set initial profile to unknown
This makes sure we sync the profile with the DBus property after
fetching it from GSettings.
2022-02-04 19:03:00 +01:00
Evangelos Ribeiro Tzaras 5f28638eec fbd-event: Fix return value for fbd_event_get_sender 2021-10-29 17:56:28 +02:00
Pablo Correa Gómez 8e9bbd9d4c Reload theme on SIGHUP signal
Fixes #28

Allows for users/applications to request a theme reload
by sending SIGHUP signal to the daemon.
2021-10-19 14:24:04 +00:00
Guido Günther c88c6cfff5 fbd-dev-sound: Delay sending ended signal
Remove the feedback and the associated callback data before invoking the
callback (which then triggers FbdFeebackBased:ended) since we otherwise
remove the data from the currently playing sound from the hash table
instead of removing the data from the sound that just finished playing.

Call flow for a repeating sound before:

  on_sound_play_finished_callback()
    data->callback()
      fbd_feedback_get_ended()
        on_fb_ended()
          fbd_feedback_run()
            g_hash_table_insert(..., feedback, data)
            fbd_dev_sound_play()
              gsound_context_play_full() [async]
    g_hash_table_remove (..., data->feedback) <- removes wrong feedback

So (since the feedback is still the same but only the callback data
changes) we end up removing the data from the currently playing sound
from the hash table and any calls to fbd_dev_sound_stop() would fail
to find data and hence not cancel the playing sound.

Call flow for a repeating sound now:

  on_sound_play_finished_callback()
    g_hash_table_remove (..., data->feedback)
    data->callback()
      fbd_feedback_get_ended()
        on_fb_ended()
          fbd_feedback_run()
            g_hash_table_insert(..., feedback, data)
            fbd_dev_sound_play()
              gsound_context_play_full() [async]

So we remove the data of the currently playing sound before adding
the feedback to the hash table again. No ownership is transfered to
the hash table so no cleanusp need to be changed.

Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/46
2021-10-15 15:12:55 +02:00
Guido Günther 05bd9ae0cb fbd-dev-sounce: Name data consistently
We name it `data` elsewhere. Don't call it `object` in one function.
2021-10-15 15:10:31 +02:00
Guido Günther 48c05be29d fbd-dev-sound: Rename cancellable to cancel
The current name is just confusing
2021-10-15 15:10:31 +02:00
Evangelos Ribeiro Tzaras 1ed04e409d fbd-dev-sound: Honour sound theme name for all GNOME based desktops
Phosh recently changed to XDG_CURRENT_DESKTOP=GNOME:Phosh and has since stopped
using the configured theme and instead used the fallback freedesktop theme.

Closes #41
2021-07-23 04:35:21 +02:00
Pablo Correa Gómez 3802c89e67 feedback-manager: Search for default theme under XDG_CONFIG_HOME first
This would allow users to create their own feedback profiles
without editing system files or using root privileges

Signed-off-by: Pablo Correa Gómez <ablocorrea@hotmail.com>
2021-06-08 16:17:41 +02:00
Andreas Hartmann 1c53464090 fbd-feedback-manager: Make sure theme path components are '/' separated
Previously, assembly of the theme paths for custom paths (based on
`XDG_DATA_DIRS`) was performed using `g_strconcat`, which produced erroneous
file paths with missing path separators due to a typo in the code.

Instead, make use of `g_build_filename` to assemble the theme paths from
`XDG_DATA_DIRS` to look for custom themes, which automatically introduces
host-specific path separators between individual path components. This
introduces another temporary variable to ensure that the filename (which is
itself assembled from a name and the file ending) isn't mangled by introduction
of a path separator between these two "parts".
2021-05-31 11:31:30 +02:00
Evangelos Ribeiro Tzaras 63eba5d715 fbd-dev-sound: whitespace 2021-05-04 10:54:46 +02:00
Guido Günther 678ae7a22d fbd-feedback-manager: Don't leak device list 2021-04-26 09:34:23 +00:00
Guido Günther 9c9f767986 fbd-feedback-manager: Don't leak config_path
It's assigned multiple times.
2021-04-26 09:34:23 +00:00
Guido Günther 437b19edd4 fbd-feedback-manager: Make sure to dispose sound device as well
Fixes another leak.
2021-04-26 09:34:23 +00:00
Guido Günther 11aa38baba fbd-dev-sound: Use correct cleanup for hash table
This went unnoticed since the manager forgot to cleanup
this at all (see follow up commit).
2021-04-26 09:34:23 +00:00
Guido Günther 4c30fafc6e fbd-dev-leds: Use automatic deep cleanup for device list
The current logic was fragile and failed e.g. when the
FEEDBACKD_UDEV_VAL_LED would not match leaking the dev since the
g_object_unref() at the end of the loop was never hit.

Prevent that with automatic cleanup and explicitly ref'ing the
devs we want to use.
2021-04-26 09:34:23 +00:00
Guido Günther 957fa1be83 fbd-dev-leds: Don't leak color
g_ascii_strdown() creates a copy already.
2021-04-26 09:34:23 +00:00
Guido Günther d8f944ed30 fbd-dev-leds: Don't leak enum_name
g_enum_to_string() is transfer full.
2021-04-26 09:34:23 +00:00
Guido Günther d7419f37a1 fbd-dev-leds: Free actual FbdDevLed as well
So far we only unref'ed the device.
2021-04-26 09:34:23 +00:00
Guido Günther 9169d8b23b fbd-feedback-theme: Don't leak JSON node 2021-04-26 09:34:23 +00:00
Guido Günther 04648dcf27 feedback-manager: Track DBus clients and end feedbacks if they go away
When the client goes away we build up a list of events to end feedback
for to make sure the hash table isn't modified in place. tThe alternative
approach would be to disconnect the on_event_feedbacks_ended handler,
duplicate the DBus signal emission and use g_hash_table_foreach_remove
but that looks less robust than using the same code path.

Closes: #25
2021-04-22 14:44:30 +02:00
Guido Günther dc8c8c9594 fbd-manager: Keep DBus sender around 2021-04-22 14:43:30 +02:00
Guido Günther 66bcb31a0e fbd-event: Add sender property
This allows us to store the DBus sender
2021-04-22 14:43:30 +02:00
Guido Günther abab07a2f2 event: Remove 'g' prefix from common C types
This matchs phosh's style.
2021-04-22 14:43:30 +02:00
Guido Günther da537aff1e event: Make log-domain match source file name 2021-04-22 14:43:30 +02:00
Clayton Craft 2674654c39 fbd-ledctrl: fix matching of trigger in list of triggers
If the trigger is the last thing in sysfs_path/LED_TRIGGER_ATTR, then
the new-line at the end of the output causes g_strv_contains to fail to
find the trigger in the list. This strips the new-line before splitting
the output into a list for searching.

You can see the problem this patch fixes with the librem 5, by:

$ rmmod ledtrig-timer     # or whatever is listed at the end, so 'pattern' is the last thing
$ cat /sys/devices/platform/pwmleds/leds/blue:status/trigger
[none] kbd-scrolllock ... pattern
$ fbd-ledctrl -p /sys/devices/platform/pwmleds/leds/blue:status -t pattern
Failed to set perms of /sys/devices/platform/pwmleds/leds/blue:status/pattern to 101: No such file or directory
$ modprobe ledtrig-timer
$ cat /sys/devices/platform/pwmleds/leds/blue:status/trigger
[none] kbd-scrolllock ... pattern timer
$ fbd-ledctrl -p /sys/devices/platform/pwmleds/leds/blue:status -t pattern
<success>
2021-03-20 00:26:24 -07:00