Merge pull request #32 from jokeyrhyme/optional-systemd
fix: check before using `systemctl`
This commit is contained in:
commit
9b1a72db93
1 changed files with 16 additions and 13 deletions
|
|
@ -2,17 +2,19 @@
|
||||||
|
|
||||||
# From: https://people.debian.org/~mpitt/systemd.conf-2016-graphical-session.pdf
|
# From: https://people.debian.org/~mpitt/systemd.conf-2016-graphical-session.pdf
|
||||||
|
|
||||||
# robustness: if the previous graphical session left some failed units,
|
if command -v systemctl >/dev/null; then
|
||||||
# reset them so that they don't break this startup
|
# robustness: if the previous graphical session left some failed units,
|
||||||
for unit in $(systemctl --user --no-legend --state=failed --plain list-units | cut -f1 -d' '); do
|
# reset them so that they don't break this startup
|
||||||
partof="$(systemctl --user show -p PartOf --value "$unit")"
|
for unit in $(systemctl --user --no-legend --state=failed --plain list-units | cut -f1 -d' '); do
|
||||||
for target in cosmic-session.target graphical-session.target; do
|
partof="$(systemctl --user show -p PartOf --value "$unit")"
|
||||||
if [ "$partof" = "$target" ]; then
|
for target in cosmic-session.target graphical-session.target; do
|
||||||
systemctl --user reset-failed "$unit"
|
if [ "$partof" = "$target" ]; then
|
||||||
break
|
systemctl --user reset-failed "$unit"
|
||||||
fi
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
done
|
done
|
||||||
done
|
fi
|
||||||
|
|
||||||
# /etc/profile contains a lot of important environment variables
|
# /etc/profile contains a lot of important environment variables
|
||||||
source /etc/profile
|
source /etc/profile
|
||||||
|
|
@ -31,9 +33,10 @@ export GDK_BACKEND=wayland,x11
|
||||||
export MOZ_ENABLE_WAYLAND=1
|
export MOZ_ENABLE_WAYLAND=1
|
||||||
export QT_QPA_PLATFORM="wayland;xcb"
|
export QT_QPA_PLATFORM="wayland;xcb"
|
||||||
|
|
||||||
# import environment variables from the login manager
|
if command -v systemctl >/dev/null; then
|
||||||
systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP
|
# set environment variables for new units started by user service manager
|
||||||
|
systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP
|
||||||
|
fi
|
||||||
# Run cosmic-session
|
# Run cosmic-session
|
||||||
if [[ -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then
|
if [[ -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then
|
||||||
exec /usr/bin/dbus-run-session -- /usr/bin/cosmic-session
|
exec /usr/bin/dbus-run-session -- /usr/bin/cosmic-session
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue