Merge branch 'master' into applet-host
This commit is contained in:
commit
b2dc23f4f8
4 changed files with 593 additions and 28 deletions
|
|
@ -40,6 +40,12 @@ async fn main() -> Result<()> {
|
|||
systemd::start_systemd_target()
|
||||
.await
|
||||
.wrap_err("failed to start systemd target")?;
|
||||
// Always stop the target when the process exits or panics.
|
||||
scopeguard::defer! {
|
||||
if let Ok(manager) = systemd_client::manager::build_blocking_proxy() {
|
||||
manager.stop_unit("cosmic-session.target", "replace").ok();
|
||||
}
|
||||
}
|
||||
let env_vars = env_rx
|
||||
.await
|
||||
.expect("failed to receive environmental variables")
|
||||
|
|
|
|||
|
|
@ -1,28 +1,14 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use color_eyre::{
|
||||
eyre::{eyre, WrapErr},
|
||||
Result,
|
||||
};
|
||||
use tokio::process::Command;
|
||||
use color_eyre::{eyre::WrapErr, Result};
|
||||
|
||||
pub async fn start_systemd_target() -> Result<()> {
|
||||
let output = Command::new("systemctl")
|
||||
.arg("--user")
|
||||
.arg("start")
|
||||
.arg("cosmic-session.target")
|
||||
.spawn()
|
||||
.wrap_err("failed to start systemd target")?
|
||||
.wait()
|
||||
let manager = systemd_client::manager::build_nonblock_proxy()
|
||||
.await
|
||||
.wrap_err("failed to wait for systemd target to start")?;
|
||||
|
||||
if output.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(eyre!(
|
||||
"failed to start systemd target: code {}",
|
||||
output.code().unwrap_or(-1),
|
||||
))
|
||||
}
|
||||
.wrap_err("failed to connect to org.freedesktop.systemd1.Manager")?;
|
||||
manager
|
||||
.start_unit("cosmic-session.target", "replace")
|
||||
.await
|
||||
.wrap_err("failed to start cosmic-session.target")?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue