fookb: add default parameter values.

If there is no config-file in $HOME, use a default parameter value
instead of complaining and exiting.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
This commit is contained in:
Jeremy Sowden 2019-10-03 23:06:55 +01:00 committed by Carlos R. Mafra
parent f6531a0130
commit d467d2c22e
2 changed files with 43 additions and 14 deletions

View file

@ -19,16 +19,40 @@ char *read_param(char *string)
/* Command line parameters take precedence over all */
if (!strcmp(string, "Icon1") && icon1)
return icon1;
if (!strcmp(string, "Icon2") && icon2)
return icon2;
if (!strcmp(string, "Icon3") && icon3)
return icon3;
if (!strcmp(string, "Icon4") && icon4)
return icon4;
if (!strcmp(string, "IconBoom") && iconboom)
return iconboom;
if (!strcmp(string, "Icon1")) {
if (icon1)
return icon1;
result = DEFAULT_ICON1;
}
if (!strcmp(string, "Icon2")) {
if (icon2)
return icon2;
result = DEFAULT_ICON2;
}
if (!strcmp(string, "Icon3")) {
if (icon3)
return icon3;
result = DEFAULT_ICON3;
}
if (!strcmp(string, "Icon4")) {
if (icon4)
return icon4;
result = DEFAULT_ICON4;
}
if (!strcmp(string, "IconBoom")) {
if (iconboom)
return iconboom;
result = DEFAULT_ICON_BOOM;
}
if (!strcmp(string, "Sound"))
result = DEFAULT_SOUND;
if (!strcmp(string, "Command"))
result = DEFAULT_COMMAND;
/*
* Here we start the game with property lists.
@ -44,9 +68,7 @@ char *read_param(char *string)
wfree(path);
if (!pl) {
lputs("Cannot open config file: ");
lputs(DEFAULTS_FILE);
exit(EXIT_FAILURE);
return result;
}
tmp = WMCreatePLString(string);

View file

@ -8,8 +8,15 @@
#ifndef PARAMS_H
#define PARAMS_H
#define DEFAULTS_FILE "~/.fookb"
#define DEFAULTS_FILE "~/.fookb"
#define DEFAULT_ICON1 "/usr/local/share/fookb/lat.xpm"
#define DEFAULT_ICON2 "/usr/local/share/fookb/rus.xpm"
#define DEFAULT_ICON3 "/usr/local/share/fookb/3.xpm"
#define DEFAULT_ICON4 "/usr/local/share/fookb/4.xpm"
#define DEFAULT_ICON_BOOM "/usr/local/share/fookb/boom.xpm"
#define DEFAULT_SOUND "Yes"
#define DEFAULT_COMMAND "/usr/bin/play /usr/local/share/fookb/beep_spring.au"
char *read_param(char *);