You are not logged in.

#1 2015-10-05 03:17:05

nbd
Member
Registered: 2014-08-04
Posts: 389

[SOLVED]Apps launched by D-Bus are unaware about environment variables

After the recent change in how D-Bus works, applications that are launched by it are not provided with environment variables. E.g.

notify-send "test"

causes the

org.freedesktop.Notifications[621]: cannot open display

(Note, that the display has an empty label.) From the D-Bus/User wiki it's a bit unclear what's the correct way to solve this problem. In '/etc/X11/xinit/xinitrc.d' directory I have '50-systemd-user.sh' file which has the following:

systemctl --user import-environment DISPLAY XAUTHORITY

if which dbus-update-activation-environment >/dev/null 2>&1; then
        dbus-update-activation-environment DISPLAY XAUTHORITY
fi

If this file is launched manually, 'notify-send' begins to work OK.

In the D-Bus/User wiki it's written that one of the ways of exporting env. variables to dbus applications is:

At any time, use systemctl --user set-environment or systemctl --user import-environment. Affects all user units started after setting the environment variables, but not the units that were already running.

Can the problem be an indication that the service unit (/usr/share/dbus-1/services/org.xfce.xfce4-notifyd.Notifications.service in my case) is started before the '50-systemd-user.sh'? If so, is there a correct way to ensure the right order of initialization apart from adding a script which exports environment variables for the second time?

Last edited by nbd (2015-10-05 09:15:04)


bing different

Offline

#2 2015-10-05 07:54:36

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED]Apps launched by D-Bus are unaware about environment variables

How are you starting X? If you're using a DM, which one? If you're using startx/xinit, post your ~/.xinitrc.

Offline

#3 2015-10-05 08:18:53

nbd
Member
Registered: 2014-08-04
Posts: 389

Re: [SOLVED]Apps launched by D-Bus are unaware about environment variables

I'm using XFCE and start DE manually from login shell by 'startxfce4' (I don't use 'startx').


bing different

Offline

#4 2015-10-05 08:51:28

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED]Apps launched by D-Bus are unaware about environment variables

Well, startxfce4 doesn't do anything with files in /etc/X11/xinit/xinitrc.d. Display managers execute these for you and if you use ~/.xinitrc the wiki advises you to not remove the part of the default xinitrc script that sources these scripts. Then 50-systemd-user.sh runs before you start any other applications and dbus activated apps will know $DISPLAY.

startxfce4 runs /etc/xdg/xfce4/xinitrc, which also doesn't refer to this xinitrc.d directory*. You can copy it to ~/.config/xfce4/xinitrc and modify that file to include the for loop you can find in the default xinitrc (and the xinitrc wiki page). Or you can use startx and `exec startxfce4` at the end of ~/.xinitrc (sourcing the xinitrc.d scripts before that, of course). startxfce4 will see that $DISPLAY is set and not start a second X, but it will still run /etc/xdg/xfce4/xinitrc to load Xresources and things like that so you don't have to do that in ~/.xinitrc.

* Note that /etc/xdg/xfce4/xinitrc startx xfce4-session if you have it and this is not a short script, so I haven't look at what it does, but from your description it seems that it doesn't handle this rather new dbus+systemd/user setup.

Last edited by Raynman (2015-10-05 08:52:02)

Offline

#5 2015-10-05 09:14:15

nbd
Member
Registered: 2014-08-04
Posts: 389

Re: [SOLVED]Apps launched by D-Bus are unaware about environment variables

I will try to create ~/.config/xfce4/xinitrc (it currently doesn't exist) and copy to it the init staff from the ~/.xinitrc. But first will try to start xfce4 via 'startx' (until the xfce4 adapts its configuration to the new scheme).  Thanks for the helping.


bing different

Offline

Board footer

Powered by FluxBB