sway: do the WAYLAND_DISPLAY moving inside sway config itself
This commit is contained in:
@@ -8,7 +8,7 @@ let
|
|||||||
swayLauncher = pkgs.writeShellScriptBin "sway" ''
|
swayLauncher = pkgs.writeShellScriptBin "sway" ''
|
||||||
# delete DISPLAY-related vars from env before launch, else sway will try to connect to a remote display.
|
# 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)
|
# (consider: nested sway sessions, where sway actually has a reason to read these)
|
||||||
exec env -u DISPLAY -u WAYLAND_DISPLAY ${configuredSway}/bin/sway 2>&1
|
exec env -u DISPLAY -u WAYLAND_DISPLAY "REAL_WAYLAND_DISPLAY=$WAYLAND_DISPLAY" ${configuredSway}/bin/sway 2>&1
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
pkgs.symlinkJoin {
|
pkgs.symlinkJoin {
|
||||||
@@ -232,16 +232,7 @@ in
|
|||||||
'';
|
'';
|
||||||
# readiness.waitExists = "$SWAYSOCK";
|
# readiness.waitExists = "$SWAYSOCK";
|
||||||
readiness.waitCommand = pkgs.writeShellScript "sway-readycheck" ''
|
readiness.waitCommand = pkgs.writeShellScript "sway-readycheck" ''
|
||||||
# wait for sway to create its socket AND its wayland display.
|
test -e "$SWAYSOCK" && test -e "$WAYLAND_DISPLAY"
|
||||||
# it doesn't know to create the wayland display in the right directory, so have to manually move it socket... bleh.
|
|
||||||
# TODO: socket moving could be more reliable inside of the sway config
|
|
||||||
set -e
|
|
||||||
test -e "$SWAYSOCK"
|
|
||||||
expected_display="$XDG_RUNTIME_DIR/$(basename "$WAYLAND_DISPLAY")"
|
|
||||||
test -e "$expected_display" && test -e "$expected_display.lock"
|
|
||||||
set +e # make only a best-effort to move these; if it fails (because e.g. perms, or destination exists somehow), don't hold up init
|
|
||||||
mv "$expected_display" "$WAYLAND_DISPLAY"
|
|
||||||
mv "$expected_display.lock" "$WAYLAND_DISPLAY.lock"
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
# link the graphical-session into the default target, so sway gets auto-started
|
# link the graphical-session into the default target, so sway gets auto-started
|
||||||
|
@@ -236,6 +236,13 @@ output $out_moby {
|
|||||||
# scale 1.6
|
# scale 1.6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# 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)"
|
||||||
|
|
||||||
|
|
||||||
# manually export PATH here, since all my user services need that, and sane-sandboxed implementation depends on it.
|
# manually export PATH here, since all my user services need that, and sane-sandboxed implementation depends on it.
|
||||||
# also, manually export XDG_DATA_DIRS. glib fails in weird ways (e.g. thinks everything is application/x-octet-stream mime type) without it.
|
# also, manually export XDG_DATA_DIRS. glib fails in weird ways (e.g. thinks everything is application/x-octet-stream mime type) without it.
|
||||||
@@ -243,8 +250,8 @@ output $out_moby {
|
|||||||
#
|
#
|
||||||
# XXX: dbus-update-activation-environment --systemd is ASYNCHRONOUS. it returns before the systemd environment is actually updated.
|
# XXX: dbus-update-activation-environment --systemd is ASYNCHRONOUS. it returns before the systemd environment is actually updated.
|
||||||
# hence, call `systemctl import-environment` ourselves. i could probably remove the dbus stuff and be safe, but at least for now it's an OK backup.
|
# hence, call `systemctl import-environment` ourselves. i could probably remove the dbus stuff and be safe, but at least for now it's an OK backup.
|
||||||
exec --no-startup-id systemctl --user import-environment PATH XDG_DATA_DIRS DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
|
# exec --no-startup-id systemctl --user import-environment PATH XDG_DATA_DIRS DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
|
||||||
exec --no-startup-id dbus-update-activation-environment --systemd PATH XDG_DATA_DIRS DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
|
# exec --no-startup-id dbus-update-activation-environment --systemd PATH XDG_DATA_DIRS DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
|
||||||
|
|
||||||
# previously: `include /etc/sway/config.d/*` was needed for xdg-desktop-portal-* to work.
|
# previously: `include /etc/sway/config.d/*` was needed for xdg-desktop-portal-* to work.
|
||||||
# stock nixos `programs.sway` would setup /etc/sway/config.d with additional variables to import to the dbus env.
|
# stock nixos `programs.sway` would setup /etc/sway/config.d with additional variables to import to the dbus env.
|
||||||
|
Reference in New Issue
Block a user