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[])
|
||||
{
|
||||
char *p;
|
||||
const char *confpath = NULL;
|
||||
int r, xfd, e_dummy;
|
||||
fd_set rd;
|
||||
XEvent ev;
|
||||
|
@ -281,13 +282,23 @@ main(int argc, char *argv[])
|
|||
Atom netatom[NetLast];
|
||||
event_handler **handler;
|
||||
|
||||
if(argc == 2 && !a_strcmp("-v", argv[1]))
|
||||
if(argc >= 2)
|
||||
{
|
||||
printf("awesome-" VERSION " © 2007 Julien Danjou\n");
|
||||
return EXIT_SUCCESS;
|
||||
if(!a_strcmp("-v", argv[1]))
|
||||
{
|
||||
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 */
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
@ -317,7 +328,7 @@ main(int argc, char *argv[])
|
|||
|
||||
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]);
|
||||
XChangeProperty(dpy, RootWindow(dpy, screen), netatom[NetSupported],
|
||||
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
|
||||
*/
|
||||
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*/
|
||||
config_t awesomelibconf;
|
||||
|
@ -179,12 +179,17 @@ parse_config(Display * disp, int scr, DC * drawcontext, awesome_config *awesomec
|
|||
KeySym tmp_key;
|
||||
ssize_t confpath_len;
|
||||
|
||||
homedir = getenv("HOME");
|
||||
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);
|
||||
if(confpatharg)
|
||||
confpath = a_strdup(confpatharg);
|
||||
else
|
||||
{
|
||||
homedir = getenv("HOME");
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue