mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-09 07:14:18 +01:00
wmmenugen: Add executable detection, make Wmconfig use it
Add fileInPath, which determines whether or not a given file exists in $PATH (some heuristics apply). Make the Wconfig parser use it. Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
This commit is contained in:
committed by
Carlos R. Mafra
parent
0451160f7d
commit
5377ec8fba
@@ -51,6 +51,7 @@ char *env_lang, *env_ctry, *env_enc, *env_mod;
|
|||||||
*/
|
*/
|
||||||
void parse_locale(const char *what, char **env_lang, char **env_ctry, char **env_enc, char **env_mod);
|
void parse_locale(const char *what, char **env_lang, char **env_ctry, char **env_enc, char **env_mod);
|
||||||
char *find_terminal_emulator(void);
|
char *find_terminal_emulator(void);
|
||||||
|
Bool fileInPath(const char *file);
|
||||||
|
|
||||||
/* implemented parsers
|
/* implemented parsers
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -124,3 +124,48 @@ out:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* determine whether (first token of) given file is in $PATH
|
||||||
|
*/
|
||||||
|
Bool fileInPath(const char *file)
|
||||||
|
{
|
||||||
|
char *p, *t;
|
||||||
|
static char *path = NULL;
|
||||||
|
|
||||||
|
if (!file || !*file)
|
||||||
|
return False;
|
||||||
|
|
||||||
|
/* if it's an absolute path spec, don't override the user.
|
||||||
|
* s/he might just know better.
|
||||||
|
*/
|
||||||
|
if (*file == '/')
|
||||||
|
return True;
|
||||||
|
|
||||||
|
/* if it has a directory separator at random places,
|
||||||
|
* we might know better.
|
||||||
|
*/
|
||||||
|
p = strchr(file, '/');
|
||||||
|
if (p)
|
||||||
|
return False;
|
||||||
|
|
||||||
|
if (!path) {
|
||||||
|
path = getenv("PATH");
|
||||||
|
if (!path)
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = wstrdup(file);
|
||||||
|
t = strpbrk(p, " \t");
|
||||||
|
if (t)
|
||||||
|
*t = '\0';
|
||||||
|
|
||||||
|
t = wfindfile(path, p);
|
||||||
|
wfree(p);
|
||||||
|
|
||||||
|
if (t) {
|
||||||
|
wfree(t);
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|||||||
@@ -185,8 +185,10 @@ static Bool wmc_to_wm(WMConfigMenuEntry **wmc, WMMenuEntry **wm)
|
|||||||
char *p;
|
char *p;
|
||||||
size_t slen;
|
size_t slen;
|
||||||
|
|
||||||
/* only Exec is mandatory */
|
/* only Exec is mandatory, and it's better exist in a known place */
|
||||||
if (!*wmc || !(*wmc)->Exec || !*(*wmc)->Exec)
|
if (!*wmc ||
|
||||||
|
!(*wmc)->Exec || !*(*wmc)->Exec ||
|
||||||
|
!fileInPath((*wmc)->Exec))
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
/* normalize Exec: wmconfig tends to stuck an ampersand
|
/* normalize Exec: wmconfig tends to stuck an ampersand
|
||||||
|
|||||||
Reference in New Issue
Block a user