emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unable to get dbus.el to work with the Gentoo OpenRC 'emacs' service


From: Alexis
Subject: Unable to get dbus.el to work with the Gentoo OpenRC 'emacs' service
Date: Fri, 02 Jun 2023 22:39:52 +1000
User-agent: mu4e 1.10.3; emacs 28.3


[Please cc me on replies as i'm not currently subscribed to the list.]

Hi all,

For a while i've been manually starting an Emacs server on login (via my .zlogin), after a D-Bus session has been started (also via my .zlogin). However, i recently tried moving to the Gentoo OpenRC service, and have run into a problem regarding D-Bus.

The 'emacs' OpenRC service gets started at boot, prior to login. There is thus no D-Bus session bus available at that time; the DBUS_SESSION_BUS_ADDRESS env var isn't set. As noted above, this changes once i log in; the DBUS_SESSION_BUS_ADDRESS variable gets set. However, the Emacs server still thinks that var is unset.

i had assumed that running:

emacsclient --eval "(setenv \"DBUS_SESSION_BUS_ADDRESS\" \"${DBUS_SESSION_BUS_ADDRESS}\")"

in my WM startup script, to set that var in the environment of the server process, would address this.

However, while it addresses some issues - such as Emacs being able to open a new tab in an existing Firefox instance - it doesn't seem to affect the D-Bus environment in Emacs more generally:

   (dbus-get-unique-name :session)
   -> (dbus-error "No connection to bus" :session)

   (dbus-monitor :session)
   -> (dbus-error "No connection to bus" :session-private)

There seems to be no way of 'restarting' the "dbus" feature from within Emacs in order to get it to pick up the session bus address.

* (dbus-init-bus :session)
 -> (dbus-error "No connection to bus" :session)

* (dbus-init-bus (getenv "DBUS_SESSION_BUS_ADDRESS"))
 -> 2

 which means a new connection has been created, but:

 (dbus-monitor :session)
 -> "No connection to bus"

* (dbus-list-hash-table)
 -> (((:signal "unix:path=/tmp/dbus-[etc]

where [etc] is the correct current value of DBUS_SESSION_BUS_ADDRESS for the session, and yet:

 (dbus-monitor :session)
 -> "No connection to bus"

* Redefining `dbus-handle-bus-disconnect`:

(defun my-dbus-handle-bus-disconnect ()
 "React to a bus disconnection.
BUS is the bus that disconnected.  This routine unregisters all
handlers on the given bus and causes all synchronous calls
pending at the time of disconnect to fail."
 (let ((bus (getenv "DBUS_SESSION_BUS_ADDRESS"))
       keys-to-remove)
   (maphash
    (lambda (key value)
      (when (and (eq (nth 0 key) :serial)
                 (eq (nth 1 key) bus))
        (run-hook-with-args
         'dbus-event-error-functions
         (list 'dbus-event
               bus
               dbus-message-type-error
               (nth 2 key) ; serial
               nil         ; service
               nil         ; destination
               nil         ; path
               nil         ; interface
               nil         ; member
               value)      ; handler
(list 'dbus-error dbus-error-disconnected "Bus disconnected" bus))
        (push key keys-to-remove)))
    dbus-registered-objects-table)
   (dolist (key keys-to-remove)
     (remhash key dbus-registered-objects-table))))

 followed by:

 (my-dbus-handle-bus-disconnect)
 (dbus-ignore-errors
   (dbus-init-bus :session))

 returns `nil` (i.e. without errors), but

 (dbus-monitor :session)
 -> "No connection to bus"

* (unload-feature 'dbus t)

where `t` is required due to various in-tree packages having a dependency on dbus.el, returns `nil` (i.e. without errors), but:

 (require 'dbus)
 -> dbus
 (dbus-monitor :session)
 -> "No connection to bus"

What am i missing? Or is it simply not possible to 'restart' dbus.el from ELisp in order to get it to create a :session bus based on the updated value of DBUS_SESSION_BUS_ADDRESS in the server process environment?


Alexis.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]