1 This patch makes it possible (and necessary) to specify the default
2 shell, xterm client, and startx script from environment variables. These
3 defaults are used when launching the XQuartz.app, which in turn needs to know
4 how to start the X server. `startx' comes from the `xinit' package,
5 which also has a dependency on `xorg-server', so we can't hardcode
6 sane defaults. If the environment variables are specified, they
7 override any value in the preferences settings.
9 When developing an installable package for XQuartz/XQuartz.app, we'll
10 need to set an `LSEnvironment' entry in the plist for the XQuartz.app.
11 (See stub.patch for more details.).
13 diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
14 index de82e2280..da58a5d44 100644
15 --- a/hw/xquartz/mach-startup/bundle-main.c
16 +++ b/hw/xquartz/mach-startup/bundle-main.c
17 @@ -76,8 +76,6 @@ extern int noPanoramiXExtension;
18 extern Bool noCompositeExtension;
21 -#define DEFAULT_CLIENT X11BINDIR "/xterm"
22 -#define DEFAULT_STARTX X11BINDIR "/startx -- " X11BINDIR "/Xquartz"
23 #define DEFAULT_SHELL "/bin/sh"
25 #define _STRINGIZE(s) #s
26 @@ -108,7 +106,7 @@ server_main(int argc, char **argv, char **envp);
28 execute(const char *command);
30 -command_from_prefs(const char *key, const char *default_value);
31 +command_from_prefs(const char *key, const char *env_name, const char *default_value);
33 static char *pref_app_to_run;
34 static char *pref_login_shell;
35 @@ -669,14 +667,19 @@ main(int argc, char **argv, char **envp)
39 - pref_app_to_run = command_from_prefs("app_to_run", DEFAULT_CLIENT);
40 + pref_app_to_run = command_from_prefs("app_to_run",
41 + "XQUARTZ_DEFAULT_CLIENT",
43 assert(pref_app_to_run);
45 - pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL);
46 + pref_login_shell = command_from_prefs("login_shell",
47 + "XQUARTZ_DEFAULT_SHELL",
49 assert(pref_login_shell);
51 pref_startx_script = command_from_prefs("startx_script",
53 + "XQUARTZ_DEFAULT_STARTX",
55 assert(pref_startx_script);
57 /* Do the fork-twice trick to avoid having to reap zombies */
58 @@ -753,7 +756,7 @@ execute(const char *command)
62 -command_from_prefs(const char *key, const char *default_value)
63 +command_from_prefs(const char *key, const char *env_name, const char *default_value)
67 @@ -763,6 +766,17 @@ command_from_prefs(const char *key, const char *default_value)
71 + if (env_name != NULL) {
72 + command = getenv(env_name);
73 + if (command != NULL) {
74 + return strdup(command);
78 + if (!default_value) {
82 cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);