Refactor dbus launch code

This should fix not launching dbus when we certainly can
This commit is contained in:
Salt 2020-07-25 19:47:48 -05:00
parent 643fba814a
commit da05005665

View File

@ -159,17 +159,11 @@ step_preexecute() {
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
if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; 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
elif [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && has dbus-launch; then
# We have dbus but haven't started it yet
eval "$(dbus-launch --exit-with-session --sh-syntax)"
_hasdbus=1
@ -179,7 +173,7 @@ step_preexecute() {
# Nest protection
if [ -n "$_hasdbus" ]; then
log "Exporting to dbus: FIRESTARTER FIRESTARTER_DISPLAY"
dbus-update-activation-environment FIRESTARTER FIRESTARTER_DISPLAY
dbus-update-activation-environment --systemd FIRESTARTER FIRESTARTER_DISPLAY
fi
# IME settings
if has uim; then
@ -193,7 +187,7 @@ step_preexecute() {
fi
if [ -n "$_hasdbus" ]; then
log "Exporting to dbus: GTK_IM_MODULE QT_IM_MODULE XMODIFIERS"
dbus-update-activation-environment GTK_IM_MODULE QT_IM_MODULE XMODIFIERS
dbus-update-activation-environment --systemd GTK_IM_MODULE QT_IM_MODULE XMODIFIERS
fi
# kcminit/Qt settings
if has qt5ct; then
@ -212,7 +206,7 @@ step_preexecute() {
fi
if [ -n "$_hasdbus" ]; then
log "Exporting to dbus: QT_QPA_PLATFORMTHEME QT_AUTO_SCREEN_SCALE_FACTOR"
dbus-update-activation-environment QT_QPA_PLATFORMTHEME QT_AUTO_SCREEN_SCALE_FACTOR
dbus-update-activation-environment --systemd QT_QPA_PLATFORMTHEME QT_AUTO_SCREEN_SCALE_FACTOR
fi
fi
if has kcminit; then