main: Update D-Bus activation environment also on non-systemd systems
On systems without systemd, use zbus to update D-Bus activation environment with `WAYLAND_DISPLAY` and `DISPLAY` variables. Fixes #1037
This commit is contained in:
parent
7829e7696d
commit
9b50d0f506
2 changed files with 29 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
|||
use crate::state::{BackendData, State};
|
||||
use crate::state::{BackendData, Common, State};
|
||||
use anyhow::{Context, Result};
|
||||
use calloop::{InsertError, LoopHandle, RegistrationToken};
|
||||
use std::collections::HashMap;
|
||||
use zbus::blocking::{fdo::DBusProxy, Connection};
|
||||
|
||||
mod power;
|
||||
|
||||
|
|
@ -64,3 +66,24 @@ pub fn init(evlh: &LoopHandle<'static, State>) -> Result<Vec<RegistrationToken>>
|
|||
|
||||
Ok(tokens)
|
||||
}
|
||||
|
||||
/// Updated the D-Bus activation environment with `WAYLAND_DISPLAY` and
|
||||
/// `DISPLAY` variables.
|
||||
pub fn ready(common: &Common) -> Result<()> {
|
||||
let conn = Connection::session()?;
|
||||
let proxy = DBusProxy::new(&conn)?;
|
||||
|
||||
proxy.update_activation_environment(HashMap::from([
|
||||
("WAYLAND_DISPLAY", common.socket.to_str().unwrap()),
|
||||
(
|
||||
"DISPLAY",
|
||||
&common
|
||||
.xwayland_state
|
||||
.as_ref()
|
||||
.map(|s| format!(":{}", s.display))
|
||||
.unwrap_or(String::new()),
|
||||
),
|
||||
]))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,9 +45,13 @@ impl State {
|
|||
// into systemd and the session?
|
||||
self.ready.call_once(|| {
|
||||
// potentially tell systemd we are setup now
|
||||
#[cfg(feature = "systemd")]
|
||||
if let state::BackendData::Kms(_) = &self.backend {
|
||||
#[cfg(feature = "systemd")]
|
||||
systemd::ready(&self.common);
|
||||
#[cfg(not(feature = "systemd"))]
|
||||
if let Err(err) = dbus::ready(&self.common) {
|
||||
error!(?err, "Failed to update the D-Bus activation environment");
|
||||
}
|
||||
}
|
||||
|
||||
// potentially tell the session we are setup now
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue