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.
This commit is contained in:
Geoffrey D. Bennett
2024-03-31 03:11:57 +10:30
parent 2ddede4d3f
commit db0929bd08

View File

@@ -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)