From 062602d81e9b12320698ff32356cf03444cfae51 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sat, 1 Dec 2018 15:00:19 +0100 Subject: [PATCH] nixos/sway-beta: Improve the wrapper According to the dbus-launch documentation [0] "--exit-with-session" shouldn't be used: "This option is not recommended, since it will consume input from the terminal where it was started; it is mainly provided for backwards compatibility." And it also states: "To start a D-Bus session within a text-mode session, do not use dbus-launch. Instead, see dbus-run-session(1)." The new wrapper also avoids starting an additional D-Bus session if DBUS_SESSION_BUS_ADDRESS is already set. Fix #51303. [0]: https://dbus.freedesktop.org/doc/dbus-launch.1.html [1]: https://dbus.freedesktop.org/doc/dbus-run-session.1.html --- nixos/modules/programs/sway-beta.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nixos/modules/programs/sway-beta.nix b/nixos/modules/programs/sway-beta.nix index 8447f94ca254..7fc5979a38aa 100644 --- a/nixos/modules/programs/sway-beta.nix +++ b/nixos/modules/programs/sway-beta.nix @@ -7,8 +7,19 @@ let swayPackage = cfg.package; swayWrapped = pkgs.writeShellScriptBin "sway" '' - ${cfg.extraSessionCommands} - exec ${pkgs.dbus.dbus-launch} --exit-with-session ${swayPackage}/bin/sway "$@" + set -o errexit + + if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then + export _SWAY_WRAPPER_ALREADY_EXECUTED=1 + ${cfg.extraSessionCommands} + fi + + if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then + export DBUS_SESSION_BUS_ADDRESS + exec ${swayPackage}/bin/sway "$@" + else + exec ${pkgs.dbus}/bin/dbus-run-session ${swayPackage}/bin/sway "$@" + fi ''; swayJoined = pkgs.symlinkJoin { name = "sway-joined";