~/.enlightenment dir moved to a virtual dir - can me chang4ed with the

-econfdir option :)


SVN revision: 90
This commit is contained in:
Carsten Haitzler 1999-08-24 19:00:07 +00:00
parent 20dcc51975
commit 5a11902d8c
13 changed files with 93 additions and 103 deletions

View File

@ -1604,6 +1604,8 @@ void EFont_draw_string(Display * disp, Drawable win, GC gc,
void ErrAlert(int erno);
void SetEDir(char *d);
char *UserEDir(void);
void EDisplayMemUse(void);
int EExit(void *code);
void ShowEdgeWindows(void);

View File

@ -12,3 +12,5 @@ raster: add dnd to iconbox
raster: icoify animation suport
raster: changing virtual desktop size screws up pager content draws.
raster: double "close sound" playing atthe moment - fix.
raster: need to lock .enlightenment dir for multiple logins etc.

View File

@ -3058,26 +3058,26 @@ OpenConfigFileForReading(char *path, char preprocess)
"-D HOME_DIR=%s "
"-D USER_SHELL=%s "
"-D ENLIGHTENMENT_VERSION_015=1 "
"%s %s/.enlightenment/cached/cfg/%s.preparsed",
"%s %s/cached/cfg/%s.preparsed",
epp_path, ENLIGHTENMENT_ROOT, ENLIGHTENMENT_ROOT,
ENLIGHTENMENT_VERSION, ENLIGHTENMENT_ROOT, ENLIGHTENMENT_BIN,
themepath,
root.w, root.h, root.w, root.h, root.depth,
def_user, def_home, def_shell,
path, def_home, s);
path, UserEDir(), s);
system(execline);
Esnprintf(execline, sizeof(execline),
"%s/.enlightenment/cached/cfg/%s.preparsed",
def_home, s);
"%s/cached/cfg/%s.preparsed",
UserEDir(), s);
fpin = fopen(execline, "r");
if (s)
Efree(s);
if (def_user)
Efree(def_user);
if (def_home)
Efree(def_home);
if (def_shell)
Efree(def_shell);
if (def_home)
Efree(def_home);
EDBUG_RETURN(fpin);
}
else
@ -3347,7 +3347,6 @@ char *
FindFile(char *file)
{
char s[FILEPATH_LEN_MAX];
char *home;
EDBUG(6, "FindFile");
/* if absolute path - and file exists - return it */
@ -3357,9 +3356,7 @@ FindFile(char *file)
EDBUG_RETURN(duplicate(file));
}
/* look in ~/.enlightenment first */
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment/%s", home, file);
Efree(home);
Esnprintf(s, sizeof(s), "%s/%s", UserEDir(), file);
if (isfile(s))
EDBUG_RETURN(duplicate(s));
/* look in theme dir */
@ -3378,7 +3375,6 @@ char *
FindNoThemeFile(char *file)
{
char s[FILEPATH_LEN_MAX];
char *home;
EDBUG(6, "FindFile");
/* if absolute path - and file exists - return it */
@ -3388,9 +3384,7 @@ FindNoThemeFile(char *file)
EDBUG_RETURN(duplicate(file));
}
/* look in ~/.enlightenment first */
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment/%s", home, file);
Efree(home);
Esnprintf(s, sizeof(s), "%s/%s", UserEDir(), file);
if (isfile(s))
EDBUG_RETURN(duplicate(s));
/* look in system config dir */
@ -3405,15 +3399,13 @@ int
LoadEConfig(char *themelocation)
{
char s[FILEPATH_LEN_MAX], ss[FILEPATH_LEN_MAX];
char *theme, *home;
char *theme;
FILE *f;
EDBUG(5, "LoadEConfig");
home = NULL;
mustdel = 0;
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment/", home);
Esnprintf(s, sizeof(s), "%s/", UserEDir());
Fnlib_add_dir(fd, s);
Esnprintf(s, sizeof(s), "%s/config/", ENLIGHTENMENT_ROOT);
Fnlib_add_dir(fd, s);
@ -3427,7 +3419,7 @@ LoadEConfig(char *themelocation)
fprintf(f, "%s\n", themelocation);
fclose(f);
}
Esnprintf(ss, sizeof(ss), "%s/.enlightenment/user_theme.cfg", home);
Esnprintf(ss, sizeof(ss), "%s/user_theme.cfg", UserEDir());
rm(ss);
mv(s, ss);
if (!isfile(ss))
@ -3468,8 +3460,6 @@ LoadEConfig(char *themelocation)
"If you are the administrator of your own system please\n"
"consult the documentation that came with Enlightenment for\n"
"addional information.\n", ENLIGHTENMENT_ROOT);
if (home)
Efree(home);
EDBUG_RETURN(0);
}
strcpy(themepath, theme);
@ -3536,8 +3526,6 @@ LoadEConfig(char *themelocation)
}
if (theme)
Efree(theme);
if (home)
Efree(home);
themelocation = NULL;
EDBUG_RETURN(0);
}

