add -c option to specify configuration file
This commit is contained in:
parent
c81d40f15e
commit
9dad2fd85c
23
awesome.c
23
awesome.c
|
@ -270,6 +270,7 @@ int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
const char *confpath = NULL;
|
||||||
int r, xfd, e_dummy;
|
int r, xfd, e_dummy;
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
@ -281,13 +282,23 @@ main(int argc, char *argv[])
|
||||||
Atom netatom[NetLast];
|
Atom netatom[NetLast];
|
||||||
event_handler **handler;
|
event_handler **handler;
|
||||||
|
|
||||||
if(argc == 2 && !a_strcmp("-v", argv[1]))
|
if(argc >= 2)
|
||||||
{
|
{
|
||||||
printf("awesome-" VERSION " © 2007 Julien Danjou\n");
|
if(!a_strcmp("-v", argv[1]))
|
||||||
return EXIT_SUCCESS;
|
{
|
||||||
|
printf("awesome-" VERSION " © 2007 Julien Danjou\n");
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
else if(!a_strcmp("-c", argv[1]))
|
||||||
|
{
|
||||||
|
if(a_strlen(argv[2]))
|
||||||
|
confpath = argv[2];
|
||||||
|
else
|
||||||
|
eprint("awesome: -c require a file\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
eprint("usage: awesome [-v | -c configfile]\n");
|
||||||
}
|
}
|
||||||
else if(argc != 1)
|
|
||||||
eprint("usage: awesome [-v]\n");
|
|
||||||
|
|
||||||
/* Tag won't be printed otherwised */
|
/* Tag won't be printed otherwised */
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
|
@ -317,7 +328,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
for(screen = 0; screen < ScreenCount(dpy); screen++)
|
for(screen = 0; screen < ScreenCount(dpy); screen++)
|
||||||
{
|
{
|
||||||
parse_config(dpy, screen, &dc[screen], &awesomeconf[screen]);
|
parse_config(dpy, screen, &dc[screen], confpath, &awesomeconf[screen]);
|
||||||
setup(dpy, screen, &dc[screen], &awesomeconf[screen]);
|
setup(dpy, screen, &dc[screen], &awesomeconf[screen]);
|
||||||
XChangeProperty(dpy, RootWindow(dpy, screen), netatom[NetSupported],
|
XChangeProperty(dpy, RootWindow(dpy, screen), netatom[NetSupported],
|
||||||
XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast);
|
XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast);
|
||||||
|
|
19
config.c
19
config.c
|
@ -164,7 +164,7 @@ name_func_lookup(const char *funcname, const NameFuncLink * list)
|
||||||
* \param drawcontext Draw context
|
* \param drawcontext Draw context
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomeconf)
|
parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
/* Main configuration object for parsing*/
|
/* Main configuration object for parsing*/
|
||||||
config_t awesomelibconf;
|
config_t awesomelibconf;
|
||||||
|
@ -179,12 +179,17 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
||||||
KeySym tmp_key;
|
KeySym tmp_key;
|
||||||
ssize_t confpath_len;
|
ssize_t confpath_len;
|
||||||
|
|
||||||
homedir = getenv("HOME");
|
if(confpatharg)
|
||||||
confpath_len = a_strlen(homedir) + a_strlen(AWESOME_CONFIG_FILE) + 2;
|
confpath = a_strdup(confpatharg);
|
||||||
confpath = p_new(char, confpath_len);
|
else
|
||||||
a_strcpy(confpath, confpath_len, homedir);
|
{
|
||||||
a_strcat(confpath, confpath_len, "/");
|
homedir = getenv("HOME");
|
||||||
a_strcat(confpath, confpath_len, AWESOME_CONFIG_FILE);
|
confpath_len = a_strlen(homedir) + a_strlen(AWESOME_CONFIG_FILE) + 2;
|
||||||
|
confpath = p_new(char, confpath_len);
|
||||||
|
a_strcpy(confpath, confpath_len, homedir);
|
||||||
|
a_strcat(confpath, confpath_len, "/");
|
||||||
|
a_strcat(confpath, confpath_len, AWESOME_CONFIG_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
config_init(&awesomelibconf);
|
config_init(&awesomelibconf);
|
||||||
|
|
||||||
|
|
2
config.h
2
config.h
|
@ -159,6 +159,6 @@ struct awesome_config
|
||||||
Bool have_randr;
|
Bool have_randr;
|
||||||
};
|
};
|
||||||
|
|
||||||
void parse_config(Display *, int, DC *, awesome_config *); /* parse configuration file */
|
void parse_config(Display *, int, DC *, const char *, awesome_config *); /* parse configuration file */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue