Specify Autostart Location, README & LICENSE updates, and Add config.h
- Remove config.h from gitignore - Move config.def.h modifications to config.h - Restore config.def.h to original version - Specify location of autostart instead of searching certain locations - Rename autostart.sh to autostart_blocking.sh - Add myself to license - Change README to markdown and add personal changes
This commit is contained in:
55
dwm.c
55
dwm.c
@ -242,7 +242,6 @@ static const char autostartblocksh[] = "autostart_blocking.sh";
|
||||
static const char autostartsh[] = "autostart.sh";
|
||||
static const char broken[] = "broken";
|
||||
static const char dwmdir[] = "dwm";
|
||||
static const char localshare[] = ".local/share";
|
||||
static char stext[256];
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
@ -1392,43 +1391,13 @@ runautostart(void)
|
||||
{
|
||||
char *pathpfx;
|
||||
char *path;
|
||||
char *xdgdatahome;
|
||||
char *xdgconfighome;
|
||||
char *home;
|
||||
struct stat sb;
|
||||
|
||||
if ((home = getenv("HOME")) == NULL)
|
||||
/* this is almost impossible */
|
||||
return;
|
||||
|
||||
/* if $XDG_DATA_HOME is set and not empty, use $XDG_DATA_HOME/dwm,
|
||||
* otherwise use $XDG_CONFIG_HOME if it is set and not empty,
|
||||
* otherwise use ~/.local/share/dwm as autostart script directory
|
||||
*/
|
||||
xdgdatahome = getenv("XDG_DATA_HOME");
|
||||
xdgconfighome = getenv("XDG_CONFIG_HOME");
|
||||
if (xdgdatahome != NULL && *xdgdatahome != '\0') {
|
||||
if (dwmdir != NULL && *dwmdir != '\0') {
|
||||
/* space for path segments, separators and nul */
|
||||
pathpfx = ecalloc(1, strlen(xdgdatahome) + strlen(dwmdir) + 2);
|
||||
pathpfx = ecalloc(1, strlen(rootdir) + strlen(dwmdir) + 2);
|
||||
|
||||
if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) {
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
} else if (xdgconfighome != NULL && *xdgdatahome != '\0') {
|
||||
/* space for path segments, separators and nul */
|
||||
pathpfx = ecalloc(1, strlen(xdgconfighome) + strlen(dwmdir) + 2);
|
||||
|
||||
if (sprintf(pathpfx, "%s/%s", xdgconfighome, dwmdir) <= 0) {
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/* space for path segments, separators and nul */
|
||||
pathpfx = ecalloc(1, strlen(home) + strlen(localshare)
|
||||
+ strlen(dwmdir) + 3);
|
||||
|
||||
if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) {
|
||||
if (sprintf(pathpfx, "%s/%s", rootdir, dwmdir) <= 0) {
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
@ -1436,21 +1405,9 @@ runautostart(void)
|
||||
|
||||
/* check if the autostart script directory exists */
|
||||
if (! (stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) {
|
||||
/* the XDG conformant path does not exist or is no directory
|
||||
* so we try ~/.dwm instead
|
||||
*/
|
||||
char *pathpfx_new = realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3);
|
||||
if(pathpfx_new == NULL) {
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
|
||||
pathpfx = pathpfx_new;
|
||||
|
||||
if (sprintf(pathpfx, "%s/.%s", home, dwmdir) <= 0) {
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
/* the specified dwm root directory does not exist or is not a directory */
|
||||
free(pathpfx);
|
||||
return;
|
||||
}
|
||||
|
||||
/* try the blocking script first */
|
||||
|
Reference in New Issue
Block a user