Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 84 lines 3.3 kB view raw
1This patch makes it possible (and necessary) to specify the default 2shell, xterm client, and startx script from environment variables. These 3defaults are used when launching the XQuartz.app, which in turn needs to know 4how to start the X server. `startx' comes from the `xinit' package, 5which also has a dependency on `xorg-server', so we can't hardcode 6sane defaults. If the environment variables are specified, they 7override any value in the preferences settings. 8 9When developing an installable package for XQuartz/XQuartz.app, we'll 10need to set an `LSEnvironment' entry in the plist for the XQuartz.app. 11(See stub.patch for more details.). 12 13diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c 14index 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; 19 #endif 20 21-#define DEFAULT_CLIENT X11BINDIR "/xterm" 22-#define DEFAULT_STARTX X11BINDIR "/startx -- " X11BINDIR "/Xquartz" 23 #define DEFAULT_SHELL "/bin/sh" 24 25 #define _STRINGIZE(s) #s 26@@ -108,7 +106,7 @@ server_main(int argc, char **argv, char **envp); 27 static int 28 execute(const char *command); 29 static char * 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); 32 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) 36 pid_t child1, child2; 37 int status; 38 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", 42+ NULL); 43 assert(pref_app_to_run); 44 45- pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL); 46+ pref_login_shell = command_from_prefs("login_shell", 47+ "XQUARTZ_DEFAULT_SHELL", 48+ DEFAULT_SHELL); 49 assert(pref_login_shell); 50 51 pref_startx_script = command_from_prefs("startx_script", 52- DEFAULT_STARTX); 53+ "XQUARTZ_DEFAULT_STARTX", 54+ NULL); 55 assert(pref_startx_script); 56 57 /* Do the fork-twice trick to avoid having to reap zombies */ 58@@ -753,7 +756,7 @@ execute(const char *command) 59 } 60 61 static char * 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) 64 { 65 char *command = NULL; 66 67@@ -763,6 +766,17 @@ command_from_prefs(const char *key, const char *default_value) 68 if (!key) 69 return NULL; 70 71+ if (env_name != NULL) { 72+ command = getenv(env_name); 73+ if (command != NULL) { 74+ return strdup(command); 75+ } 76+ } 77+ 78+ if (!default_value) { 79+ return NULL; 80+ } 81+ 82 cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII); 83 84 if (!cfKey)