wmbutton: Support for global conf file

This patch is based in the code wrote by Christian Aichinger
for the Debian distribution.

The patch includes the /etc/wmbutton.conf as global configuration
file. This file is readed if $home/.wmbutton don't exists.
This commit is contained in:
Rodolfo García Peñas (kix) 2012-08-20 20:28:45 +02:00 committed by Carlos R. Mafra
parent 83e2e0f2f9
commit de5602b957
2 changed files with 7 additions and 3 deletions

View file

@ -151,7 +151,9 @@ void err_mess(int err, char *str) {
fprintf(stderr,"Fail: XCreateGC\n");
exit(err);
case FAILCONF:
fprintf(stderr, "Fail: Can't Find configuration file %s\n",str);
fprintf(stderr, "Fail: Can't Find user or system configuration file.\n");
fprintf(stderr, "Fail: User Config: '%s'\n", str);
fprintf(stderr, "Fail: System Config: '%s'\n", CONFIGGLOBAL);
exit(err);
case FAILTMPL:
fprintf(stderr, "Fail: Can't Create 'template' Pixmap\n");
@ -200,7 +202,8 @@ char *Parse(int app) {
char *Ptr;
if ((fp = fopen(Config.configfile, "r")) == NULL)
err_mess(FAILCONF,Config.configfile);
if ((fp = fopen(CONFIGGLOBAL, "r")) == NULL)
err_mess(FAILCONF,Config.configfile);
while ((Ptr = fgets(Buf, BUFFER_SIZE, fp))) {
if (atoi(Buf) == app)

View file

@ -16,9 +16,10 @@
/****** Define Config File Info ***************************************/
#define CONFFILENAME "/.wmbutton" /* Default conf filename $HOME/.wmbutton */
#define CONFIGGLOBAL "/etc/wmbutton.conf" /* system configuration */
#define BUTTONFILENAME "/.wmbutton.xpm"
/****** Version / Release Number ***************************************/
/****** Version Number *************************************************/
#define VER 0 /* Version Number */
#define REL 6 /* Release Number */