all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Issue connecting Emacs --daemon to D-BUS
@ 2012-09-27  9:42 joakim
  2012-10-02  5:38 ` andres.ramirez
  0 siblings, 1 reply; 4+ messages in thread
From: joakim @ 2012-09-27  9:42 UTC (permalink / raw
  To: emacs-devel

This will be a rather vague problem description, sorry.

I'm trying to start using Emacs in its daemonic form:
emacs --daemon

The idea is that since the Gnome 3 gnome-shell sometimes crashes several times a
day for me, my emacs will survive and I can simply reconnect with
emacsclient once gnome-shell is up again.

Since I want my emacs to start as a service daemon when the machine
boots, there is no dbus or gnome session to connect to yet. I want to
attach to dbus and gnome once the gui session is started.



for the gnome keyring I can do this:
m-x setenv SSH_AUTH_SOCK RET /run/user/joakim/keyring-hzCXZo/ssh RET

where the value is fetched from a shell started within the login
session. I can thus unlock the keyring in gnome and use it in emacs.

I expect to be able to do the same for dbus, but it doesnt quite work:

m-x setevn DBUS_SESSION_BUS_ADDRESS RET
unix:abstract=/tmp/dbus-XpKHIj1IpU,guid=5a7b419d5e50e78fe35e6ccf0005787a
RET

I still get:

ELISP> (dbus-init-bus :session)
*** Eval error ***  D-Bus error: "No connection to bus", :session

And here somewhere is my actuall issue: "No connection to bus" can be
returned in several places in dbusbind.c, so I cant really debug which
of the checks are triggered. 


(dbus-init-bus :system) seems to work and return 2.
-- 
Joakim Verona



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

* Re: Issue connecting Emacs --daemon to D-BUS
  2012-09-27  9:42 Issue connecting Emacs --daemon to D-BUS joakim
@ 2012-10-02  5:38 ` andres.ramirez
  2012-10-03  1:31   ` Dan Nicolaescu
  2012-10-08 12:28   ` Michael Albinus
  0 siblings, 2 replies; 4+ messages in thread
From: andres.ramirez @ 2012-10-02  5:38 UTC (permalink / raw
  To: joakim; +Cc: emacs-devel

Hi Joakim.

From a Discussion with Michael Albinus.

This is what works for me. Using the emacs trunk:

- You start the daemon as usual via crontab:

  @reboot /usr/local/src/emacs/src/emacs --quick --eval \(progn\ \(setq\ server-name\ \"test\"\)\ \) --daemon

- In your emacsclient call, you hand over $DBUS_SESSION_BUS_ADDRESS via
  the variable `my-dbus-address':

  emacsclient -s test -c -e \(setq\ my-dbus-address\ \"$DBUS_SESSION_BUS_ADDRESS\"\)

  Instead of expanding $DBUS_SESSION_BUS_ADDRESS you could use any
  address string, once you know it.

- In your Emacs daemon, you can now apply the following code:

  (progn
    (require 'notifications)
    (dbus-init-bus my-dbus-address)
    (notifications-notify
     :bus my-dbus-address
     :title "nick"
     :body "message"
     :app-icon "/usr/share/notify-osd/icons/gnome/scalable/status/notification-message-im.svg"
     :urgency 'low))

The crucial point is calling `dbus-init-bus' and using the bus address
as argument of `notifications-notify'. `dbus-init-bus' must be called
only once for a new address, but it doesn't hurt when you call it
always. Btw, there was a subtle bug in `dbus-init-bus', which took me so
long to test ...

Now your notifications shall be visible, wherever you call emacsclient
from. Even if you stop your session, and restart it, it shall work,
because the new D-Bus session bus will be found.

At Thu, 27 Sep 2012 11:42:13 +0200,
joakim@verona.se wrote:
> 
> This will be a rather vague problem description, sorry.
> 
> I'm trying to start using Emacs in its daemonic form:
> emacs --daemon
> 
> The idea is that since the Gnome 3 gnome-shell sometimes crashes several times a
> day for me, my emacs will survive and I can simply reconnect with
> emacsclient once gnome-shell is up again.
> 
> Since I want my emacs to start as a service daemon when the machine
> boots, there is no dbus or gnome session to connect to yet. I want to
> attach to dbus and gnome once the gui session is started.
> 
> 
> 
> for the gnome keyring I can do this:
> m-x setenv SSH_AUTH_SOCK RET /run/user/joakim/keyring-hzCXZo/ssh RET
> 
> where the value is fetched from a shell started within the login
> session. I can thus unlock the keyring in gnome and use it in emacs.
> 
> I expect to be able to do the same for dbus, but it doesnt quite work:
> 
> m-x setevn DBUS_SESSION_BUS_ADDRESS RET
> unix:abstract=/tmp/dbus-XpKHIj1IpU,guid=5a7b419d5e50e78fe35e6ccf0005787a
> RET
> 
> I still get:
> 
> ELISP> (dbus-init-bus :session)
> *** Eval error ***  D-Bus error: "No connection to bus", :session
> 
> And here somewhere is my actuall issue: "No connection to bus" can be
> returned in several places in dbusbind.c, so I cant really debug which
> of the checks are triggered. 
> 
> 
> (dbus-init-bus :system) seems to work and return 2.
> -- 
> Joakim Verona
> 
> 



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

* Re: Issue connecting Emacs --daemon to D-BUS
  2012-10-02  5:38 ` andres.ramirez
@ 2012-10-03  1:31   ` Dan Nicolaescu
  2012-10-08 12:28   ` Michael Albinus
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Nicolaescu @ 2012-10-03  1:31 UTC (permalink / raw
  To: andres.ramirez; +Cc: joakim, emacs-devel

andres.ramirez <andres.ramirez@kipuamutay.com> writes:

> Hi Joakim.
>
> From a Discussion with Michael Albinus.
>
> This is what works for me. Using the emacs trunk:
>
> - You start the daemon as usual via crontab:
>
>   @reboot /usr/local/src/emacs/src/emacs --quick --eval \(progn\ \(setq\ server-name\ \"test\"\)\ \) --daemon

this can be written in a simpler way:

@reboot /usr/local/src/emacs/src/emacs --quick --daemon=test



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

* Re: Issue connecting Emacs --daemon to D-BUS
  2012-10-02  5:38 ` andres.ramirez
  2012-10-03  1:31   ` Dan Nicolaescu
@ 2012-10-08 12:28   ` Michael Albinus
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Albinus @ 2012-10-08 12:28 UTC (permalink / raw
  To: joakim; +Cc: andres.ramirez, emacs-devel

[Sorry for the late answer, I was offline last weeks due to vacation]

andres.ramirez <andres.ramirez@kipuamutay.com> writes:

Hi Joakim.

> From a Discussion with Michael Albinus.
>
> This is what works for me. Using the emacs trunk:
>
> - You start the daemon as usual via crontab:
>
>   @reboot /usr/local/src/emacs/src/emacs --quick --eval \(progn\ \(setq\ server-name\ \"test\"\)\ \) --daemon
>
> - In your emacsclient call, you hand over $DBUS_SESSION_BUS_ADDRESS via
>   the variable `my-dbus-address':
>
>   emacsclient -s test -c -e \(setq\ my-dbus-address\ \"$DBUS_SESSION_BUS_ADDRESS\"\)
>
>   Instead of expanding $DBUS_SESSION_BUS_ADDRESS you could use any
>   address string, once you know it.
>
> - In your Emacs daemon, you can now apply the following code:
>
>   (progn
>     (require 'notifications)
>     (dbus-init-bus my-dbus-address)
>     (notifications-notify
>      :bus my-dbus-address
>      :title "nick"
>      :body "message"
>      :app-icon "/usr/share/notify-osd/icons/gnome/scalable/status/notification-message-im.svg"
>      :urgency 'low))

Does this recipe work for you? It is a limited use case, because you
have to manage your own session bus address, instead of using `:session'.

If you need a more general solution, because you use libraries which
depend on the `:session' bus, you might try to postpone the load of dbus.el
to the emacsclient call, after setting $DBUS_SESSION_BUS_ADDRESS properly.

Best regards, Michael.



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

end of thread, other threads:[~2012-10-08 12:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-27  9:42 Issue connecting Emacs --daemon to D-BUS joakim
2012-10-02  5:38 ` andres.ramirez
2012-10-03  1:31   ` Dan Nicolaescu
2012-10-08 12:28   ` Michael Albinus

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.