cli: Allow to set important hint

This commit is contained in:
Guido Günther
2024-04-20 13:21:56 +00:00
committed by Guido Günther
parent 716f296ab8
commit f575d32651
+10 -3
View File
@@ -1,5 +1,7 @@
/* /*
* Copyright (C) 2020 Purism SPC * Copyright (C) 2020 Purism SPC
* 2023-2024 The Phosh Developers
*
* 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>
*/ */
@@ -58,7 +60,7 @@ on_user_input (GIOChannel *channel, GIOCondition cond, LfbEvent *event)
} }
static gboolean static gboolean
trigger_event (const char *name, const gchar *profile, gint timeout) trigger_event (const char *name, const gchar *profile, gboolean important, gint timeout)
{ {
g_autoptr(GError) err = NULL; g_autoptr(GError) err = NULL;
g_autoptr(LfbEvent) event = NULL; g_autoptr(LfbEvent) event = NULL;
@@ -74,6 +76,9 @@ trigger_event (const char *name, const gchar *profile, gint timeout)
if (profile) if (profile)
lfb_event_set_feedback_profile (event, profile); lfb_event_set_feedback_profile (event, profile);
if (important)
lfb_event_set_important (event, TRUE);
g_signal_connect (event, "feedback-ended", (GCallback)on_feedback_ended, &success); g_signal_connect (event, "feedback-ended", (GCallback)on_feedback_ended, &success);
if (!lfb_event_trigger_feedback (event, &err)) { if (!lfb_event_trigger_feedback (event, &err)) {
g_print ("Failed to report event: %s\n", err->message); g_print ("Failed to report event: %s\n", err->message);
@@ -133,12 +138,14 @@ main (int argc, char *argv[0])
g_autofree char *profile = NULL; g_autofree char *profile = NULL;
g_autofree char *app_id = NULL; g_autofree char *app_id = NULL;
const char *name = NULL; const char *name = NULL;
gboolean success; gboolean success, important = FALSE;
int watch = 30; int watch = 30;
int timeout = -1; int timeout = -1;
const GOptionEntry options [] = { const GOptionEntry options [] = {
{"event", 'E', 0, G_OPTION_ARG_STRING, &name, {"event", 'E', 0, G_OPTION_ARG_STRING, &name,
"Event name. (default: " DEFAULT_EVENT ").", NULL}, "Event name. (default: " DEFAULT_EVENT ").", NULL},
{"important", 'I', 0, G_OPTION_ARG_NONE, &important,
"Whether to set the important hint", NULL},
{"timeout", 't', 0, G_OPTION_ARG_INT, &timeout, {"timeout", 't', 0, G_OPTION_ARG_INT, &timeout,
"Run feedback for timeout seconds", NULL}, "Run feedback for timeout seconds", NULL},
{"profile", 'P', 0, G_OPTION_ARG_STRING, &profile, {"profile", 'P', 0, G_OPTION_ARG_STRING, &profile,
@@ -173,7 +180,7 @@ main (int argc, char *argv[0])
name = g_strdup (DEFAULT_EVENT); name = g_strdup (DEFAULT_EVENT);
g_timeout_add_seconds (watch, (GSourceFunc)on_watch_expired, NULL); g_timeout_add_seconds (watch, (GSourceFunc)on_watch_expired, NULL);
success = trigger_event (name, profile, timeout); success = trigger_event (name, profile, important, timeout);
} }
lfb_uninit (); lfb_uninit ();