1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2006-01-06 23:20:58 -08:00
|
|
|
* Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors
|
|
|
|
* Copyright (C) 2004-2006 Kim Woelders
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
2005-09-04 00:27:20 -07:00
|
|
|
#include "desktops.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "emodule.h"
|
2005-10-27 16:18:35 -07:00
|
|
|
#include "hints.h"
|
2005-09-23 09:12:13 -07:00
|
|
|
#include "snaps.h"
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "timestamp.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "xwin.h"
|
1999-10-28 05:24:39 -07:00
|
|
|
#include <sys/utsname.h>
|
2004-03-11 15:44:19 -08:00
|
|
|
#include <signal.h>
|
|
|
|
#include <time.h>
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
const char e_wm_name[] = "Enlightenment";
|
|
|
|
const char e_wm_version[] =
|
|
|
|
#ifdef ENLIGHTENMENT_RELEASE
|
|
|
|
"enlightenment-" ENLIGHTENMENT_VERSION "-" ENLIGHTENMENT_RELEASE;
|
|
|
|
#else
|
|
|
|
"enlightenment-" ENLIGHTENMENT_VERSION;
|
|
|
|
#endif
|
2005-02-13 06:49:38 -08:00
|
|
|
const char e_wm_date[] = E_CHECKOUT_DATE;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Display *disp;
|
|
|
|
RealRoot RRoot;
|
|
|
|
VirtRoot VRoot;
|
|
|
|
EConf Conf;
|
|
|
|
EMode Mode;
|
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
static int EoptGet(int argc, char **argv);
|
|
|
|
static void EoptHelp(void);
|
2004-12-28 15:46:49 -08:00
|
|
|
static void ECheckEprog(const char *name);
|
|
|
|
static void EDirUserSet(const char *dir);
|
2005-04-03 07:05:04 -07:00
|
|
|
static void EConfNameSet(const char *dir);
|
2004-12-28 15:46:49 -08:00
|
|
|
static void EDirUserCacheSet(const char *dir);
|
|
|
|
static void EDirsSetup(void);
|
2005-02-07 15:44:59 -08:00
|
|
|
static void RunInitPrograms(void);
|
2005-04-07 09:38:57 -07:00
|
|
|
|
|
|
|
static int eoptind = 0;
|
|
|
|
const char *eoptarg = NULL;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char sopt;
|
|
|
|
char arg;
|
|
|
|
const char *lopt;
|
|
|
|
const char *oarg;
|
|
|
|
const char *desc;
|
|
|
|
} EOpt;
|
|
|
|
|
|
|
|
static const EOpt Eopts[] = {
|
|
|
|
{'d', 1, "display", "display", "Set display"},
|
|
|
|
{'f', 0, "fast", NULL, "Fast startup"},
|
|
|
|
{'h', 0, "help", NULL, "Show help"},
|
|
|
|
{'m', 1, NULL, NULL, NULL},
|
|
|
|
{'p', 1, "config-prefix", "prefix", "Configuration file name prefix"},
|
|
|
|
{'P', 1, "econfdir", "path", "Set user configuration directory"},
|
|
|
|
{'Q', 1, "ecachedir", "path", "Set user cache directory"},
|
|
|
|
{'s', 1, "single", "screen", "Run only on given screen"},
|
|
|
|
{'S', 1, "sm-client-id", "session id", "Set session manager ID"},
|
|
|
|
{'t', 1, "theme", "name", "Select theme"},
|
|
|
|
{'v', 0, "verbose", NULL, "Show additional info"},
|
|
|
|
{'V', 0, "version", NULL, "Show version"},
|
|
|
|
{'w', 1, "window", "WxH", "Run in window"},
|
|
|
|
{'X', 1, NULL, NULL, NULL},
|
|
|
|
};
|
1999-10-01 11:15:04 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
int ch, i, loop;
|
1999-10-28 05:24:39 -07:00
|
|
|
struct utsname ubuf;
|
2005-04-07 09:38:57 -07:00
|
|
|
const char *str, *dstr;
|
1999-09-22 19:31:53 -07:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
/* This function runs all the setup for startup, and then
|
|
|
|
* proceeds into the primary event loop at the end.
|
|
|
|
*/
|
|
|
|
|
2004-03-09 11:07:05 -08:00
|
|
|
/* Init state variable struct */
|
2004-03-20 07:49:05 -08:00
|
|
|
memset(&Mode, 0, sizeof(EMode));
|
2005-04-07 09:38:57 -07:00
|
|
|
|
|
|
|
Mode.wm.master = 1;
|
|
|
|
Mode.wm.pid = getpid();
|
2004-12-28 15:46:49 -08:00
|
|
|
Mode.wm.exec_name = argv[0];
|
2004-05-07 08:18:07 -07:00
|
|
|
Mode.wm.startup = 1;
|
2005-04-07 09:38:57 -07:00
|
|
|
|
|
|
|
memset(&VRoot, 0, sizeof(VRoot));
|
|
|
|
VRoot.scr = -1;
|
|
|
|
|
|
|
|
Mode.mode = MODE_NONE;
|
2004-05-19 14:41:03 -07:00
|
|
|
Mode.move.check = 1;
|
2004-03-09 11:07:05 -08:00
|
|
|
|
2005-02-22 13:04:24 -08:00
|
|
|
str = getenv("EDEBUG");
|
2003-06-15 08:27:05 -07:00
|
|
|
if (str)
|
2004-01-04 10:07:18 -08:00
|
|
|
EventDebugInit(str);
|
2005-02-22 13:04:24 -08:00
|
|
|
str = getenv("EDEBUG_COREDUMP");
|
2004-05-07 08:18:07 -07:00
|
|
|
if (str)
|
|
|
|
Mode.wm.coredump = 1;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-04-03 07:05:04 -07:00
|
|
|
str = getenv("ECONFNAME");
|
|
|
|
if (str)
|
|
|
|
EConfNameSet(str);
|
2005-04-07 09:38:57 -07:00
|
|
|
str = getenv("ECONFDIR");
|
|
|
|
if (str)
|
|
|
|
EDirUserSet(str);
|
2004-12-28 15:46:49 -08:00
|
|
|
str = getenv("ECACHEDIR");
|
|
|
|
if (str)
|
|
|
|
EDirUserCacheSet(str);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
srand((unsigned int)time(NULL));
|
1999-08-17 15:56:46 -07:00
|
|
|
|
1999-10-28 05:24:39 -07:00
|
|
|
if (!uname(&ubuf))
|
2004-12-28 15:46:49 -08:00
|
|
|
Mode.wm.machine_name = Estrdup(ubuf.nodename);
|
|
|
|
if (!Mode.wm.machine_name)
|
|
|
|
Mode.wm.machine_name = Estrdup("localhost");
|
2004-02-13 10:36:52 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Now we're going to interpret any of the commandline parameters
|
|
|
|
* that are passed to it -- Well, at least the ones that we
|
|
|
|
* understand.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Mode.theme.path = NULL;
|
|
|
|
dstr = NULL;
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
for (loop = 1; loop;)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
ch = EoptGet(argc, argv);
|
|
|
|
if (ch <= 0)
|
|
|
|
break;
|
|
|
|
#if 0
|
|
|
|
Eprintf("Opt: %c: %d - %s\n", ch, eoptind, eoptarg);
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
2005-04-07 09:38:57 -07:00
|
|
|
switch (ch)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
default:
|
|
|
|
case '?':
|
|
|
|
printf("e16: Ignoring: ");
|
|
|
|
for (i = eoptind; i < argc; i++)
|
|
|
|
printf("%s ", argv[i]);
|
|
|
|
printf("\n");
|
|
|
|
loop = 0;
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
EoptHelp();
|
2004-12-28 15:46:49 -08:00
|
|
|
exit(0);
|
2005-04-07 09:38:57 -07:00
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
dstr = eoptarg;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
Mode.wm.restart = 1;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
EConfNameSet(eoptarg);
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
EDirUserSet(eoptarg);
|
|
|
|
break;
|
|
|
|
case 'Q':
|
|
|
|
EDirUserCacheSet(eoptarg);
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
Mode.wm.single = 1;
|
|
|
|
VRoot.scr = strtoul(eoptarg, NULL, 10);
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
SetSMID(eoptarg);
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
Mode.theme.path = Estrdup(eoptarg);
|
|
|
|
break;
|
|
|
|
case 'V':
|
2005-02-22 13:04:24 -08:00
|
|
|
printf("Enlightenment %s - %s\n",
|
2004-12-28 15:46:49 -08:00
|
|
|
ENLIGHTENMENT_VERSION, E_CHECKOUT_DATE);
|
|
|
|
exit(0);
|
2005-04-07 09:38:57 -07:00
|
|
|
break;
|
|
|
|
case 'v':
|
2005-02-22 13:04:24 -08:00
|
|
|
EventDebugSet(EDBUG_TYPE_VERBOSE, 1);
|
2005-04-07 09:38:57 -07:00
|
|
|
break;
|
|
|
|
case 'w':
|
|
|
|
sscanf(eoptarg, "%dx%d", &VRoot.w, &VRoot.h);
|
|
|
|
Mode.wm.window = 1;
|
|
|
|
Mode.wm.single = 1;
|
|
|
|
Mode.wm.master = 0;
|
|
|
|
break;
|
|
|
|
#ifdef USE_EXT_INIT_WIN
|
|
|
|
case 'X':
|
2005-04-23 06:35:37 -07:00
|
|
|
ExtInitWinSet(strtoul(eoptarg, NULL, 0));
|
2005-04-07 09:38:57 -07:00
|
|
|
Mode.wm.restart = 1;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case 'm':
|
|
|
|
Mode.wm.master = 0;
|
|
|
|
Mode.wm.master_screen = strtoul(eoptarg, NULL, 10);
|
|
|
|
break;
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-02-22 13:04:24 -08:00
|
|
|
/* Initialise internationalisation */
|
|
|
|
LangInit();
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
/* run most of the setup */
|
2004-03-11 08:58:14 -08:00
|
|
|
AlertInit(); /* Set up all the text bits that belong on the GSOD */
|
2003-08-18 14:54:27 -07:00
|
|
|
SignalsSetup();
|
2004-12-28 15:46:49 -08:00
|
|
|
SetupX(dstr); /* This is where the we fork per screen */
|
|
|
|
/* X is now running, and we have forked per screen */
|
2004-06-19 14:31:40 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
ECheckEprog("epp");
|
|
|
|
ECheckEprog("eesh");
|
|
|
|
EDirsSetup();
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* So far nothing should rely on a selected settings or theme. */
|
|
|
|
ConfigurationLoad(); /* Load settings */
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* The theme path must now be available for config file loading. */
|
|
|
|
ThemePathFind();
|
|
|
|
|
|
|
|
/* Set the Environment variables */
|
|
|
|
Esetenv("EVERSION", ENLIGHTENMENT_VERSION, 1);
|
|
|
|
Esetenv("EROOT", EDirRoot(), 1);
|
|
|
|
Esetenv("EBIN", EDirBin(), 1);
|
|
|
|
Esetenv("ECONFDIR", EDirUser(), 1);
|
|
|
|
Esetenv("ECACHEDIR", EDirUserCache(), 1);
|
2005-04-03 07:05:04 -07:00
|
|
|
Esetenv("ETHEME", Mode.theme.path, 1);
|
2004-04-21 13:51:57 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Unmap the clients */
|
|
|
|
MapUnmap(0);
|
2004-04-21 13:51:57 -07:00
|
|
|
|
2005-03-18 13:43:43 -08:00
|
|
|
/* Move elsewhere? */
|
2003-03-23 19:48:09 -08:00
|
|
|
HintsInit();
|
2004-12-28 15:46:49 -08:00
|
|
|
CommsInit();
|
1999-08-17 15:56:46 -07:00
|
|
|
SessionInit();
|
2004-12-28 15:46:49 -08:00
|
|
|
LoadSnapInfo();
|
2004-04-21 13:51:57 -07:00
|
|
|
|
2005-03-18 13:43:43 -08:00
|
|
|
ModulesSignal(ESIGNAL_INIT, NULL);
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Load the theme */
|
|
|
|
ThemeConfigLoad();
|
2004-04-25 11:48:36 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Do initial configuration */
|
|
|
|
ModulesSignal(ESIGNAL_CONFIGURE, NULL);
|
2004-04-21 13:51:57 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Set root window cursor */
|
|
|
|
ECsrApply(ECSR_ROOT, VRoot.win);
|
2004-04-07 07:32:36 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
#ifdef USE_EXT_INIT_WIN
|
2004-04-07 07:32:36 -07:00
|
|
|
/* Kill the E process owning the "init window" */
|
2005-04-23 06:35:37 -07:00
|
|
|
ExtInitWinKill();
|
2004-12-28 15:46:49 -08:00
|
|
|
#endif
|
|
|
|
|
2005-05-27 23:23:51 -07:00
|
|
|
if (Mode.wm.window)
|
|
|
|
EMapWindow(VRoot.win);
|
|
|
|
|
2005-06-05 08:15:59 -07:00
|
|
|
#if 0 /* FIXME - Remove? */
|
1999-09-07 16:16:39 -07:00
|
|
|
/* sync just to make sure */
|
2005-05-07 04:20:02 -07:00
|
|
|
ESync();
|
2005-06-05 08:15:59 -07:00
|
|
|
#endif
|
1999-09-07 16:16:39 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* let's make sure we set this up and go to our desk anyways */
|
2005-02-26 08:40:36 -08:00
|
|
|
DeskGoto(DesksGetCurrent());
|
2005-05-07 04:20:02 -07:00
|
|
|
ESync();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
#ifdef SIGCONT
|
|
|
|
for (i = 0; i < Mode.wm.child_count; i++)
|
|
|
|
kill(Mode.wm.children[i], SIGCONT);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ModulesSignal(ESIGNAL_START, NULL);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-02-10 10:59:32 -08:00
|
|
|
/* Map the clients */
|
|
|
|
MapUnmap(1);
|
|
|
|
|
2005-02-07 15:44:59 -08:00
|
|
|
RunInitPrograms();
|
2004-12-28 15:46:49 -08:00
|
|
|
SpawnSnappedCmds();
|
|
|
|
|
2005-02-27 06:42:41 -08:00
|
|
|
if (!Mode.wm.restart)
|
|
|
|
StartupWindowsOpen();
|
|
|
|
|
2006-03-12 09:57:32 -08:00
|
|
|
Conf.startup.firsttime = 0;
|
2005-03-19 03:10:12 -08:00
|
|
|
Mode.wm.save_ok = Conf.autosave;
|
2004-12-28 15:46:49 -08:00
|
|
|
Mode.wm.startup = 0;
|
|
|
|
autosave();
|
2004-04-25 11:48:36 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* The primary event loop */
|
2006-01-08 08:13:21 -08:00
|
|
|
EventsMain();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* Of course, we should NEVER get to this point */
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
void
|
|
|
|
EExit(int exitcode)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (EventDebug(EDBUG_TYPE_SESSION))
|
|
|
|
Eprintf("EExit(%d)\n", exitcode);
|
|
|
|
|
|
|
|
if (disp)
|
|
|
|
{
|
2005-05-07 04:20:02 -07:00
|
|
|
EUngrabServer();
|
2005-04-07 09:38:57 -07:00
|
|
|
GrabPointerRelease();
|
|
|
|
XAllowEvents(disp, AsyncBoth, CurrentTime);
|
|
|
|
|
|
|
|
/* XSetInputFocus(disp, None, RevertToParent, CurrentTime); */
|
|
|
|
/* I think this is a better way to release the grabs: (felix) */
|
|
|
|
XSetInputFocus(disp, PointerRoot, RevertToPointerRoot, CurrentTime);
|
|
|
|
XSelectInput(disp, VRoot.win, 0);
|
|
|
|
EDisplayClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
SignalsRestore();
|
|
|
|
|
|
|
|
if (Mode.wm.master)
|
|
|
|
{
|
|
|
|
for (i = 0; i < Mode.wm.child_count; i++)
|
|
|
|
kill(Mode.wm.children[i], SIGINT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
exitcode = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(exitcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Command line parsing.
|
|
|
|
* Not entirely standard compliant, but close enough.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
EoptGet(int argc, char **argv)
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
unsigned int i, len;
|
|
|
|
int lopt;
|
|
|
|
const EOpt *eopt;
|
|
|
|
|
|
|
|
eoptind++;
|
|
|
|
if (eoptind >= argc)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
s = argv[eoptind];
|
|
|
|
if (*s++ != '-')
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
lopt = 0;
|
|
|
|
if (*s == '-')
|
|
|
|
{
|
|
|
|
lopt = 1;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
|
|
|
|
eoptarg = NULL;
|
|
|
|
eopt = NULL;
|
|
|
|
for (i = 0; i < sizeof(Eopts) / sizeof(EOpt); i++)
|
|
|
|
{
|
|
|
|
eopt = &Eopts[i];
|
|
|
|
|
|
|
|
/* Short option */
|
|
|
|
if (!lopt)
|
|
|
|
{
|
|
|
|
if (!eopt->sopt || eopt->sopt != s[0])
|
|
|
|
continue;
|
|
|
|
if (eopt->arg)
|
|
|
|
{
|
|
|
|
if (s[1])
|
|
|
|
{
|
|
|
|
eoptarg = s + 1;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
if (s[1])
|
|
|
|
break;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eopt->lopt)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Long option */
|
|
|
|
len = strlen(eopt->lopt);
|
|
|
|
if (strncmp(eopt->lopt, s, len))
|
|
|
|
continue;
|
|
|
|
if (eopt->arg)
|
|
|
|
{
|
|
|
|
if (s[len] == '\0')
|
|
|
|
goto found;
|
|
|
|
if (s[len] != '=')
|
|
|
|
break;
|
|
|
|
eoptarg = s + len + 1;
|
|
|
|
}
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
return '?';
|
|
|
|
|
|
|
|
found:
|
|
|
|
if (!eopt->arg || eoptarg)
|
|
|
|
return eopt->sopt;
|
|
|
|
|
|
|
|
if (eoptind >= argc - 1)
|
|
|
|
return '?'; /* Missing param */
|
|
|
|
|
|
|
|
eoptind++;
|
|
|
|
eoptarg = argv[eoptind];
|
|
|
|
return eopt->sopt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
EoptHelp(void)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
const EOpt *eopt;
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
printf("e16 options:\n");
|
|
|
|
for (i = 0; i < sizeof(Eopts) / sizeof(EOpt); i++)
|
|
|
|
{
|
|
|
|
eopt = &Eopts[i];
|
|
|
|
if (!eopt->desc)
|
|
|
|
continue;
|
|
|
|
if (eopt->oarg)
|
|
|
|
Esnprintf(buf, sizeof(buf), "--%s <%s>", eopt->lopt, eopt->oarg);
|
|
|
|
else
|
|
|
|
Esnprintf(buf, sizeof(buf), "--%s", eopt->lopt);
|
|
|
|
printf(" -%c %-30s\t%s\n", eopt->sopt, buf, eopt->desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-07 15:44:59 -08:00
|
|
|
static void
|
|
|
|
RunDocBrowser(void)
|
|
|
|
{
|
|
|
|
char file[FILEPATH_LEN_MAX];
|
|
|
|
|
|
|
|
Esnprintf(file, sizeof(file), "%s/edox", EDirBin());
|
|
|
|
if (!canexec(file))
|
|
|
|
return;
|
|
|
|
Esnprintf(file, sizeof(file), "%s/E-docs", EDirRoot());
|
|
|
|
if (!canread(file))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (fork())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Esnprintf(file, sizeof(file), "exec %s/edox %s/E-docs",
|
|
|
|
EDirBin(), EDirRoot());
|
|
|
|
|
|
|
|
execl(usershell(getuid()), usershell(getuid()), "-c", (char *)file, NULL);
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RunMenuGen(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
char file[FILEPATH_LEN_MAX];
|
|
|
|
|
|
|
|
if (fork())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Esnprintf(file, sizeof(file), "exec %s/scripts/e_gen_menu", EDirRoot());
|
|
|
|
execl(usershell(getuid()), usershell(getuid()), "-c", (char *)file, NULL);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
RunInitPrograms(void)
|
|
|
|
{
|
|
|
|
if (Mode.wm.session_start)
|
2005-11-06 10:12:12 -08:00
|
|
|
SessionHelper(ESESSION_INIT);
|
2005-02-07 15:44:59 -08:00
|
|
|
|
2005-11-06 10:12:12 -08:00
|
|
|
SessionHelper(ESESSION_START);
|
2005-02-07 15:44:59 -08:00
|
|
|
|
2005-12-28 01:59:53 -08:00
|
|
|
if (Mode.firsttime && Mode.wm.master)
|
2005-02-07 15:44:59 -08:00
|
|
|
{
|
|
|
|
RunMenuGen();
|
|
|
|
RunDocBrowser();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
const char *
|
|
|
|
EDirBin(void)
|
|
|
|
{
|
|
|
|
return ENLIGHTENMENT_BIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
EDirRoot(void)
|
|
|
|
{
|
|
|
|
return ENLIGHTENMENT_ROOT;
|
|
|
|
}
|
|
|
|
|
2005-04-03 07:05:04 -07:00
|
|
|
static void
|
|
|
|
EConfNameSet(const char *name)
|
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
if (Mode.conf.name)
|
|
|
|
Efree(Mode.conf.name);
|
|
|
|
Mode.conf.name = Estrdup(name);
|
|
|
|
Esetenv("ECONFNAME", Mode.conf.name, 1);
|
2005-04-03 07:05:04 -07:00
|
|
|
}
|
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
static void
|
|
|
|
EDirUserSet(const char *dir)
|
2005-04-03 07:05:04 -07:00
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
if (!strcmp(dir, EDirUser()))
|
|
|
|
return;
|
|
|
|
if (Mode.conf.dir)
|
|
|
|
Efree(Mode.conf.dir);
|
|
|
|
Mode.conf.dir = Estrdup(dir);
|
2005-04-03 07:05:04 -07:00
|
|
|
}
|
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
static void
|
|
|
|
EDirUserCacheSet(const char *dir)
|
2005-04-03 07:05:04 -07:00
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
if (!strcmp(dir, EDirUser()))
|
|
|
|
return;
|
|
|
|
if (Mode.conf.cache_dir)
|
|
|
|
Efree(Mode.conf.cache_dir);
|
|
|
|
Mode.conf.cache_dir = Estrdup(dir);
|
2005-04-03 07:05:04 -07:00
|
|
|
}
|
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
static const char *
|
|
|
|
EConfNameDefault(void)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
return "e_config";
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
static const char *
|
|
|
|
EConfName(void)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
return (Mode.conf.name) ? Mode.conf.name : EConfNameDefault();
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
EDirUser(void)
|
|
|
|
{
|
2005-10-30 11:40:49 -08:00
|
|
|
static char *user_dir = NULL;
|
2004-12-28 15:46:49 -08:00
|
|
|
char *home, buf[4096];
|
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
if (Mode.conf.dir)
|
|
|
|
return Mode.conf.dir;
|
|
|
|
|
|
|
|
if (user_dir)
|
|
|
|
return user_dir;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
home = homedir(getuid());
|
|
|
|
Esnprintf(buf, sizeof(buf), "%s/.e16", home);
|
|
|
|
Efree(home);
|
2005-04-07 09:38:57 -07:00
|
|
|
user_dir = Estrdup(buf);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
return user_dir;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
EDirUserCache(void)
|
|
|
|
{
|
2005-04-07 09:38:57 -07:00
|
|
|
if (Mode.conf.cache_dir)
|
|
|
|
return Mode.conf.cache_dir;
|
|
|
|
return EDirUser();
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
EDirCheck(const char *dir)
|
|
|
|
{
|
|
|
|
if (!isdir(dir))
|
|
|
|
{
|
|
|
|
Alert(_("The directory %s is apparently not a directory\n"
|
|
|
|
"This is a fatal condition.\n" "Please remove this file\n"),
|
|
|
|
dir);
|
|
|
|
EExit(1);
|
|
|
|
}
|
|
|
|
if (!canexec(dir))
|
|
|
|
{
|
|
|
|
Alert(_("Do not have execute access to %s\n"
|
|
|
|
"This is a fatal condition.\n"
|
|
|
|
"Please check the ownership and permissions of this\n"
|
|
|
|
"directory and take steps to rectify this.\n"), dir);
|
|
|
|
EExit(1);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!canread(dir))
|
|
|
|
{
|
|
|
|
Alert(_("Do not have read access to %s\n" "This is a fatal condition.\n"
|
|
|
|
"Please check the ownership and permissions of this\n"
|
|
|
|
"directory and take steps to rectify this.\n"), dir);
|
|
|
|
EExit(1);
|
|
|
|
}
|
|
|
|
if (!canwrite(dir))
|
|
|
|
{
|
|
|
|
Alert(_("Do not have write access to %s\n"
|
|
|
|
"This is a fatal condition.\n"
|
|
|
|
"Please check the ownership and permissions of this\n"
|
|
|
|
"directory and take steps to rectify this.\n"), dir);
|
|
|
|
EExit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
EDirMake(const char *base, const char *name)
|
|
|
|
{
|
|
|
|
char s[1024];
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), "%s/%s", base, name);
|
|
|
|
if (!exists(s))
|
|
|
|
E_md(s);
|
|
|
|
else
|
|
|
|
EDirCheck(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
EDirsSetup(void)
|
|
|
|
{
|
|
|
|
char s[1024], ss[1024], *home;
|
|
|
|
|
|
|
|
home = homedir(getuid());
|
|
|
|
if (home)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
EDirCheck(home);
|
|
|
|
Efree(home);
|
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Esnprintf(s, sizeof(s), "%s", EDirUser());
|
|
|
|
if (exists(s))
|
|
|
|
{
|
|
|
|
if (!isdir(s))
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
Esnprintf(ss, sizeof(ss), "%s.old", EDirUser());
|
|
|
|
E_mv(s, ss);
|
|
|
|
E_md(s);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
else
|
|
|
|
EDirCheck(s);
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
else
|
|
|
|
E_md(s);
|
2003-11-15 14:27:17 -08:00
|
|
|
|
2005-12-28 01:59:53 -08:00
|
|
|
Esnprintf(s, sizeof(s), "%s/menus", EDirUser());
|
|
|
|
Mode.firsttime = !exists(s);
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
EDirMake(EDirUser(), "themes");
|
|
|
|
EDirMake(EDirUser(), "backgrounds");
|
|
|
|
EDirMake(EDirUser(), "menus");
|
2003-11-15 14:27:17 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
EDirMake(EDirUserCache(), "cached");
|
|
|
|
EDirMake(EDirUserCache(), "cached/cfg");
|
|
|
|
}
|
2003-11-15 14:27:17 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/*
|
|
|
|
* The user control config is called "~/.e16/e_config-$DISPLAY"
|
|
|
|
* The client data appends ".clients" onto this filename and the snapshot data
|
|
|
|
* appends ".snapshots".
|
|
|
|
*/
|
2005-04-07 09:38:57 -07:00
|
|
|
const char *
|
|
|
|
EGetSavePrefix(void)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
static char *def_prefix = NULL;
|
|
|
|
char *s, buf[1024];
|
1999-09-07 16:16:39 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (def_prefix)
|
|
|
|
return def_prefix;
|
2003-05-31 01:28:52 -07:00
|
|
|
|
2005-04-07 09:38:57 -07:00
|
|
|
if (Mode.conf.name)
|
2005-04-03 07:05:04 -07:00
|
|
|
Esnprintf(buf, sizeof(buf), "%s/%s-%d", EDirUser(), EConfName(),
|
|
|
|
VRoot.scr);
|
|
|
|
else if (Mode.wm.window)
|
|
|
|
Esnprintf(buf, sizeof(buf), "%s/%s-window", EDirUser(),
|
|
|
|
EConfNameDefault());
|
2004-12-28 15:46:49 -08:00
|
|
|
else
|
2005-04-03 07:05:04 -07:00
|
|
|
Esnprintf(buf, sizeof(buf), "%s/%s-%s", EDirUser(), EConfNameDefault(),
|
2004-12-28 15:46:49 -08:00
|
|
|
Mode.display.name);
|
|
|
|
def_prefix = Estrdup(buf);
|
1999-09-23 14:08:03 -07:00
|
|
|
|
2005-10-30 11:40:49 -08:00
|
|
|
for (s = def_prefix; (s = strchr(s, ':')) != NULL; *s = '-')
|
|
|
|
;
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
return def_prefix;
|
|
|
|
}
|
2004-04-10 12:39:02 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
const char *
|
|
|
|
EGetSavePrefixCommon(void)
|
|
|
|
{
|
|
|
|
static char *pfx = NULL;
|
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
if (pfx)
|
|
|
|
return pfx;
|
|
|
|
|
2005-04-03 07:05:04 -07:00
|
|
|
Esnprintf(buf, sizeof(buf), "%s/%s", EDirUser(), EConfName());
|
2004-12-28 15:46:49 -08:00
|
|
|
pfx = Estrdup(buf);
|
|
|
|
|
|
|
|
return pfx;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ECheckEprog(const char *name)
|
|
|
|
{
|
|
|
|
char s[1024];
|
|
|
|
|
|
|
|
Esnprintf(s, sizeof(s), "%s/%s", EDirBin(), name);
|
|
|
|
|
|
|
|
if (!exists(s))
|
|
|
|
{
|
|
|
|
Alert(_("!!!!!!!! ERROR ERROR ERROR ERROR !!!!!!!!\n" "\n"
|
|
|
|
"Enlightenment's utility executable cannot be found at:\n"
|
|
|
|
"\n" "%s\n"
|
|
|
|
"This is a fatal error and Enlightenment will cease to run.\n"
|
|
|
|
"Please rectify this situation and ensure it is installed\n"
|
|
|
|
"correctly.\n" "\n"
|
|
|
|
"The reason this could be missing is due to badly created\n"
|
|
|
|
"packages, someone manually deleting that program or perhaps\n"
|
|
|
|
"an error in installing Enlightenment.\n"), s);
|
|
|
|
EExit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!canexec(s))
|
|
|
|
{
|
|
|
|
Alert(_("!!!!!!!! ERROR ERROR ERROR ERROR !!!!!!!!\n" "\n"
|
|
|
|
"Enlightenment's utility executable is not able to be executed:\n"
|
|
|
|
"\n" "%s\n"
|
|
|
|
"This is a fatal error and Enlightenment will cease to run.\n"
|
|
|
|
"Please rectify this situation and ensure it is installed\n"
|
|
|
|
"correctly.\n"), s);
|
|
|
|
EExit(0);
|
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|