summary refs log tree commit diff
path: root/pkgs/tools/X11/bumblebee/nixos.patch
blob: 00fb8ad7a5352ddd2c7a1d96f64e519d4529f019 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
diff --git a/conf/xorg.conf.nouveau b/conf/xorg.conf.nouveau
index 87e48cb..60d6eaf 100644
--- a/conf/xorg.conf.nouveau
+++ b/conf/xorg.conf.nouveau
@@ -15,4 +15,5 @@ Section "Device"
 #   This Setting is needed on Ubuntu 13.04.
 #   BusID "PCI:01:00:0"
 
+@nouveauDeviceOptions@
 EndSection
diff --git a/conf/xorg.conf.nvidia b/conf/xorg.conf.nvidia
index c3107f9..17072f4 100644
--- a/conf/xorg.conf.nvidia
+++ b/conf/xorg.conf.nvidia
@@ -29,6 +29,6 @@ Section "Device"
     Option "ProbeAllGpus" "false"
 
     Option "NoLogo" "true"
-    Option "UseEDID" "false"
-    Option "UseDisplayDevice" "none"
+
+@nvidiaDeviceOptions@
 EndSection
diff --git a/src/bbsecondary.c b/src/bbsecondary.c
index 71a6b73..a682d8a 100644
--- a/src/bbsecondary.c
+++ b/src/bbsecondary.c
@@ -145,6 +145,23 @@ bool start_secondary(bool need_secondary) {
     }
 
     bb_log(LOG_INFO, "Starting X server on display %s.\n", bb_config.x_display);
+    const char mod_appends[] = X_MODULE_APPENDS;
+
+    char *mod_path;
+    int pathlen = strlen(bb_config.mod_path);
+    if (pathlen == 0) {
+      mod_path = mod_appends;
+    } else {
+      mod_path = malloc(pathlen + 1 + sizeof(mod_appends));
+      if (!mod_path) {
+        set_bb_error("Could not allocate memory for modules path\n");
+        return false;
+      }
+      strcpy(mod_path, bb_config.mod_path);
+      mod_path[pathlen] = ',';
+      strcpy(mod_path + pathlen + 1, mod_appends);
+    }
+
     char *x_argv[] = {
       XORG_BINARY,
       bb_config.x_display,
@@ -153,24 +170,25 @@ bool start_secondary(bool need_secondary) {
       "-sharevts",
       "-nolisten", "tcp",
       "-noreset",
+      "-logfile", "/var/log/X.bumblebee.log",
+      "-xkbdir", X_XKB_DIR,
       "-verbose", "3",
       "-isolateDevice", pci_id,
-      "-modulepath", bb_config.mod_path, // keep last
+      "-modulepath", mod_path,
       NULL
     };
     enum {n_x_args = sizeof(x_argv) / sizeof(x_argv[0])};
-    if (!*bb_config.mod_path) {
-      x_argv[n_x_args - 3] = 0; //remove -modulepath if not set
-    }
     //close any previous pipe, if it (still) exists
     if (bb_status.x_pipe[0] != -1){close(bb_status.x_pipe[0]); bb_status.x_pipe[0] = -1;}
     if (bb_status.x_pipe[1] != -1){close(bb_status.x_pipe[1]); bb_status.x_pipe[1] = -1;}
     //create a new pipe
     if (pipe2(bb_status.x_pipe, O_NONBLOCK | O_CLOEXEC)){
       set_bb_error("Could not create output pipe for X");
+      if (pathlen > 0) free(mod_path);
       return false;
     }
     bb_status.x_pid = bb_run_fork_ld_redirect(x_argv, bb_config.ld_path, bb_status.x_pipe[1]);
+    if (pathlen > 0) free(mod_path);
     //close the end of the pipe that is not ours
     if (bb_status.x_pipe[1] != -1){close(bb_status.x_pipe[1]); bb_status.x_pipe[1] = -1;}
   }