diff options
| author | Christian Meissl <meissl.christian@gmail.com> | 2024-11-03 14:29:36 +0100 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-29 21:57:36 -0800 |
| commit | 61f2ac01d782f1142aefb78d1286db005021a7a0 (patch) | |
| tree | 9c299d378f9495f179d522f7be75e85e7352f009 /src/utils | |
| parent | 39a9f55205ccb87b06e5f992f2db97800d6ce853 (diff) | |
| download | niri-61f2ac01d782f1142aefb78d1286db005021a7a0.tar.gz niri-61f2ac01d782f1142aefb78d1286db005021a7a0.tar.bz2 niri-61f2ac01d782f1142aefb78d1286db005021a7a0.zip | |
xdg: startup activation
pass an activation token to process spawned through actions
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/spawning.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/utils/spawning.rs b/src/utils/spawning.rs index 871f05db..b7aa0d44 100644 --- a/src/utils/spawning.rs +++ b/src/utils/spawning.rs @@ -9,6 +9,7 @@ use std::{io, thread}; use atomic::Atomic; use libc::{getrlimit, rlim_t, rlimit, setrlimit, RLIMIT_NOFILE}; use niri_config::Environment; +use smithay::wayland::xdg_activation::XdgActivationToken; use crate::utils::expand_home; @@ -61,7 +62,7 @@ pub fn restore_nofile_rlimit() { } /// Spawns the command to run independently of the compositor. -pub fn spawn<T: AsRef<OsStr> + Send + 'static>(command: Vec<T>) { +pub fn spawn<T: AsRef<OsStr> + Send + 'static>(command: Vec<T>, token: Option<XdgActivationToken>) { let _span = tracy_client::span!(); if command.is_empty() { @@ -73,7 +74,7 @@ pub fn spawn<T: AsRef<OsStr> + Send + 'static>(command: Vec<T>) { .name("Command Spawner".to_owned()) .spawn(move || { let (command, args) = command.split_first().unwrap(); - spawn_sync(command, args); + spawn_sync(command, args, token); }); if let Err(err) = res { @@ -81,7 +82,11 @@ pub fn spawn<T: AsRef<OsStr> + Send + 'static>(command: Vec<T>) { } } -fn spawn_sync(command: impl AsRef<OsStr>, args: impl IntoIterator<Item = impl AsRef<OsStr>>) { +fn spawn_sync( + command: impl AsRef<OsStr>, + args: impl IntoIterator<Item = impl AsRef<OsStr>>, + token: Option<XdgActivationToken>, +) { let _span = tracy_client::span!(); let mut command = command.as_ref(); @@ -122,6 +127,11 @@ fn spawn_sync(command: impl AsRef<OsStr>, args: impl IntoIterator<Item = impl As } drop(env); + if let Some(token) = token.as_ref() { + process.env("XDG_ACTIVATION_TOKEN", token.as_str()); + process.env("DESKTOP_STARTUP_ID", token.as_str()); + } + let Some(mut child) = do_spawn(command, process) else { return; }; |
