From db0929bd0871fcdf85f3f870c6c772f14e3a561e Mon Sep 17 00:00:00 2001 From: "Geoffrey D. Bennett" Date: Sun, 31 Mar 2024 03:11:57 +1030 Subject: [PATCH] Search $PATH and /usr/sbin for alsactl The path to alsactl was previously hardcoded because some distros put it in /usr/sbin but don't include that directory in $PATH. Unfortunately other distros put alsactl elsewhere. Let's search $PATH and /usr/sbin to cater for both. Fixes #101. --- src/file.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/file.c b/src/file.c index f43a62a..3844abf 100644 --- a/src/file.c +++ b/src/file.c @@ -14,9 +14,15 @@ static void run_alsactl( ) { GtkWindow *w = GTK_WINDOW(card->window_main); + gchar *alsactl_path = g_find_program_in_path("alsactl"); + + if (!alsactl_path) + alsactl_path = g_strdup("/usr/sbin/alsactl"); + gchar *argv[] = { - "/usr/sbin/alsactl", cmd, card->device, "-f", fn, NULL + alsactl_path, cmd, card->device, "-f", fn, NULL }; + gchar *stdout; gchar *stderr; gint exit_status; @@ -52,6 +58,7 @@ static void run_alsactl( g_free(error_message); done: + g_free(alsactl_path); g_free(stdout); g_free(stderr); if (error)