all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dbus: "(setenv ...)" not the same as "export ...=..."
@ 2011-10-29 23:44 Peter Münster
  2011-10-30  8:51 ` Michael Albinus
  2011-11-02  4:56 ` Kevin Rodgers
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Münster @ 2011-10-29 23:44 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

Emacs is the only program, that requires the DBUS_SESSION_BUS_ADDRESS
environment variable, so instead of setting it in the global environment,
I prefer to set it in my .emacs file:

--8<---------------cut here---------------start------------->8---
(when window-system
  (unless (getenv "DBUS_SESSION_BUS_ADDRESS")
    (setenv "DBUS_SESSION_BUS_ADDRESS" "autolaunch:"))
  (require 'notifications))
--8<---------------cut here---------------end--------------->8---

But it does not work: D-Bus error: "No connection to bus", :session

The workaround is to start emacs like this:
DBUS_SESSION_BUS_ADDRESS=autolaunch: emacs

Could anybody explain, why emacs needs the DBUS_SESSION_BUS_ADDRESS (or
why other programs don't need it), and why setting it with (setenv ...)
does not work?

TIA for any hints!

P.S.: I don't know, where the dbus is started on my system, the parent
PID is 1. Perhaps from xinit or fvwm, how can I know?

-- 
           Peter




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dbus: "(setenv ...)" not the same as "export ...=..."
  2011-10-29 23:44 dbus: "(setenv ...)" not the same as "export ...=..." Peter Münster
@ 2011-10-30  8:51 ` Michael Albinus
  2011-10-30 15:08   ` Peter Münster
  2011-11-02  4:56 ` Kevin Rodgers
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2011-10-30  8:51 UTC (permalink / raw)
  To: Peter Münster; +Cc: help-gnu-emacs

pmlists@free.fr (Peter Münster) writes:

> Hello,

Hi,

> Emacs is the only program, that requires the DBUS_SESSION_BUS_ADDRESS
> environment variable,

Nope. $DBUS_SESSION_BUS_ADDRESS is used to identify the respective D-Bus
session bus, for any application connecting to D-Bus. Other applications
might start the session bus if they don't find it. In Emacs we have
discarded this feature, see <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6579> 
for the reasoning.

> so instead of setting it in the global environment,
> I prefer to set it in my .emacs file:
>
> (when window-system
>   (unless (getenv "DBUS_SESSION_BUS_ADDRESS")
>     (setenv "DBUS_SESSION_BUS_ADDRESS" "autolaunch:"))
>   (require 'notifications))
>
> But it does not work: D-Bus error: "No connection to bus", :session
>
> The workaround is to start emacs like this:
> DBUS_SESSION_BUS_ADDRESS=autolaunch: emacs
>
> Could anybody explain, why emacs needs the DBUS_SESSION_BUS_ADDRESS (or
> why other programs don't need it), and why setting it with (setenv ...)
> does not work?

I do not see the use case for starting the D-Bus session bus from inside
Emacs. In this case, you could only communicate with D-Bus-aware
applications which have been started from inside Emacs as well, other
applications won't see your session bus.

> TIA for any hints!

> P.S.: I don't know, where the dbus is started on my system, the parent
> PID is 1. Perhaps from xinit or fvwm, how can I know?

Best regards, Michael.

PS: I'm not able to respond for the next days, we're just starting to go
to the Baltic sea for some relaxed days. Being back next Sunday.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dbus: "(setenv ...)" not the same as "export ...=..."
  2011-10-30  8:51 ` Michael Albinus
@ 2011-10-30 15:08   ` Peter Münster
  2011-11-07 10:07     ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Münster @ 2011-10-30 15:08 UTC (permalink / raw)
  To: help-gnu-emacs

On Sun, Oct 30 2011, Michael Albinus wrote:

>> Emacs is the only program, that requires the DBUS_SESSION_BUS_ADDRESS
>> environment variable,
>
> Nope.

Better: emacs is the only program, that I know...
(my personal experience is quite limited ;)


> I do not see the use case for starting the D-Bus session bus from inside
> Emacs. In this case, you could only communicate with D-Bus-aware
> applications which have been started from inside Emacs as well, other
> applications won't see your session bus.

I don't want to start it from emacs. It has already been started from
somewhere at the start of the X-session. The "address=autolaunch"
permits emacs to find the dbus-daemon.

From the dbus-launch man page:
  "If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to
   use D-Bus, by default the process will attempt to invoke dbus-launch
   with the --autolaunch option to start up a new session bus or find
   the existing bus address on the X display or in a file in
   ~/.dbus/session-bus/"

It seems, that emacs does this only, if DBUS_SESSION_BUS_ADDRESS is set
to "autolaunch:", but not if it is unset. And (setenv ...) does not
work, it must be set from outside emacs.

-- 
           Peter




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dbus: "(setenv ...)" not the same as "export ...=..."
  2011-10-29 23:44 dbus: "(setenv ...)" not the same as "export ...=..." Peter Münster
  2011-10-30  8:51 ` Michael Albinus
@ 2011-11-02  4:56 ` Kevin Rodgers
  2011-11-02 21:54   ` Peter Münster
  1 sibling, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2011-11-02  4:56 UTC (permalink / raw)
  To: help-gnu-emacs

On 10/29/11 5:44 PM, Peter Münster wrote:
> Hello,
>
> Emacs is the only program, that requires the DBUS_SESSION_BUS_ADDRESS
> environment variable, so instead of setting it in the global environment,
> I prefer to set it in my .emacs file:
>
> --8<---------------cut here---------------start------------->8---
> (when window-system
>    (unless (getenv "DBUS_SESSION_BUS_ADDRESS")
>      (setenv "DBUS_SESSION_BUS_ADDRESS" "autolaunch:"))
>    (require 'notifications))
> --8<---------------cut here---------------end--------------->8---
>
> But it does not work: D-Bus error: "No connection to bus", :session
>
> The workaround is to start emacs like this:
> DBUS_SESSION_BUS_ADDRESS=autolaunch: emacs
>
> Could anybody explain, why emacs needs the DBUS_SESSION_BUS_ADDRESS (or
> why other programs don't need it), and why setting it with (setenv ...)
> does not work?

setenv modifies the process-environment variable, which affects subprocesses
of the Emacs OS process.  If setting a variable with setenv doesn't work, I
think it means that the OS process that reads the variable was not spawned
from Emacs (or the process was spawned before the variable was set).

Could the process that reads DBUS_SESSION_BUS_ADDRESS be Emacs itself?

> TIA for any hints!
>
> P.S.: I don't know, where the dbus is started on my system, the parent
> PID is 1. Perhaps from xinit or fvwm, how can I know?

More guesses:

/etc/init (/etc/init.d, /etc/rc*.d)
/etc/services

-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dbus: "(setenv ...)" not the same as "export ...=..."
  2011-11-02  4:56 ` Kevin Rodgers
@ 2011-11-02 21:54   ` Peter Münster
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Münster @ 2011-11-02 21:54 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, Nov 02 2011, Kevin Rodgers wrote:

> Could the process that reads DBUS_SESSION_BUS_ADDRESS be Emacs itself?

Yes, certainly.


>> P.S.: I don't know, where the dbus is started on my system, the parent
>> PID is 1. Perhaps from xinit or fvwm, how can I know?
>
> More guesses:
>
> /etc/init (/etc/init.d, /etc/rc*.d)

For the system dbus yes, but not for the session dbus. The latter is
launched at the start of the X-session, I just don't know, where exactly.

-- 
           Peter




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dbus: "(setenv ...)" not the same as "export ...=..."
  2011-10-30 15:08   ` Peter Münster
@ 2011-11-07 10:07     ` Michael Albinus
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Albinus @ 2011-11-07 10:07 UTC (permalink / raw)
  To: Peter Münster; +Cc: help-gnu-emacs

pmlists@free.fr (Peter Münster) writes:

> I don't want to start it from emacs. It has already been started from
> somewhere at the start of the X-session. The "address=autolaunch"
> permits emacs to find the dbus-daemon.
>
> From the dbus-launch man page:
>   "If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to
>    use D-Bus, by default the process will attempt to invoke dbus-launch
>    with the --autolaunch option to start up a new session bus or find
>    the existing bus address on the X display or in a file in
>    ~/.dbus/session-bus/"
>
> It seems, that emacs does this only, if DBUS_SESSION_BUS_ADDRESS is set
> to "autolaunch:", but not if it is unset. And (setenv ...) does not
> work, it must be set from outside emacs.

Emacs' dbusbind.c does not parse $DBUS_SESSION_BUS_ADDRESS, it uses
vanilla libdbus from the reference implementation. Therefore, its
behaviour seems to be correct.

For the behaviour of `setenv' see the other answer. It modifies
`process-environment', which is not involved 'cause there is no new
process started when opening a D-Bus connection.

Best regards, Michael.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-07 10:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-29 23:44 dbus: "(setenv ...)" not the same as "export ...=..." Peter Münster
2011-10-30  8:51 ` Michael Albinus
2011-10-30 15:08   ` Peter Münster
2011-11-07 10:07     ` Michael Albinus
2011-11-02  4:56 ` Kevin Rodgers
2011-11-02 21:54   ` Peter Münster

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.