Wmfs: Add -C option to load a configuration file
This commit is contained in:
parent
f252636744
commit
702d6065fa
12
src/config.c
12
src/config.c
@ -525,18 +525,16 @@ init_conf(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
sprintf(final_path, "%s/%s", _strdup(getenv("HOME")), _strdup(FILE_NAME));
|
||||
|
||||
cfg = cfg_init(opts, CFGF_NONE);
|
||||
ret = cfg_parse(cfg, final_path);
|
||||
ret = cfg_parse(cfg, conf.confpath);
|
||||
|
||||
if(ret == CFG_FILE_ERROR || ret == CFG_PARSE_ERROR)
|
||||
{
|
||||
fprintf(stderr, "WMFS: parsing configuration file (%s) failed\n", final_path);
|
||||
sprintf(final_path, "%s/wmfs/wmfsrc", XDG_CONFIG_DIR);
|
||||
fprintf(stderr, "Use the default configuration (%s).\n", final_path);
|
||||
fprintf(stderr, "WMFS: parsing configuration file (%s) failed\n", conf.confpath);
|
||||
sprintf(conf.confpath, "%s/wmfs/wmfsrc", XDG_CONFIG_DIR);
|
||||
fprintf(stderr, "Use the default configuration (%s).\n", conf.confpath);
|
||||
cfg = cfg_init(opts, CFGF_NONE);
|
||||
ret = cfg_parse(cfg, final_path);
|
||||
ret = cfg_parse(cfg, conf.confpath);
|
||||
}
|
||||
|
||||
conf_init_func_list();
|
||||
|
||||
@ -32,10 +32,7 @@
|
||||
|
||||
#include "wmfs.h"
|
||||
|
||||
#define FILE_NAME ".config/wmfs/wmfsrc"
|
||||
|
||||
cfg_t *cfg, *cfgtmp;
|
||||
char final_path[128];
|
||||
|
||||
cfg_opt_t misc_opts[] =
|
||||
{
|
||||
|
||||
@ -278,6 +278,9 @@ typedef struct
|
||||
/* Configuration structure */
|
||||
typedef struct
|
||||
{
|
||||
/* Configuration file path */
|
||||
char confpath[512];
|
||||
|
||||
/* Misc option */
|
||||
char *font;
|
||||
Bool raisefocus;
|
||||
|
||||
12
src/wmfs.c
12
src/wmfs.c
@ -345,9 +345,10 @@ main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
argv_global = _strdup(argv[0]);
|
||||
argv_global = _strdup(argv[0]);
|
||||
sprintf(conf.confpath, "%s/"DEF_CONF, getenv("HOME"));
|
||||
|
||||
while ((i = getopt(argc, argv, "hvic:s:g:")) != -1)
|
||||
while((i = getopt(argc, argv, "hvic:s:g:C:")) != -1)
|
||||
{
|
||||
|
||||
/* For options who need WMFS running */
|
||||
@ -362,7 +363,8 @@ main(int argc, char **argv)
|
||||
{
|
||||
case 'h':
|
||||
default:
|
||||
printf("usage: %s [-ihv] [-c <uicb function> <cmd> ] [-g <argument>] [-s <string>]\n"
|
||||
printf("usage: %s [-ihv] [-C <file>] [-c <uicb function> <cmd> ] [-g <argument>] [-s <string>]\n"
|
||||
" -C <file> Load a configuration file\n"
|
||||
" -c <uicb_function> <cmd> Execute an uicb function to control WMFS\n"
|
||||
" -g <argument> Show information about wmfs status\n"
|
||||
" -s <string> Set the bar(s) statustext\n"
|
||||
@ -386,6 +388,10 @@ main(int argc, char **argv)
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
strcpy(conf.confpath, optarg);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
exec_uicb_function(argv[2], ((argv[3]) ? argv[3] : NULL));
|
||||
XCloseDisplay(dpy);
|
||||
|
||||
@ -97,6 +97,7 @@
|
||||
#define IFREE(x) if(x) free(x)
|
||||
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define deb(p) fprintf(stderr, "debug: %d\n", (p))
|
||||
#define DEF_CONF ".config/wmfs/wmfsrc"
|
||||
#define PAD conf.pad
|
||||
|
||||
/* barwin.c */
|
||||
|
||||
7
wmfs.1
7
wmfs.1
@ -13,13 +13,18 @@
|
||||
.SH "NAME"
|
||||
wmfs \- Window Manager From Scratch
|
||||
.SH "SYNOPSIS"
|
||||
\fBwmfs\fR [\fB\-v\fR] [\fB\-h\fR] [\fB\-i\fR] [\fB\-c <uicb_function> <cmd>\fR] [\fB\-g <argument>\fR] [\fB\-s <string>\fR]
|
||||
\fBwmfs\fR [\fB\-ihv\fR] [\fB\-C <file>\fR] [\fB\-c <uicb_function> <cmd>\fR] [\fB\-g <argument>\fR] [\fB\-s <string>\fR]
|
||||
.sp
|
||||
.SH "DESCRIPTION"
|
||||
\fBWMFS\fR is a basic, lightweight and dynamic tiling windows manager for X\&.
|
||||
.sp
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
\fB\-C <file>\fR
|
||||
.RS 4
|
||||
Load a configuration file\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-c <uicb_function> <cmd>\fR
|
||||
.RS 4
|
||||
Execute an uicb function to control WMFS\&.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user