added zbus_systemd as an optional dependency
This commit is contained in:
parent
e1a0048f33
commit
93a9524996
3 changed files with 129 additions and 82 deletions
171
Cargo.lock
generated
171
Cargo.lock
generated
|
|
@ -32,23 +32,12 @@ version = "0.7.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20cd0e2e25ea8e5f7e9df04578dc6cf5c83577fd09b1a46aaf5c85e1c33f2a7e"
|
||||
dependencies = [
|
||||
"event-listener 5.3.1",
|
||||
"event-listener",
|
||||
"event-listener-strategy",
|
||||
"futures-core",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-channel"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833"
|
||||
dependencies = [
|
||||
"concurrent-queue",
|
||||
"event-listener 2.5.3",
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-channel"
|
||||
version = "2.3.1"
|
||||
|
|
@ -61,17 +50,41 @@ dependencies = [
|
|||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-executor"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8828ec6e544c02b0d6691d21ed9f9218d0384a82542855073c2a3f58304aaf0"
|
||||
dependencies = [
|
||||
"async-task",
|
||||
"concurrent-queue",
|
||||
"fastrand 2.1.0",
|
||||
"futures-lite",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-fs"
|
||||
version = "2.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a"
|
||||
dependencies = [
|
||||
"async-lock",
|
||||
"blocking",
|
||||
"futures-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-io"
|
||||
version = "2.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964"
|
||||
dependencies = [
|
||||
"async-lock 3.4.0",
|
||||
"async-lock",
|
||||
"cfg-if",
|
||||
"concurrent-queue",
|
||||
"futures-io",
|
||||
"futures-lite 2.0.0",
|
||||
"futures-lite",
|
||||
"parking",
|
||||
"polling",
|
||||
"rustix 0.38.34",
|
||||
|
|
@ -80,22 +93,13 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-lock"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7"
|
||||
dependencies = [
|
||||
"event-listener 2.5.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-lock"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18"
|
||||
dependencies = [
|
||||
"event-listener 5.3.1",
|
||||
"event-listener",
|
||||
"event-listener-strategy",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
|
@ -106,15 +110,15 @@ version = "2.2.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7eda79bbd84e29c2b308d1dc099d7de8dcc7035e48f4bf5dc4a531a44ff5e2a"
|
||||
dependencies = [
|
||||
"async-channel 2.3.1",
|
||||
"async-channel",
|
||||
"async-io",
|
||||
"async-lock 3.4.0",
|
||||
"async-lock",
|
||||
"async-signal",
|
||||
"async-task",
|
||||
"blocking",
|
||||
"cfg-if",
|
||||
"event-listener 5.3.1",
|
||||
"futures-lite 2.0.0",
|
||||
"event-listener",
|
||||
"futures-lite",
|
||||
"rustix 0.38.34",
|
||||
"tracing",
|
||||
"windows-sys 0.52.0",
|
||||
|
|
@ -138,7 +142,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "794f185324c2f00e771cd9f1ae8b5ac68be2ca7abb129a87afd6e86d228bc54d"
|
||||
dependencies = [
|
||||
"async-io",
|
||||
"async-lock 3.4.0",
|
||||
"async-lock",
|
||||
"atomic-waker",
|
||||
"cfg-if",
|
||||
"futures-core",
|
||||
|
|
@ -227,17 +231,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "blocking"
|
||||
version = "1.3.1"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65"
|
||||
checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea"
|
||||
dependencies = [
|
||||
"async-channel 1.8.0",
|
||||
"async-lock 2.7.0",
|
||||
"async-channel",
|
||||
"async-task",
|
||||
"atomic-waker",
|
||||
"fastrand 1.9.0",
|
||||
"futures-lite 1.13.0",
|
||||
"log",
|
||||
"futures-io",
|
||||
"futures-lite",
|
||||
"piper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -338,6 +340,7 @@ dependencies = [
|
|||
"tracing-journald",
|
||||
"tracing-subscriber",
|
||||
"zbus",
|
||||
"zbus_systemd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -427,12 +430,6 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "event-listener"
|
||||
version = "2.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
||||
|
||||
[[package]]
|
||||
name = "event-listener"
|
||||
version = "5.3.1"
|
||||
|
|
@ -450,7 +447,7 @@ version = "0.5.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1"
|
||||
dependencies = [
|
||||
"event-listener 5.3.1",
|
||||
"event-listener",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
|
|
@ -479,6 +476,31 @@ version = "2.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.30"
|
||||
|
|
@ -486,25 +508,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.28"
|
||||
name = "futures-executor"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
|
||||
checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-lite"
|
||||
version = "1.13.0"
|
||||
name = "futures-io"
|
||||
version = "0.3.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce"
|
||||
dependencies = [
|
||||
"fastrand 1.9.0",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"memchr",
|
||||
"parking",
|
||||
"pin-project-lite",
|
||||
"waker-fn",
|
||||
]
|
||||
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
|
||||
|
||||
[[package]]
|
||||
name = "futures-lite"
|
||||
|
|
@ -550,10 +568,13 @@ version = "0.3.30"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-macro",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
|
|
@ -664,7 +685,7 @@ checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a"
|
|||
[[package]]
|
||||
name = "launch-pad"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/launch-pad#699fd1801260cd4425dfd472d0e36fdf17bb7f36"
|
||||
source = "git+https://github.com/pop-os/launch-pad#1596d1b83ae5d5c804a69146f89718776022b46b"
|
||||
dependencies = [
|
||||
"log",
|
||||
"nix 0.26.2",
|
||||
|
|
@ -915,6 +936,17 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "piper"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae1d5c74c9876f070d3e8fd503d748c7d974c3e48da8f41350fa5222ef9b4391"
|
||||
dependencies = [
|
||||
"atomic-waker",
|
||||
"fastrand 2.1.0",
|
||||
"futures-io",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polling"
|
||||
version = "3.7.2"
|
||||
|
|
@ -1643,11 +1675,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "23915fcb26e7a9a9dc05fd93a9870d336d6d032cd7e8cebf1c5c37666489fdd5"
|
||||
dependencies = [
|
||||
"async-broadcast",
|
||||
"async-executor",
|
||||
"async-fs",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"async-process",
|
||||
"async-recursion",
|
||||
"async-task",
|
||||
"async-trait",
|
||||
"blocking",
|
||||
"enumflags2",
|
||||
"event-listener 5.3.1",
|
||||
"event-listener",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
|
|
@ -1693,6 +1731,17 @@ dependencies = [
|
|||
"zvariant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zbus_systemd"
|
||||
version = "0.25600.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14a94191447de6983b8c81f6d57d759501e03e59be7970ab0dc069ac9e36f786"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"serde",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "4.1.1"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ color-eyre = "0.6"
|
|||
futures-util = "0.3"
|
||||
launch-pad = { git = "https://github.com/pop-os/launch-pad" }
|
||||
itertools = "0.12"
|
||||
# launch-pad = { path = "../launch-pad" }
|
||||
#launch-pad = { path = "../../../launch-pad" }
|
||||
libc = "0.2"
|
||||
log-panics = { version = "2", features = ["with-backtrace"] }
|
||||
rustix = "0.38"
|
||||
|
|
@ -34,9 +34,16 @@ tokio = { version = "1", features = [
|
|||
"sync",
|
||||
"time",
|
||||
] }
|
||||
zbus_systemd = { version = "0.25600.0", optional = true, features = [
|
||||
"systemd1",
|
||||
] }
|
||||
tokio-util = "0.7"
|
||||
tracing = "0.1"
|
||||
tracing-journald = "0.3"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
zbus = { version = "4.3.0", default-features = false, features = ["tokio"] }
|
||||
cosmic-notifications-util = { git = "https://github.com/pop-os/cosmic-notifications" }
|
||||
|
||||
[features]
|
||||
systemd = ["dep:zbus_systemd"]
|
||||
default = ["systemd"]
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ use std::sync::OnceLock;
|
|||
use zbus::zvariant::{Array, OwnedValue};
|
||||
use zbus::{proxy, zvariant::Value, Connection};
|
||||
|
||||
#[cfg(feature = "systemd")]
|
||||
use zbus_systemd::systemd1::ManagerProxy as SystemdManagerProxy;
|
||||
|
||||
pub async fn set_systemd_environment(key: &str, value: &str) {
|
||||
run_optional_command(
|
||||
"systemctl",
|
||||
|
|
@ -44,31 +47,19 @@ pub fn is_systemd_used() -> &'static bool {
|
|||
)
|
||||
}
|
||||
|
||||
#[proxy(
|
||||
name = "org.freedesktop.systemd1.Manager",
|
||||
default_service = "org.freedesktop.systemd1",
|
||||
default_path = "/org/freedesktop/systemd1"
|
||||
)]
|
||||
trait SystemdManager<'a> {
|
||||
fn start_transient_unit<'a>(
|
||||
&self,
|
||||
name: &str,
|
||||
mode: &str,
|
||||
properties: Vec<(String, Value<'a>)>,
|
||||
//This is based on the systemd-zbus implementation, however according to the spec this should be empty
|
||||
//see: https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.systemd1.html#:~:text=aux%20is%20currently%20unused
|
||||
aux: Vec<(String, Vec<(String, Value<'a>)>)>,
|
||||
) -> zbus::Result<()>;
|
||||
}
|
||||
|
||||
///Spawn a systemd scope unit with the given name and PIDs.
|
||||
pub async fn spawn_scope(scope_name: &str, pids: Vec<u32>) -> zbus::Result<()> {
|
||||
let connection = Connection::session().await?;
|
||||
let systemd_manager = SystemdManagerProxy::new(&connection).await?;
|
||||
|
||||
let properties = vec![(String::from("PIDs"), Value::Array(Array::from(pids)))];
|
||||
let pids = OwnedValue::try_from(Value::Array(Array::from(pids)))?;
|
||||
let properties = vec![(String::from("PIDs"), pids)];
|
||||
systemd_manager
|
||||
.start_transient_unit(scope_name, "fail", properties, Vec::new())
|
||||
.start_transient_unit(
|
||||
scope_name.to_string(),
|
||||
String::from("fail"),
|
||||
properties,
|
||||
Vec::new(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue