WhitewaterFoundry / Fedora-Remix-for-WSL

Fedora Remix for Windows Subsystem for Linux.
Other
698 stars 51 forks source link

check to see if dbus-launch is running #88

Open akwebb1 opened 3 years ago

akwebb1 commented 3 years ago

I use xfce4-appfinder to launch apps including the xfce4-terminal. Whenever I start a new xfce4-terminal a new dbus-launch process is created. In 00-remix.sh it would be nice if we could check to see if the process is already up before starting a new one. e.g.

if dbus-daemon is installed then load it

if (command -v dbus-daemon >/dev/null 2>&1); then if [ -z $(pidof dbus-launch) ]; then eval "$(timeout 2s dbus-launch --auto-syntax)" fi fi

I am not sure if this would interfere with anything else, but it has solved my problem of dbus-launch processes piling up.

crramirez commented 3 years ago

Thank you for your contribution. We will test your solution and see if it interferes with anything

crramirez commented 3 years ago

Hello @akwebb1

In my case are the dbus-daemon processes instead of dbus-launch piling up. Is it a typo or in fact in your case the dbus-launch are pilling up.

Regards, Carlos

akwebb1 commented 3 years ago

I am pretty sure it was dbus-launch. I have an autohotkey script to launch xfce4-appfinder when I hit win+space. It was launching a new dbus-launch when xfce4-appfinder started an application since there was no parent dbus-daemon process. I have just moved to new PC today and have not installed fedora yet and I probably won't in the near future so I can't double check right now. My old machine is currently inaccessible. I used the same profile.d script snippit in Pengwin and Ubuntu so that it is already running when the wsl distribution starts so xfce4 does not launch a new one which worked great. If I get a chance I will give it another try once I finish getting my development environment running on the new machine.

crramirez commented 2 months ago

We went for this solution so the applications can reuse a previously started daemon

setup_dbus() {
  # if dbus-launch is installed then load it
  if ! (command -v dbus-launch >/dev/null); then
    return
  fi

  # Enabled via systemd
  if [ -n "${DBUS_SESSION_BUS_ADDRESS}" ]; then
    return
  fi

  dbus_pid="$(pidof dbus-daemon | cut -d' ' -f1)"

  if [ -z "${dbus_pid}" ]; then
    dbus_env="$(timeout 2s dbus-launch --auto-syntax)"
    eval "${dbus_env}"

    echo "${dbus_env}" >"/tmp/dbus_env_${DBUS_SESSION_BUS_PID}"

    unset dbus_env
  else # Running from a previous session
    eval "$(cat "/tmp/dbus_env_${dbus_pid}")"
  fi

  unset dbus_pid
}
crramirez commented 2 months ago

@akwebb1