From da05005665a1edc3f2f4370271de69e4e800e018 Mon Sep 17 00:00:00 2001
From: Salt <rehashedsalt@cock.li>
Date: Sat, 25 Jul 2020 19:47:48 -0500
Subject: [PATCH] Refactor dbus launch code This should fix not launching dbus
 when we certainly can

---
 firestarter | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/firestarter b/firestarter
index 5d332e6..f4e16b1 100755
--- a/firestarter
+++ b/firestarter
@@ -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