From 42800a1cc8d751113b1a47d075fa497446b37164 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Fri, 29 Jul 2016 19:58:15 +0200 Subject: [PATCH] ALSA plugin: only run if /usr/sbin/alsactl exists Signed-off-by: Joachim Nilsson --- plugins/alsa-utils.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/alsa-utils.c b/plugins/alsa-utils.c index db3170dd..ff583c80 100644 --- a/plugins/alsa-utils.c +++ b/plugins/alsa-utils.c @@ -1,6 +1,6 @@ /* Save and restore ALSA sound settings using alsactl * - * Copyright (c) 2012 Joachim Nilsson + * Copyright (c) 2012-2016 Joachim Nilsson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,26 +26,28 @@ #include "../helpers.h" #include "../plugin.h" +#define ALSACTL "/usr/sbin/alsactl" + static void save(void *UNUSED(arg)) { - _d("Saving sound settings ..."); - run_interactive("/usr/sbin/alsactl -g store", "Saving sound settings"); + if (fexist(ALSACTL)) { + _d("Saving sound settings ..."); + run_interactive(ALSACTL " -g store", "Saving sound settings"); + } } static void restore(void *UNUSED(arg)) { - _d("Restoring sound settings ..."); - run_interactive("/usr/sbin/alsactl -g restore", "Restoring sound settings"); + if (fexist(ALSACTL)) { + _d("Restoring sound settings ..."); + run_interactive(ALSACTL " -g restore", "Restoring sound settings"); + } } static plugin_t plugin = { .name = __FILE__, - .hook[HOOK_BASEFS_UP] = { - .cb = restore - }, - .hook[HOOK_SHUTDOWN] = { - .cb = save - } + .hook[HOOK_BASEFS_UP] = { .cb = restore }, + .hook[HOOK_SHUTDOWN] = { .cb = save } }; PLUGIN_INIT(plugin_init)