Commit 9cb62dee authored by Guido Gunther's avatar Guido Gunther Committed by Guido Gunther
Browse files

Allow to lower the feedback level per application

We munge the application id the same way as it's done
for notifications so these can eventually move into
the same schema.
parent eec1556d
......@@ -126,6 +126,15 @@ Run feedbacks for event `message-new-instant` for 10 seconds:
_build/cli/fbcli -t 10 -E alarm-clock-elapsed
```
## Per app profiles
One can lower the feedback level of an individual application
via `GSettings`. E.g. for an app with app id `sm.puri.Phosh`
to set the profile to `quiet` do:
```
GSETTINGS_SCHEMA_DIR=_build/data/ gsettings set org.sigxcpu.feedbackd.application:/org/sigxcpu/feedbackd/application/sm-puri-phosh/ profile quiet
```
# Documentation
- [Libfeedback API](https://honk.sigxcpu.org/projects/feedbackd/doc/)
......
......@@ -17,14 +17,6 @@
</schema>
<schema id="org.sigxcpu.feedbackd.application">
<key name="application-id" type="s">
<default>''</default>
<summary>Application ID</summary>
<description>
The application that this policy is for.
</description>
</key>
<key name="profile" type="s">
<choices>
<choice value='full'/>
......
......@@ -21,6 +21,10 @@
#define FEEDBACKD_SCHEMA_ID "org.sigxcpu.feedbackd"
#define FEEDBACKD_KEY_PROFILE "profile"
#define APP_SCHEMA FEEDBACKD_SCHEMA_ID ".application"
#define APP_PREFIX "/org/sigxcpu/feedbackd/application/"
/**
* SECTION:fbd-feedback-manager
* @short_description: The manager processing incoming events
......@@ -84,6 +88,37 @@ device_changes (FbdFeedbackManager *self, gchar *action, GUdevDevice *device,
}
}
static gchar *
munge_app_id (const gchar *app_id)
{
gchar *id = g_strdup (app_id);
gint i;
g_strcanon (id,
"0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"-",
'-');
for (i = 0; id[i] != '\0'; i++)
id[i] = g_ascii_tolower (id[i]);
return id;
}
static FbdFeedbackProfileLevel
app_get_feedback_level (const gchar *app_id)
{
g_autofree gchar *profile = NULL;
g_autofree gchar *munged_app_id = munge_app_id (app_id);
g_autofree gchar *path = g_strconcat (APP_PREFIX, munged_app_id, "/", NULL);
g_autoptr (GSettings) setting = g_settings_new_with_path (APP_SCHEMA, path);
profile = g_settings_get_string (setting, FEEDBACKD_KEY_PROFILE);
g_debug ("%s uses app profile %s", app_id, profile);
return fbd_feedback_profile_level (profile);
}
static void
init_devices (FbdFeedbackManager *self)
{
......@@ -181,6 +216,7 @@ fbd_feedback_manager_handle_trigger_feedback (LfbGdbusFeedback *object,
FbdEvent *event;
GSList *feedbacks, *l;
gint event_id;
FbdFeedbackProfileLevel app_level, level;
g_debug ("Event '%s' for '%s'", arg_event, arg_app_id);
......@@ -211,7 +247,10 @@ fbd_feedback_manager_handle_trigger_feedback (LfbGdbusFeedback *object,
event = fbd_event_new (event_id, arg_app_id, arg_event, arg_timeout);
g_hash_table_insert (self->events, GUINT_TO_POINTER (event_id), event);
feedbacks = fbd_feedback_theme_lookup_feedback (self->theme, self->level, event);
/* If user configured a lower feedback level for this app honor that */
app_level = app_get_feedback_level (arg_app_id);
level = self->level > app_level ? app_level : self->level;
feedbacks = fbd_feedback_theme_lookup_feedback (self->theme, level, event);
if (feedbacks) {
for (l = feedbacks; l; l = l->next) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment