From 9f256004e772593a7158427d6f623c74894f64dc Mon Sep 17 00:00:00 2001 From: Ron Waldon-Howe Date: Mon, 8 Jan 2024 09:09:55 +1100 Subject: [PATCH] fix: use preferred SHELL in login shell mode --- data/start-cosmic | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/data/start-cosmic b/data/start-cosmic index d8a4437..ccb8886 100755 --- a/data/start-cosmic +++ b/data/start-cosmic @@ -1,5 +1,7 @@ #!/bin/bash +set -e + # From: https://people.debian.org/~mpitt/systemd.conf-2016-graphical-session.pdf # robustness: if the previous graphical session left some failed units, @@ -14,13 +16,14 @@ for unit in $(systemctl --user --no-legend --state=failed --plain list-units | c done done -# /etc/profile contains a lot of important environment variables -source /etc/profile - -# load user's profile if it exists -if [ -n "${HOME}" -a -f "${HOME}/.profile" ] -then - source "${HOME}/.profile" +# use the user's preferred shell to acquire environment variables +# see: https://github.com/pop-os/cosmic-session/issues/23 +if [ -n "${SHELL}" ]; then + # --in-login-shell: our flag to indicate that we don't need to recurse any further + if [ "${1}" != "--in-login-shell" ]; then + # `exec -l`: like `login`, prefixes $SHELL with a hyphen to start a login shell + exec bash -c "exec -l '${SHELL}' -c '${0} --in-login-shell'" + fi fi export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:=COSMIC}"