Make X11 service vars distro-specific

This commit is contained in:
2022-12-21 10:40:02 -05:00
parent 64c3c168a4
commit f5eb145667

View File

@@ -1071,7 +1071,7 @@ setDisplay() {
setServiceVars() { setServiceVars() {
debug "Running: ${FUNCNAME[0]}" 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 -g SERVICE_TYPE="${SERVICE_TYPE:-system}"
declare service_dir="/usr/lib/systemd/$SERVICE_TYPE" declare service_dir="/usr/lib/systemd/$SERVICE_TYPE"
@@ -1099,6 +1099,17 @@ setServiceVars() {
[[ ! -d "$service_dir" ]] && sudo mkdir -p "$service_dir" [[ ! -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 if [[ "$SERVICE_TYPE" == "system" && "$USER" != "root" ]]; then
SERVICE_FNAME="$service_dir/${1}@.service" SERVICE_FNAME="$service_dir/${1}@.service"
TIMER_FNAME="$service_dir/${1}@.timer" TIMER_FNAME="$service_dir/${1}@.timer"
@@ -1132,7 +1143,10 @@ service_jriver-mediacenter() {
[Service] [Service]
$USER_STRING $USER_STRING
$DISPLAY_STRING
Type=simple Type=simple
Environment=DISPLAY=$DISPLAY
Environment=XAUTHORITY=$XAUTHORITY
ExecStart=/usr/bin/mediacenter$MVERSION $* ExecStart=/usr/bin/mediacenter$MVERSION $*
Restart=always Restart=always
RestartSec=10 RestartSec=10