about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--home/profiles/gui/default.nix17
-rw-r--r--overlays/patches/wlroots-displaylink/DisplayLink_v2.patch48
2 files changed, 62 insertions, 3 deletions
diff --git a/home/profiles/gui/default.nix b/home/profiles/gui/default.nix
index 2fbb505..56b9b04 100644
--- a/home/profiles/gui/default.nix
+++ b/home/profiles/gui/default.nix
@@ -1,4 +1,4 @@
-{ config, lib, inputs, pkgs, self, ... }:
+{ config, options, lib, inputs, pkgs, self, ... }:
 let
   cfg = config.profiles.gui;
 
@@ -103,6 +103,17 @@ in
     wayland.windowManager.sway = {
       enable = true;
 
+      package =
+        if cfg.laptop.enable then
+          options.wayland.windowManager.sway.package.default.override
+            (prev: {
+              sway-unwrapped = prev.sway-unwrapped.override (s-prev: {
+                wlroots = s-prev.wlroots.overrideAttrs {
+                  patches = [ ../../../overlays/patches/wlroots-displaylink/DisplayLink_v2.patch ];
+                };
+              });
+            }) else options.wayland.windowManager.sway.package.default;
+
       wrapperFeatures = {
         base = true;
         gtk = true;
@@ -201,8 +212,8 @@ in
             [{
               # 10m (desktop only)
               timeout = 600;
-              command = "${pkgs.sway}/bin/swaymsg 'output * dpms off'";
-              resumeCommand = "${pkgs.sway}/bin/swaymsg 'output * dpms on'";
+              command = "${config.wayland.windowManager.sway.package}/bin/swaymsg 'output * dpms off'";
+              resumeCommand = "${config.wayland.windowManager.sway.package}/bin/swaymsg 'output * dpms on'";
             }] ++ [
             {
               # 10m on laptops, 15m on desktop
diff --git a/overlays/patches/wlroots-displaylink/DisplayLink_v2.patch b/overlays/patches/wlroots-displaylink/DisplayLink_v2.patch
new file mode 100644
index 0000000..dcdef7a
--- /dev/null
+++ b/overlays/patches/wlroots-displaylink/DisplayLink_v2.patch
@@ -0,0 +1,48 @@
+diff --git a/render/egl.c b/render/egl.c
+index 8a1e6dae..d0e6adb6 100644
+--- a/render/egl.c
++++ b/render/egl.c
+@@ -508,8 +508,43 @@ static int open_render_node(int drm_fd) {
+ 		}
+ 		wlr_log(WLR_DEBUG, "DRM device '%s' has no render node, "
+ 			"falling back to primary node", render_name);
++
++		drmVersion *render_version = drmGetVersion(drm_fd);
++		if (render_version != NULL && render_version->name != NULL) {
++			wlr_log(WLR_DEBUG, "DRM device version.name '%s'", render_version->name);
++			if (strcmp(render_version->name, "evdi") == 0) {
++				free(render_name);
++
++				uint32_t flags = 0;
++				const int devices_len = drmGetDevices2(flags, NULL, 0);
++				if (devices_len < 0) {
++					wlr_log(WLR_ERROR, "drmGetDevices2 failed: %s", strerror(-devices_len));
++					return -1;
++				}
++
++				const char *render_devices[] = {
++					"/dev/dri/card0",
++					"/dev/dri/card1",
++					"/dev/dri/card2",
++					"/dev/dri/card3",
++					"/dev/dri/card4",
++					"/dev/dri/card5",
++					"/dev/dri/card6",
++					"/dev/dri/card7",
++					"/dev/dri/card8",
++					"/dev/dri/card9",
++					NULL
++				};
++
++				render_name = malloc(sizeof(char)*15);
++				render_name = strcpy(render_name, render_devices[env_parse_switch("WLR_EVDI_RENDER_DEVICE", render_devices)]);
++			}
++			drmFreeVersion(render_version);
++		}
+ 	}
+
++	wlr_log(WLR_DEBUG, "open_render_node() DRM device '%s'", render_name);
++
+ 	int render_fd = open(render_name, O_RDWR | O_CLOEXEC);
+ 	if (render_fd < 0) {
+ 		wlr_log_errno(WLR_ERROR, "Failed to open DRM node '%s'", render_name);