summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2009-01-10 17:42:56 +0100
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2009-01-10 17:42:56 +0100
commitc23bc5538a6d8dbd52d06667d9706f05cb5a07d5 (patch)
treede48decdc0e563cb9c9fffd0359a2128f187577d /src
parentd758e5a8313c7a00fcde2e6eccf27f1b6d380c9b (diff)
downloadpianobar-c23bc5538a6d8dbd52d06667d9706f05cb5a07d5.tar.gz
pianobar-c23bc5538a6d8dbd52d06667d9706f05cb5a07d5.tar.bz2
pianobar-c23bc5538a6d8dbd52d06667d9706f05cb5a07d5.zip
Fix keyboard shortcuts if config file is missing
Diffstat (limited to 'src')
-rw-r--r--src/settings.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/settings.c b/src/settings.c
index 663a21a..daac4dc 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -115,7 +115,9 @@ void BarSettingsAppendKey (BarKeyShortcut_t *shortcut,
void BarSettingsRead (BarSettings_t *settings) {
/* FIXME: what is the max length of a path? */
char configfile[1024], key[256], val[256];
+ size_t i;
FILE *configfd;
+ BarKeyShortcut_t *curShortcut;
BarKeyShortcut_t defaultKeys[] = {
{'?', BarUiActHelp, NULL, "act_help", NULL},
{'+', BarUiActLoveSong, "love current song", "act_songlove",
@@ -150,13 +152,14 @@ void BarSettingsRead (BarSettings_t *settings) {
{'x', BarUiActSelectQuickMix, "select quickmix stations",
"act_stationselectquickmix", NULL},
};
- BarKeyShortcut_t *curShortcut;
- size_t i;
BarGetXdgConfigDir (PACKAGE "/config", configfile, sizeof (configfile));
if ((configfd = fopen (configfile, "r")) == NULL) {
- printf ("config file at %s not found\n", configfile);
- /* FIXME: what about setting default values? */
+ /* use default keyboard shortcuts */
+ for (i = 0; i < sizeof (defaultKeys) / sizeof (*defaultKeys);
+ i++) {
+ BarSettingsAppendKey (&defaultKeys[i], settings);
+ }
return;
}
@@ -205,6 +208,7 @@ void BarSettingsRead (BarSettings_t *settings) {
if (strcmp (defaultKeys[i].configKey, key) == 0) {
defaultKeys[i].key = val[0];
BarSettingsAppendKey (&defaultKeys[i], settings);
+ break;
}
}
}
@@ -222,7 +226,8 @@ void BarSettingsRead (BarSettings_t *settings) {
settings->enableScrobbling = 1;
}
- /* all actions available? append default actions if necessary */
+ /* append missing keyboard shortcuts to ensure the functionality is
+ * available */
for (i = 0; i < sizeof (defaultKeys) / sizeof (*defaultKeys); i++) {
char shortcutAvailable = 0;
curShortcut = settings->keys;