From 46fe6c690b63d299d68053e4398602f5ab8866b7 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 23 Mar 2024 17:59:37 +0000 Subject: [PATCH] sway: fix WAYLAND_DISPLAY to be relative --- hosts/common/programs/sway/default.nix | 9 +++++---- hosts/common/programs/sway/sway-config | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hosts/common/programs/sway/default.nix b/hosts/common/programs/sway/default.nix index dde51c98..8968336e 100644 --- a/hosts/common/programs/sway/default.nix +++ b/hosts/common/programs/sway/default.nix @@ -8,7 +8,7 @@ let swayLauncher = pkgs.writeShellScriptBin "sway" '' # delete DISPLAY-related vars from env before launch, else sway will try to connect to a remote display. # (consider: nested sway sessions, where sway actually has a reason to read these) - exec env -u DISPLAY -u WAYLAND_DISPLAY "REAL_WAYLAND_DISPLAY=$WAYLAND_DISPLAY" ${configuredSway}/bin/sway 2>&1 + exec env -u DISPLAY -u WAYLAND_DISPLAY "DESIRED_WAYLAND_DISPLAY=$WAYLAND_DISPLAY" ${configuredSway}/bin/sway 2>&1 ''; in pkgs.symlinkJoin { @@ -214,7 +214,8 @@ in # TODO: ensure this is reliable? might not work across sway restarts, etc. env.DISPLAY = ":0"; # docs: - env.WAYLAND_DISPLAY = "$XDG_RUNTIME_DIR/wayland/wayland-1"; + # N.B.: gtk apps support absolute paths for this; webkit apps (e.g. geary) support only relative paths (relative to $XDG_RUNTIME_DIR) + env.WAYLAND_DISPLAY = "wayland/wayland-1"; services.sway = { description = "sway: tiling wayland desktop environment"; @@ -222,11 +223,11 @@ in command = pkgs.writeShellScript "sway-start" '' # have to create these directories before launching sway so that they're available in the sandbox mkdir -p "$(dirname "$SWAYSOCK")" - mkdir -p "$(dirname "$WAYLAND_DISPLAY")" + mkdir -p "$(dirname "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY")" mkdir -p /tmp/.X11-unix # for Xwayland exec sway ''; - readiness.waitExists = [ "$SWAYSOCK" "$WAYLAND_DISPLAY" ]; + readiness.waitExists = [ "$SWAYSOCK" "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]; }; # link the graphical-session into the default target, so sway gets auto-started services.graphical-session.partOf = [ "default" ]; diff --git a/hosts/common/programs/sway/sway-config b/hosts/common/programs/sway/sway-config index dd81d34f..429d98a0 100644 --- a/hosts/common/programs/sway/sway-config +++ b/hosts/common/programs/sway/sway-config @@ -237,11 +237,11 @@ output $out_moby { } # move the wayland socket that sway implicitly created to the place which other apps expect to find it -exec --no-startup-id mv $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY $REAL_WAYLAND_DISPLAY -exec --no-startup-id mv $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY.lock $REAL_WAYLAND_DISPLAY.lock +exec --no-startup-id mv $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY $XDG_RUNTIME_DIR/$DESIRED_WAYLAND_DISPLAY +exec --no-startup-id mv $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY.lock $XDG_RUNTIME_DIR/$DESIRED_WAYLAND_DISPLAY.lock # i'm sure there's a simpler way. not certain that this actually updates the sway environment variables anyway # the double-$ means to set the variable at *runtime*, not at "compile-time" (so that it doesn't impact the line immediately above us -set $$WAYLAND_DISPLAY "$(echo $REAL_WAYLAND_DISPLAY)" +set $$WAYLAND_DISPLAY "$(echo $DESIRED_WAYLAND_DISPLAY)" # manually export PATH here, since all my user services need that, and sane-sandboxed implementation depends on it.