diff --git a/doc/toxic.conf.5 b/doc/toxic.conf.5 index 60edd8b..187a95a 100644 --- a/doc/toxic.conf.5 +++ b/doc/toxic.conf.5 @@ -252,6 +252,8 @@ tox = { .br }; .br +// To disable a sound set the path to "silent" +.br sounds = { .br error="__DATADIR__/sounds/Error.wav"; diff --git a/misc/toxic.conf.example b/misc/toxic.conf.example index 889ddd0..889b139 100644 --- a/misc/toxic.conf.example +++ b/misc/toxic.conf.example @@ -37,6 +37,7 @@ tox = { // download_path="/home/USERNAME/Downloads/"; }; +// To disable a sound set the path to "silent" sounds = { error="__DATADIR__/sounds/Error.wav"; self_log_in="__DATADIR__/sounds/LogIn.wav"; diff --git a/src/settings.c b/src/settings.c index 4ab5276..408c7ee 100644 --- a/src/settings.c +++ b/src/settings.c @@ -40,6 +40,8 @@ #define PACKAGE_DATADIR "." #endif +#define NO_SOUND "silent" + const struct _ui_strings { const char* self; const char* timestamps; @@ -202,44 +204,64 @@ int settings_load(struct user_settings *s, const char *patharg) #ifdef _SOUND_NOTIFY if ((setting = config_lookup(cfg, sound_strings.self)) != NULL) { if ( (config_setting_lookup_string(setting, sound_strings.error, &str) != CONFIG_TRUE) || - !set_sound(error, str) ) - set_sound(error, PACKAGE_DATADIR "/sounds/Error.wav"); + !set_sound(error, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(error, PACKAGE_DATADIR "/sounds/Error.wav"); + } if ( !config_setting_lookup_string(setting, sound_strings.user_log_in, &str) || - !set_sound(user_log_in, str) ) - set_sound(user_log_in, PACKAGE_DATADIR "/sounds/ContactLogsIn.wav"); + !set_sound(user_log_in, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(user_log_in, PACKAGE_DATADIR "/sounds/ContactLogsIn.wav"); + } if ( !config_setting_lookup_string(setting, sound_strings.self_log_in, &str) || - !set_sound(self_log_in, str) ) - set_sound(self_log_in, PACKAGE_DATADIR "/sounds/LogIn.wav"); - + !set_sound(self_log_in, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(self_log_in, PACKAGE_DATADIR "/sounds/LogIn.wav"); + } + if ( !config_setting_lookup_string(setting, sound_strings.user_log_out, &str) || - !set_sound(user_log_out, str) ) - set_sound(user_log_out, PACKAGE_DATADIR "/sounds/ContactLogsOut.wav"); - + !set_sound(user_log_out, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(user_log_out, PACKAGE_DATADIR "/sounds/ContactLogsOut.wav"); + } + if ( !config_setting_lookup_string(setting, sound_strings.self_log_out, &str) || - !set_sound(self_log_out, str) ) - set_sound(self_log_out, PACKAGE_DATADIR "/sounds/LogOut.wav"); + !set_sound(self_log_out, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(self_log_out, PACKAGE_DATADIR "/sounds/LogOut.wav"); + } if ( !config_setting_lookup_string(setting, sound_strings.call_incoming, &str) || - !set_sound(call_incoming, str) ) - set_sound(call_incoming, PACKAGE_DATADIR "/sounds/IncomingCall.wav"); + !set_sound(call_incoming, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(call_incoming, PACKAGE_DATADIR "/sounds/IncomingCall.wav"); + } if ( !config_setting_lookup_string(setting, sound_strings.call_outgoing, &str) || - !set_sound(call_outgoing, str) ) - set_sound(call_outgoing, PACKAGE_DATADIR "/sounds/OutgoingCall.wav"); + !set_sound(call_outgoing, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(call_outgoing, PACKAGE_DATADIR "/sounds/OutgoingCall.wav"); + } if ( config_setting_lookup_string(setting, sound_strings.generic_message, &str) || - !set_sound(generic_message, str) ) - set_sound(generic_message, PACKAGE_DATADIR "/sounds/NewMessage.wav"); + !set_sound(generic_message, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(generic_message, PACKAGE_DATADIR "/sounds/NewMessage.wav"); + } if ( !config_setting_lookup_string(setting, sound_strings.transfer_pending, &str) || - !set_sound(transfer_pending, str) ) - set_sound(transfer_pending, PACKAGE_DATADIR "/sounds/TransferPending.wav"); + !set_sound(transfer_pending, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(transfer_pending, PACKAGE_DATADIR "/sounds/TransferPending.wav"); + } if ( !config_setting_lookup_string(setting, sound_strings.transfer_completed, &str) || - !set_sound(transfer_completed, str) ) - set_sound(transfer_completed, PACKAGE_DATADIR "/sounds/TransferComplete.wav"); + !set_sound(transfer_completed, str) ) { + if (strcasecmp(str, NO_SOUND)) + set_sound(transfer_completed, PACKAGE_DATADIR "/sounds/TransferComplete.wav"); + } } else { set_sound(error, PACKAGE_DATADIR "/sounds/Error.wav");