From f5eb1456679641433f8021782ee4e29647bdcfad Mon Sep 17 00:00:00 2001 From: bryan Date: Wed, 21 Dec 2022 10:40:02 -0500 Subject: [PATCH] Make X11 service vars distro-specific --- installJRMC | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/installJRMC b/installJRMC index c351034..19f31ae 100755 --- a/installJRMC +++ b/installJRMC @@ -1071,7 +1071,7 @@ setDisplay() { setServiceVars() { debug "Running: ${FUNCNAME[0]}" - declare -g SERVICE_NAME SERVICE_FNAME TIMER_NAME TIMER_FNAME USER_STRING GRAPHICAL_TARGET + declare -g SERVICE_NAME SERVICE_FNAME TIMER_NAME TIMER_FNAME USER_STRING DISPLAY_STRING GRAPHICAL_TARGET declare -g SERVICE_TYPE="${SERVICE_TYPE:-system}" declare service_dir="/usr/lib/systemd/$SERVICE_TYPE" @@ -1099,6 +1099,17 @@ setServiceVars() { [[ ! -d "$service_dir" ]] && sudo mkdir -p "$service_dir" + # TODO Ubuntu needs these in the service file, fedora (and others?) does not + case "$ID" in + ubuntu|debian) + DISPLAY_STRING="Environment=DISPLAY=$DISPLAY" + DISPLAY_STRING+=$'\n'"Environment=XAUTHORITY=$XAUTHORITY" + ;; + *) + DISPLAY_STRING="" + ;; + esac + if [[ "$SERVICE_TYPE" == "system" && "$USER" != "root" ]]; then SERVICE_FNAME="$service_dir/${1}@.service" TIMER_FNAME="$service_dir/${1}@.timer" @@ -1132,7 +1143,10 @@ service_jriver-mediacenter() { [Service] $USER_STRING + $DISPLAY_STRING Type=simple + Environment=DISPLAY=$DISPLAY + Environment=XAUTHORITY=$XAUTHORITY ExecStart=/usr/bin/mediacenter$MVERSION $* Restart=always RestartSec=10