Page 1 of 1

run-as-spot with dbus

Posted: Fri Aug 23, 2024 9:51 am
by Caramel

The Visual Studio Code binary available on the official site ( the .tar.gz file for x64 on https://code.visualstudio.com/Download) refuses to start when launched as root.
When launched as spot via run-as-spot, there is a problem with dbus session missing

So this is a try to create a run-as-spot command that lauches a dbus session.

The code comes directly from files of the type "application.bin" where application is a flatpak

Two scripts:

run-as-spot-with-dbus

Code: Select all

#!/bin/sh
run-as-spot dbus-launch-spot "$*"

that launches dbus-launch-spot

Code: Select all

#!/bin/sh
APPlow="$1"
HOME=/home/spot
busybox ps | grep -q ' ${APPlow:0:8}.*dbus\-daemon'
DBUSflg=$?
if [ $DBUSflg -ne 0 ];then
 export $(dbus-launch) #if app needs to access dbus.
 echo "DBUS_SESSION_BUS_ADDRESS='${DBUS_SESSION_BUS_ADDRESS}'
DBUS_SESSION_BUS_PID='${DBUS_SESSION_BUS_PID}'" > ${HOME}/.DBUS-DAEMON-VARS
else 
 if [ -s ${HOME}/.DBUS-DAEMON-VARS ];then
  eval $(cat ${HOME}/.DBUS-DAEMON-VARS)
  export DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
 fi
fi

$*

pidof -o ${$} ${APPlow} >/dev/null
if [ $? -ne 0 ];then
 kill $DBUS_SESSION_BUS_PID
 rm -f ${HOME}/.DBUS-DAEMON-VARS 2>/dev/null
fi

It seems to work with Visual Studio Code, but as I don't fully understand it, the code needs to be revised.