View File

@ -18,15 +18,12 @@ FileExtension(char *file)
void
Etmp(char *s)
{
static char *home = NULL;
static unsigned long n_calls = 0;
EDBUG(9, "Etmp");
if (!n_calls)
n_calls = (unsigned long)time(NULL) + (unsigned long)getpid();
if (!home)
home = homedir(getuid());
Esnprintf(s, 1024, "%s/.enlightenment/TMP_%Xl", home, n_calls);
Esnprintf(s, 1024, "%s/TMP_%Xl", UserEDir(), n_calls);
n_calls++;
EDBUG_RETURN_
}

View File

@ -774,12 +774,10 @@ void
IB_SaveIcodefs(void)
{
/* save the icondefs */
char s[1024], *home;
char s[1024];
FILE *f;
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment/icondefs.cfg", home);
Efree(home);
Esnprintf(s, sizeof(s), "%s/icondefs.cfg", UserEDir());
f = fopen(s, "w");
if (f)
{

View File

@ -64,6 +64,10 @@ main(int argc, char **argv)
{
Esnprintf(themepath, sizeof(themepath), "%s", argv[++j]);
}
else if ((!strcmp("-econfdir", argv[j])) && (argc - j > 1))
{
SetEDir(argv[++j]);
}
else if (!strcmp("-single", argv[j]))
{
single_screen_mode = 1;
@ -92,6 +96,18 @@ main(int argc, char **argv)
{
no_overwrite = 1;
}
else if (!strcmp("-help", argv[j]))
{
printf("enlightenment options: \n"
"\t-theme /path/to/theme \n"
"\t-econfdir /path/to/.enlightenment/conf/dir\n"
"\t[-smid | -clientId | --sm-client-id] id \n"
"\t-smfile file \n"
"\t-ext_init_win window_id \n"
"\t-no_overwrite \n"
"\t[-v | -version | --version] \n");
exit(0);
}
else if ((!strcmp("-v", argv[j])) ||
(!strcmp("-version", argv[j])) ||
(!strcmp("--version", argv[j])) ||

View File

@ -938,7 +938,6 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir)
struct stat st;
const char *chmap =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
char *dhome = NULL;
FILE *f;
EDBUG(5, "CreateMenuFromDirectory");
@ -949,7 +948,6 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir)
{
int aa, bb, cc;
dhome = homedir(getuid());
aa = (int)st.st_ino;
bb = (int)st.st_dev;
cc = 0;
@ -958,8 +956,8 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir)
else
cc = st.st_ctime;
Esnprintf(cs, sizeof(cs),
"%s/.enlightenment/cached/img/.%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
dhome,
"%s/cached/img/.%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
UserEDir(),
chmap[(aa >> 0) & 0x3f],
chmap[(aa >> 6) & 0x3f],
chmap[(aa >> 12) & 0x3f],
@ -978,7 +976,6 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir)
chmap[(cc >> 18) & 0x3f],
chmap[(cc >> 24) & 0x3f],
chmap[(cc >> 28) & 0x3f]);
Efree(dhome);
/* cached dir listing - use it */
if (exists(cs))
{
@ -992,7 +989,6 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir)
{
Background *bg;
char ok = 1;
static char *home = NULL;
char s2[4096], s3[512];
word(s, 3, s3);
@ -1016,9 +1012,7 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir)
int maxw = 48, maxh = 48;
int justx = 512, justy = 512;
if (!home)
home = homedir(getuid());
Esnprintf(s2, sizeof(s2), "%s/.enlightenment/cached/img/%s", home, s3);
Esnprintf(s2, sizeof(s2), "%s/cached/img/%s", UserEDir(), s3);
width = im->rgb_width;
height = im->rgb_height;
h2 = maxh;
@ -1188,7 +1182,6 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir)
{
Background *bg;
char ok = 1;
static char *home = NULL;
char s2[4096], s3[512];
int aa, bb, cc;
@ -1235,9 +1228,7 @@ CreateMenuFromDirectory(char *name, MenuStyle * ms, char *dir)
int scr_asp, im_asp, w2, h2;
int maxw = 48, maxh = 48;
if (!home)
home = homedir(getuid());
Esnprintf(s2, sizeof(s2), "%s/.enlightenment/cached/img/%s", home, s3);
Esnprintf(s2, sizeof(s2), "%s/cached/img/%s", UserEDir(), s3);
width = im->rgb_width;
height = im->rgb_height;
h2 = maxh;

View File

@ -2,6 +2,31 @@
void EdgeTimeout(int val, void *data);
static char *dir = NULL;
void
SetEDir(char *d)
{
dir = duplicate(d);
}
char *
UserEDir(void)
{
if (dir)
return dir;
{
char *home, buf[4096];
home = homedir(getuid());
Esnprintf(buf, sizeof(buf), "%s/.enlightenment", home);
Efree(home);
dir = duplicate(buf);
}
return dir;
}
int
EExit(void *code)
{

View File

@ -907,16 +907,14 @@ PagerRedraw(Pager * p, char newbg)
if (desks.desk[p->desktop].bg)
{
char s[4096];
char *home, *uniq;
char *uniq;
ImlibImage *im;
home = homedir(getuid());
uniq = GetUniqueBGString(desks.desk[p->desktop].bg);
Esnprintf(s, sizeof(s),
"%s/.enlightenment/cached/pager/%s.%i.%i.%s",
home, desks.desk[p->desktop].bg->name, (p->w / ax),
"%s/cached/pager/%s.%i.%i.%s",
UserEDir(), desks.desk[p->desktop].bg->name, (p->w / ax),
(p->h / ay), uniq);
Efree(home);
Efree(uniq);
im = Imlib_load_image(id, s);

View File

@ -98,11 +98,8 @@ default_save_prefix(void)
if (!def_prefix)
{
char s[1024];
char *home;
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment/...e_session-XXXXXX", home);
Efree(home);
Esnprintf(s, sizeof(s), "%s/...e_session-XXXXXX", UserEDir());
def_prefix = duplicate(s);
}
return def_prefix;

View File

@ -1797,13 +1797,11 @@ CB_ConfigureBG(int val, void *data)
}
}
{
char *home, s[4096];
char s[4096];
ImlibImage *im;
Pixmap p2;
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment/cached/bgsel/%s", home, tmp_bg->name);
Efree(home);
Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s", UserEDir(), tmp_bg->name);
p2 = ECreatePixmap(disp, root.win, 64, 48, root.depth);
SetBackgroundTo(id, p2, tmp_bg, 0);
im = Imlib_create_image_from_drawable(id, p2, 0, 0, 0, 64, 48);
@ -2185,11 +2183,7 @@ BG_RedrawView(char nuke_old)
im = ELoadImage(s);
if (!im)
{
char *home;
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment/cached/bgsel/%s", home, bglist[i]->name);
Efree(home);
Esnprintf(s, sizeof(s), "%s/cached/bgsel/%s", UserEDir(), bglist[i]->name);
p2 = ECreatePixmap(disp, pmap, 64, 48, root.depth);
SetBackgroundTo(id, p2, bglist[i], 0);
XCopyArea(disp, p2, pmap, gc, 0, 0, 64, 48, x + 4, 4);

View File

@ -565,50 +565,42 @@ SetupX()
void
SetupDirs()
{
char *home;
char s[1024], ss[1024];
EDBUG(6, "SetupDirs");
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment", home);
Esnprintf(s, sizeof(s), "%s", UserEDir());
if (exists(s))
{
if (isfile(s))
{
Esnprintf(ss, sizeof(ss), "%s/.enlightenment.old", home);
Esnprintf(ss, sizeof(ss), "%s.old", UserEDir());
mv(s, ss);
md(s);
}
}
else
md(s);
Esnprintf(s, sizeof(s), "%s/.enlightenment/themes", home);
Esnprintf(s, sizeof(s), "%s/themes", UserEDir());
if (!exists(s))
md(s);
Esnprintf(s, sizeof(s), "%s/.enlightenment/cached", home);
Esnprintf(s, sizeof(s), "%s/backgrounds", UserEDir());
if (!exists(s))
md(s);
Esnprintf(s, sizeof(s), "%s/cached", UserEDir());
if (!exists(s))
md(s);
Esnprintf(s, sizeof(s), "%s/.enlightenment/cached/img", home);
Esnprintf(s, sizeof(s), "%s/cached/img", UserEDir());
if (!exists(s))
md(s);
Esnprintf(s, sizeof(s), "%s/.enlightenment/cached/cfg", home);
Esnprintf(s, sizeof(s), "%s/cached/cfg", UserEDir());
if (!exists(s))
md(s);
Esnprintf(s, sizeof(s), "%s/.enlightenment/cached/bgsel", home);
Esnprintf(s, sizeof(s), "%s/cached/bgsel", UserEDir());
if (!exists(s))
md(s);
Esnprintf(s, sizeof(s), "%s/.enlightenment/cached/pager", home);
Esnprintf(s, sizeof(s), "%s/cached/pager", UserEDir());
if (!exists(s))
md(s);
Efree(home);
EDBUG_RETURN_;
}

View File

@ -69,13 +69,11 @@ append_merge_dir(char *dir, char ***list, int *count)
char **
ListThemes(int *number)
{
char s[FILEPATH_LEN_MAX], **list = NULL, *home, *def = NULL,
char s[FILEPATH_LEN_MAX], **list = NULL, *def = NULL,
*def2 = NULL;
int count = 0;
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment/themes", home);
Efree(home);
Esnprintf(s, sizeof(s), "%s/themes", UserEDir());
def = append_merge_dir(s, &list, &count);
Esnprintf(s, sizeof(s), "%s/themes", ENLIGHTENMENT_ROOT);
def2 = append_merge_dir(s, &list, &count);
@ -96,12 +94,11 @@ ListThemes(int *number)
char *
GetDefaultTheme(void)
{
char s[FILEPATH_LEN_MAX], ss[FILEPATH_LEN_MAX], *home;
char s[FILEPATH_LEN_MAX], ss[FILEPATH_LEN_MAX];
char *def = NULL;
int count;
home = homedir(getuid());
Esnprintf(ss, sizeof(ss), "%s/.enlightenment/themes/DEFAULT", home);
Esnprintf(ss, sizeof(ss), "%s/themes/DEFAULT", UserEDir());
count = readlink(ss, s, sizeof(s));
if ((exists(ss)) && (count > 0))
{
@ -110,11 +107,10 @@ GetDefaultTheme(void)
def = duplicate(s);
else
{
Esnprintf(ss, sizeof(ss), "%s/.enlightenment/themes/%s", home, s);
Esnprintf(ss, sizeof(ss), "%s/themes/%s", UserEDir(), s);
def = duplicate(ss);
}
}
Efree(home);
if (!def)
{
Esnprintf(ss, sizeof(ss), "%s/themes/DEFAULT", ENLIGHTENMENT_ROOT);
@ -137,11 +133,9 @@ GetDefaultTheme(void)
void
SetDefaultTheme(char *theme)
{
char ss[FILEPATH_LEN_MAX], *home;
char ss[FILEPATH_LEN_MAX];
home = homedir(getuid());
Esnprintf(ss, sizeof(ss), "%s/.enlightenment/themes/DEFAULT", home);
Efree(home);
Esnprintf(ss, sizeof(ss), "%s/themes/DEFAULT", UserEDir());
if (exists(ss))
rm(ss);
if (theme)
@ -176,17 +170,15 @@ ExtractTheme(char *theme)
f = fopen(theme, "r");
if (f)
{
char *home, *themename;
char *themename;
fread(buf, 1, 320, f);
fclose(f);
/* make the temp dir */
home = homedir(getuid());
themename = fileof(theme);
Esnprintf(th, sizeof(th), "%s/.enlightenment/themes/%s",
home, themename);
Efree(home);
Esnprintf(th, sizeof(th), "%s/themes/%s",
UserEDir(), themename);
Efree(themename);
md(th);
/* check magic numbers */
@ -227,7 +219,7 @@ char *
FindTheme(char *theme)
{
char s[FILEPATH_LEN_MAX];
char *home, *ret = NULL;
char *ret = NULL;
EDBUG(6, "FindTheme");
if (!theme[0])
@ -239,9 +231,7 @@ FindTheme(char *theme)
ret = ExtractTheme(theme);
if (!ret)
{
home = homedir(getuid());
Esnprintf(s, sizeof(s), "%s/.enlightenment/themes/%s", home, theme);
Efree(home);
Esnprintf(s, sizeof(s), "%s/themes/%s", UserEDir(), theme);
if (exists(s))
ret = ExtractTheme(s);
if (!ret)