[Feature] lastfm_scrobbler add option to set beep volume level

Change-Id: Id045f0f844b67f07ba5cd47d084f5d8f1841dad8
This commit is contained in:
William Wilgus 2023-03-20 18:44:07 -04:00
parent a0a59ab610
commit 977bc698db

View file

@ -101,6 +101,7 @@ static struct
static struct static struct
{ {
int savepct; int savepct;
int beeplvl;
bool playback; bool playback;
bool verbose; bool verbose;
} gConfig; } gConfig;
@ -110,6 +111,7 @@ static struct configdata config[] =
{TYPE_INT, 0, 100, { .int_p = &gConfig.savepct }, "SavePct", NULL}, {TYPE_INT, 0, 100, { .int_p = &gConfig.savepct }, "SavePct", NULL},
{TYPE_BOOL, 0, 1, { .bool_p = &gConfig.playback }, "Playback", NULL}, {TYPE_BOOL, 0, 1, { .bool_p = &gConfig.playback }, "Playback", NULL},
{TYPE_BOOL, 0, 1, { .bool_p = &gConfig.verbose }, "Verbose", NULL}, {TYPE_BOOL, 0, 1, { .bool_p = &gConfig.verbose }, "Verbose", NULL},
{TYPE_INT, 0, 10, { .int_p = &gConfig.beeplvl }, "BeepLvl", NULL},
}; };
const int gCfg_sz = sizeof(config)/sizeof(*config); const int gCfg_sz = sizeof(config)/sizeof(*config);
/****************** config functions *****************/ /****************** config functions *****************/
@ -118,6 +120,7 @@ static void config_set_defaults(void)
gConfig.savepct = 50; gConfig.savepct = 50;
gConfig.playback = false; gConfig.playback = false;
gConfig.verbose = true; gConfig.verbose = true;
gConfig.beeplvl = 10;
} }
static int config_settings_menu(void) static int config_settings_menu(void)
@ -135,6 +138,7 @@ static int config_settings_menu(void)
ID2P(LANG_RESUME_PLAYBACK), ID2P(LANG_RESUME_PLAYBACK),
"Save Threshold", "Save Threshold",
"Verbose", "Verbose",
"Beep Level",
ID2P(VOICE_BLANK), ID2P(VOICE_BLANK),
ID2P(LANG_CANCEL_0), ID2P(LANG_CANCEL_0),
ID2P(LANG_SAVE_EXIT)); ID2P(LANG_SAVE_EXIT));
@ -153,12 +157,15 @@ static int config_settings_menu(void)
case 2: case 2:
rb->set_bool("Verbose", &gConfig.verbose); rb->set_bool("Verbose", &gConfig.verbose);
break; break;
case 3: /*sep*/ case 3:
rb->set_int("Beep Level", "", UNIT_INT,
&gConfig.beeplvl, NULL, 1, 0, 10, NULL);
case 4: /*sep*/
continue; continue;
case 4: case 5:
return -1; return -1;
break; break;
case 5: case 6:
{ {
int res = configfile_save(CFG_FILE, config, gCfg_sz, CFG_VER); int res = configfile_save(CFG_FILE, config, gCfg_sz, CFG_VER);
if (res >= 0) if (res >= 0)
@ -469,7 +476,8 @@ void thread(void)
/*fall through*/ /*fall through*/
case EV_STARTUP: case EV_STARTUP:
events_register(); events_register();
rb->beep_play(1500, 100, 1000); if (gConfig.beeplvl > 0)
rb->beep_play(1500, 100, 100 * gConfig.beeplvl);
break; break;
case SYS_POWEROFF: case SYS_POWEROFF:
case SYS_REBOOT: case SYS_REBOOT:
@ -595,6 +603,8 @@ enum plugin_status plugin_start(const void* parameter)
if (scrobbler_init() < 0) if (scrobbler_init() < 0)
return PLUGIN_ERROR; return PLUGIN_ERROR;
config_set_defaults();
if (configfile_load(CFG_FILE, config, gCfg_sz, CFG_VER) < 0) if (configfile_load(CFG_FILE, config, gCfg_sz, CFG_VER) < 0)
{ {
/* If the loading failed, save a new config file */ /* If the loading failed, save a new config file */