2022-07-12 11:55:53 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-01-08 09:09:55 +11:00
|
|
|
set -e
|
|
|
|
|
|
2022-07-12 11:55:53 -04:00
|
|
|
# From: https://people.debian.org/~mpitt/systemd.conf-2016-graphical-session.pdf
|
|
|
|
|
|
2024-01-09 15:50:00 +11:00
|
|
|
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
|
2022-07-12 11:55:53 -04:00
|
|
|
done
|
2024-01-09 15:50:00 +11:00
|
|
|
fi
|
2022-07-12 11:55:53 -04:00
|
|
|
|
2024-01-08 09:09:55 +11:00
|
|
|
# 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
|
2022-09-23 10:39:43 -06:00
|
|
|
fi
|
|
|
|
|
|
2023-12-22 10:34:47 -05:00
|
|
|
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:=COSMIC}"
|
2022-07-12 11:55:53 -04:00
|
|
|
export XDG_SESSION_TYPE="${XDG_SESSION_TYPE:=wayland}"
|
2022-10-24 14:03:45 -04:00
|
|
|
export _JAVA_AWT_WM_NONREPARENTING=1
|
2023-01-25 11:07:56 -05:00
|
|
|
export GDK_BACKEND=wayland,x11
|
|
|
|
|
export MOZ_ENABLE_WAYLAND=1
|
2023-12-19 21:50:47 +01:00
|
|
|
export QT_QPA_PLATFORM="wayland;xcb"
|
2024-08-27 17:27:09 +02:00
|
|
|
export QT_AUTO_SCREEN_SCALE_FACTOR=1
|
|
|
|
|
export QT_ENABLE_HIGHDPI_SCALING=1
|
2024-11-21 16:50:08 +01:00
|
|
|
export DCONF_PROFILE=cosmic
|
2022-07-12 11:55:53 -04:00
|
|
|
|
2025-06-11 14:49:02 +02:00
|
|
|
if command -v systemctl >/dev/null; then
|
2024-01-09 15:50:00 +11:00
|
|
|
# set environment variables for new units started by user service manager
|
2025-06-11 14:49:02 +02:00
|
|
|
systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP DCONF_PROFILE
|
2024-01-09 15:50:00 +11:00
|
|
|
fi
|
2022-07-12 11:55:53 -04:00
|
|
|
# Run cosmic-session
|
2022-07-13 12:04:16 -04:00
|
|
|
if [[ -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then
|
|
|
|
|
exec /usr/bin/dbus-run-session -- /usr/bin/cosmic-session
|
|
|
|
|
else
|
|
|
|
|
exec /usr/bin/cosmic-session
|
|
|
|
|
fi
|
2025-08-20 18:03:55 +00:00
|
|
|
|
|
|
|
|
# Start gnome keyring components if the daemon is active
|
|
|
|
|
# -> check if /run/user/$UID/keyring exists
|
|
|
|
|
if [ -d "/run/user/$(id -u)/keyring" ]; then
|
|
|
|
|
|
|
|
|
|
# start pkcs11, secrets, and ssh components
|
|
|
|
|
/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh
|
|
|
|
|
|
|
|
|
|
fi
|