Reorganize dbus setup order

This commit is contained in:
Salt 2020-07-21 12:10:08 -05:00
parent 34d8336cd8
commit e9bc4482a1

View File

@ -19,6 +19,7 @@ declare -i _opthelp
declare -i _optverbose
# Working variables
declare -a _args
declare -i _hasdbus
declare _return
# Helper functions
@ -157,29 +158,6 @@ step_preexecute() {
[ -n "$FIRESTARTER" ] && [ "$FIRESTARTER_DISPLAY" == "$DISPLAY" ] error "Firestarter is already running on $DISPLAY: $FIRESTARTER" 55
export FIRESTARTER="$BASHPID"
export FIRESTARTER_DISPLAY="$DISPLAY"
# dbus
if \
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
[ -n "$XDG_RUNTIME_DIR" ] && \
[ "$XDG_RUNTIME_DIR" = "/run/user/$(id -u)" ] && \
[ -S "$XDG_RUNTIME_DIR/bus" ]; then
# We already have a bus started; use it
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
hasdbus=1
elif \
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
has dbus-launch; then
# We have dbus but haven't started it yet
eval "$(dbus-laucnh --exit-with-session --sh-syntax)"
hasdbus=1
else
warn "Did not start dbus; some applications may misbehave"
fi
if [ -n "$hasdbus" ]; then
has dbus-update-activation-environment && \
dbus-update-activation-environment --verbose --systemd --all >/dev/null 2>&1
fi
unset hasdbus
# IME settings
if has uim; then
export GTK_IM_MODULE='uim'
@ -212,6 +190,25 @@ step_preexecute() {
# Disabled here because an XDGCD of KDE implies kded and other KDE parts, breaking copypasta and other things
#export XDG_CURRENT_DESKTOP="KDE"
fi
# dbus
# We initialize this after setting envvars so it propogates to the whole session
if \
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
[ -n "$XDG_RUNTIME_DIR" ] && \
[ "$XDG_RUNTIME_DIR" = "/run/user/$(id -u)" ] && \
[ -S "$XDG_RUNTIME_DIR/bus" ]; then
# We already have a bus started; use it
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
_hasdbus=1
elif \
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
has dbus-launch; then
# We have dbus but haven't started it yet
eval "$(dbus-laucnh --exit-with-session --sh-syntax)"
_hasdbus=1
else
warn "Did not start dbus; some applications may misbehave"
fi
# xhost
if has xhost; then
if xhost +si:localuser:"$(id -un)" >/dev/null 2>&1; then
@ -278,6 +275,11 @@ step_postexecute() {
log "Executing rc script: $firestarterrc"
"$firestarterrc"
fi
# Propogate environment variables
if [ -n "$_hasdbus" ]; then
has dbus-update-activation-environment && \
dbus-update-activation-environment --verbose --systemd --all >/dev/null 2>&1
fi
# Start XDG autostarters, if they exist
if [ -z "$_optdryrun" ]; then
if has dex; then