Move the systemctl import-environment call after keyring setup so the SSH_AUTH_SOCK variable exists before being imported into the user service manager. Remove the earlier duplicate import block.
66 lines
2.4 KiB
Bash
Executable file
66 lines
2.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# From: https://people.debian.org/~mpitt/systemd.conf-2016-graphical-session.pdf
|
|
|
|
if command -v systemctl >/dev/null; then
|
|
# robustness: if the previous graphical session left some failed units,
|
|
# reset them so that they don't break this startup
|
|
for unit in $(systemctl --user --no-legend --state=failed --plain list-units | cut -f1 -d' '); do
|
|
partof="$(systemctl --user show -p PartOf --value "$unit")"
|
|
for target in cosmic-session.target graphical-session.target; do
|
|
if [ "$partof" = "$target" ]; then
|
|
systemctl --user reset-failed "$unit"
|
|
break
|
|
fi
|
|
done
|
|
done
|
|
fi
|
|
|
|
# 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}"
|
|
export XDG_SESSION_TYPE="${XDG_SESSION_TYPE:=wayland}"
|
|
export _JAVA_AWT_WM_NONREPARENTING=1
|
|
export GDK_BACKEND=wayland,x11
|
|
export MOZ_ENABLE_WAYLAND=1
|
|
export QT_QPA_PLATFORM="wayland;xcb"
|
|
export QT_AUTO_SCREEN_SCALE_FACTOR=1
|
|
export QT_ENABLE_HIGHDPI_SCALING=1
|
|
export DCONF_PROFILE=cosmic
|
|
|
|
# Start gnome keyring components if the daemon is active
|
|
# -> check if /run/user/$UID/keyring exists
|
|
if [ -d "/run/user/$(id -u)/keyring" ]; then
|
|
|
|
# Use PATH lookup instead of hardcoding /usr/bin
|
|
if command -v gnome-keyring-daemon >/dev/null 2>&1; then
|
|
eval "$(gnome-keyring-daemon --start --components=pkcs11,secrets,ssh > /dev/null 2>&1)"
|
|
else
|
|
echo "gnome-keyring-daemon not found in PATH" >&2
|
|
fi
|
|
|
|
# Set SSH_AUTH_SOCK to the standard gnome-keyring socket
|
|
export SSH_AUTH_SOCK="/run/user/$(id -u)/keyring/ssh"
|
|
fi
|
|
|
|
if command -v systemctl >/dev/null; then
|
|
# set environment variables for new units started by user service manager
|
|
systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP DCONF_PROFILE SSH_AUTH_SOCK
|
|
fi
|
|
|
|
# Run cosmic-session
|
|
if [[ -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then
|
|
exec /usr/bin/dbus-run-session -- /usr/bin/cosmic-session
|
|
else
|
|
exec /usr/bin/cosmic-session
|
|
fi
|