Ejemplo n.º 1
0
/* normalize and convert one wmconfig-format entry to wm format */
static Bool wmc_to_wm(WMConfigMenuEntry **wmc, WMMenuEntry **wm)
{
	char *p;
	size_t slen;

	/* only Exec is mandatory, and it's better exist in a known place */
	if (!((*wmc)->Exec &&
	     *(*wmc)->Exec &&
	     fileInPath((*wmc)->Exec)))
		return False;

	/* normalize Exec: wmconfig tends to stick an ampersand
	 * at the end of everything, which we don't need */
	slen = strlen((*wmc)->Exec) - 1;
	p = (*wmc)->Exec;
	while (slen > 0 && (isspace(*(p + slen)) || *(p + slen) == '&'))
		*(p + slen--) = '\0';

	/* if there's no Name, use the first word of Exec; still better
	 * than nothing. i realize it's highly arguable whether `xterm' from
	 * `xterm -e "ssh dev push-to-prod"' is helpful or not, but since
	 * the alternative is to completely lose the entry, i opt for this.
	 * you could just fix the descriptor file to have a label <G> */
	if (!(*wmc)->Name) {
		(*wmc)->Name = wstrdup((*wmc)->Exec);
		p = strchr((*wmc)->Name, ' ');
		if (p)
			*p = '\0';
	}

	/* if there's no Category, use "Applications"; apparently "no category"
	 * can manifest both as no `group' descriptor at all, or a group
	 * descriptor of "" */
	if (!(*wmc)->Category || !*(*wmc)->Category)
		(*wmc)->Category = wstrdup("Applications");

	/* the `restart' type is used for restart, restart other
	 * wm and quit current wm too. separate these cases. */
	if ((*wmc)->Restart) {
		if (strcmp((*wmc)->Restart, "restart") == 0)
			(*wmc)->Flags |= F_RESTART_SELF;
		else if (strcmp((*wmc)->Restart, "quit") == 0)
			(*wmc)->Flags |= F_QUIT;
		else
			(*wmc)->Flags |= F_RESTART_OTHER;
	}

	(*wm)->Name = (*wmc)->Name;
	(*wm)->CmdLine = (*wmc)->Exec;
	(*wm)->SubMenu = (*wmc)->Category;
	(*wm)->Flags = (*wmc)->Flags;

	return True;
}
Ejemplo n.º 2
0
/*
** Is flpr present in the search path and is it executable ?
*/
static bool flprPresent()
{
   /* Is flpr present in the search path and is it executable ? */
   return fileInPath("flpr",0111);
}