From 832d2c3ce5256859471179833f85562f94e9c2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 26 Jan 2025 13:55:07 +0100 Subject: [PATCH] cli: Allow to provide custom sound file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther --- cli/fbcli.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cli/fbcli.c b/cli/fbcli.c index c412ebf..6fab410 100644 --- a/cli/fbcli.c +++ b/cli/fbcli.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2020 Purism SPC - * 2023-2024 The Phosh Developers + * 2023-2025 The Phosh Developers * * SPDX-License-Identifier: GPL-3.0+ * Author: Guido Günther @@ -60,7 +60,11 @@ on_user_input (GIOChannel *channel, GIOCondition cond, LfbEvent *event) } static gboolean -trigger_event (const char *name, const gchar *profile, gboolean important, gint timeout) +trigger_event (const char *name, + const char *profile, + gboolean important, + gint timeout, + const char *sound_file) { g_autoptr (GError) err = NULL; g_autoptr (LfbEvent) event = NULL; @@ -79,6 +83,9 @@ trigger_event (const char *name, const gchar *profile, gboolean important, gint if (important) lfb_event_set_important (event, TRUE); + if (sound_file) + lfb_event_set_sound_file(event, sound_file); + g_signal_connect (event, "feedback-ended", (GCallback)on_feedback_ended, &success); if (!lfb_event_trigger_feedback (event, &err)) { g_print ("Failed to report event: %s\n", err->message); @@ -140,6 +147,7 @@ main (int argc, char *argv[0]) g_autoptr (GError) err = NULL; g_autofree char *profile = NULL; g_autofree char *app_id = NULL; + g_autofree char *sound_file = NULL; const char *name = NULL; gboolean success, important = FALSE; int watch = 30; @@ -157,6 +165,8 @@ main (int argc, char *argv[0]) "How long to watch for feedback longest", NULL}, {"app-id", 'A', 0, G_OPTION_ARG_STRING, &app_id, "Override used application id"}, + {"sound-file", 'S', 0, G_OPTION_ARG_STRING, &sound_file, + "Override the sound effect used by a file"}, { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } }; @@ -183,7 +193,7 @@ main (int argc, char *argv[0]) name = g_strdup (DEFAULT_EVENT); g_timeout_add_seconds (watch, (GSourceFunc)on_watch_expired, NULL); - success = trigger_event (name, profile, important, timeout); + success = trigger_event (name, profile, important, timeout, sound_file); } lfb_uninit ();