From a39d39ec1e5d9c04dfc45c503b494cbcaa9d5433 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 27 Jun 2024 15:42:00 +0200 Subject: [PATCH] greetd: Run session command from user's shell --- .../roles/workstation/display/login/greetd.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/system/roles/workstation/display/login/greetd.nix b/system/roles/workstation/display/login/greetd.nix index cf39101..21690d5 100644 --- a/system/roles/workstation/display/login/greetd.nix +++ b/system/roles/workstation/display/login/greetd.nix @@ -16,6 +16,20 @@ sessionData = config.services.displayManager.sessionData.desktops; + # Run the session / application using the appropriate shell configured for this user. + # This will make sure all of the environment variables are set before the WM session + # is started. This is very important, as without it, variables for things like qt theme + # will not be set, and applications executed by the WM will not be themed properly. + sessionWrapperScript = pkgs.writeShellScriptBin "tuigreet-session-wrapper" '' + set -euo pipefail + + script_name="$0" + shell="$(getent passwd itsdrike | awk -F: '{print $NF}')" + command=("$@") + + exec "$shell" -c 'exec "$@"' "$script_name" "''${command[@]}" + ''; + defaultSession = { user = "greeter"; command = concatStringsSep " " [ @@ -28,6 +42,8 @@ "--theme ${tuiGreetTheme}" "--sessions '${sessionData}/share/wayland-sessions'" "--xsessions '${sessionData}/share/xsessions'" + "--session-wrapper ${sessionWrapperScript}/bin/tuigreet-session-wrapper" + "--xsession-wrapper ${sessionWrapperScript}/bin/tuigreet-session-wrapper startx /usr/bin/env \"$@\"" ]; }; in {