Util: Add patht function to transform path: '~/' is now allowed
This commit is contained in:
parent
00638264d3
commit
36ca03f8f3
@ -159,7 +159,7 @@ draw_image(Drawable dr, int x, int y, int w, int h, char *name)
|
||||
imlib_context_set_colormap(DefaultColormap(dpy, DefaultScreen(dpy)));
|
||||
imlib_context_set_drawable(dr);
|
||||
|
||||
image = imlib_load_image(name);
|
||||
image = imlib_load_image(patht(name));
|
||||
imlib_context_set_image(image);
|
||||
|
||||
if(w <= 0)
|
||||
|
||||
@ -201,16 +201,16 @@ init_status(void)
|
||||
sprintf(conf.status_path, "%s/"DEF_STATUS, home);
|
||||
}
|
||||
|
||||
if (stat(conf.status_path, &st) == -1)
|
||||
if (stat(patht(conf.status_path), &st) == -1)
|
||||
{
|
||||
warn("%s", conf.status_path);
|
||||
warn("%s", patht(conf.status_path));
|
||||
return;
|
||||
}
|
||||
|
||||
if(st.st_size && st.st_mode & S_IXUSR)
|
||||
estatus = True;
|
||||
else
|
||||
warnx("status file specified in configuratin (status_path) or present in wmfs directory can't be executed, try 'chmod +x %s'.", conf.status_path);
|
||||
warnx("status file specified in configuratin (status_path) or present in wmfs directory can't be executed, try 'chmod +x %s'.", patht(conf.status_path));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
18
src/util.c
18
src/util.c
@ -340,3 +340,21 @@ clean_value(char *str)
|
||||
return p;
|
||||
}
|
||||
|
||||
/* To use ~/ shortcut.. */
|
||||
char*
|
||||
patht(char *path)
|
||||
{
|
||||
static char ret[512];
|
||||
|
||||
if(!path)
|
||||
return NULL;
|
||||
|
||||
strcpy(ret, path);
|
||||
|
||||
if(strstr(path, "~/"))
|
||||
sprintf(ret, "%s/%s", getenv("HOME"), path + 2);
|
||||
|
||||
printf("--> (%s) - %s\n", path, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -296,6 +296,8 @@ int spawn(const char *str, ...);
|
||||
void swap_ptr(void **x, void **y);
|
||||
void uicb_spawn(uicb_t);
|
||||
char *clean_value(char *str);
|
||||
char* patht(char *path);
|
||||
|
||||
|
||||
#ifdef HAVE_IMLIB
|
||||
int parse_image_block(ImageAttr *im, char *str);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user