From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alexis Newsgroups: gmane.emacs.devel Subject: Unable to get dbus.el to work with the Gentoo OpenRC 'emacs' service Date: Fri, 02 Jun 2023 22:39:52 +1000 Message-ID: <87edmudofk.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22090"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.10.3; emacs 28.3 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 02 14:59:52 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q54Nj-0005ah-UF for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Jun 2023 14:59:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q54N4-0002jD-Hr; Fri, 02 Jun 2023 08:59:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q548Y-0003t8-Av for emacs-devel@gnu.org; Fri, 02 Jun 2023 08:44:10 -0400 Original-Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q548T-0003Lm-GG for emacs-devel@gnu.org; Fri, 02 Jun 2023 08:44:10 -0400 Original-Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-652a6bf4e6aso548478b3a.2 for ; Fri, 02 Jun 2023 05:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685709843; x=1688301843; h=mime-version:message-id:date:subject:to:from:user-agent:from:to:cc :subject:date:message-id:reply-to; bh=7AJoaWeD+u65rlKopCbvEuFM037lMlIsSSx2A7JLGRM=; b=aV1MoQVvFO9Gn5oObCVe/4zKiss7592NM4Wr169nK4PU3VIz6MZVYIgwMZpkRo+BfK YavrahKA2lwiZ6Bocndg74wUrCzhSqqr7hbAcf2VDsqCNXR0icR2CzkyQFZel/xnubC8 /QNIAJeN55hIDKDQlzTlcdQ4z7JBZDCysGGESscgIFetzjZydr2oKrAVebylO69d8NWu QV80RETdYDJg1rnZoWKUzV4NmyvaoC0qNFW1erfCcI7P4JhfWnlIsgZwlZb1dVBz+Tim 6GRa3wHubLrhZB3EeE4YPzyE4DYKwCWA5uBDfGkdG7KBRkrXNUwMQHIteT1VLzkwGnEc P/Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685709843; x=1688301843; h=mime-version:message-id:date:subject:to:from:user-agent :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7AJoaWeD+u65rlKopCbvEuFM037lMlIsSSx2A7JLGRM=; b=dZsj2CdWU5On7Ih0W3YWGKEvTWH5hOYlNomZD6Xq0CnyukUlgqphBeTMFux2+xjKsn uzDDq+7ja98o78rUUQBAeV2SkG+dZj5BQCdn5utic4K2JKjTvZt+AMGP33R9XUNEh7we GKgTWGwTQ0edziRT8LqskS7SKr0rtKBRlYks+c8hGS1OfjE7S0pyG0Su87X5s0vEDUtq QA7aTHFnw1itPP1KRt8cxLvN0FUBYNg2PRMn6xfASIEzgp90HZDI3hhnKRSamRa2Z04T Svpp3Ub+0sATLlWjNmOQaSDvHKlMWcv/SgcnDTav9dP5JVWvgHhb8RG+9oL/xiyj7XDf mw/g== X-Gm-Message-State: AC+VfDzn40NedapMFh6yGWaD/j/akNWSLtpi8Idj3ce8bw1aEdFfx0o4 fzovKVrh6Rqwuek3dbUWiWzAOyL+FfI= X-Google-Smtp-Source: ACHHUZ4M0vthxC7GI6TwWofpL+y4swDYOq0ynYryHA99S2hGN65xqSOETOsCSZZRv4qmXNwJGsf/cw== X-Received: by 2002:a05:6a00:114e:b0:64d:123d:cc74 with SMTP id b14-20020a056a00114e00b0064d123dcc74mr9608761pfm.4.1685709843157; Fri, 02 Jun 2023 05:44:03 -0700 (PDT) Original-Received: from localhost ([124.183.210.40]) by smtp.gmail.com with ESMTPSA id e3-20020a62ee03000000b0065379c6d549sm634612pfi.215.2023.06.02.05.44.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 05:44:02 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=flexibeast@gmail.com; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 02 Jun 2023 08:59:09 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306553 Archived-At: [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.