From 35abeddb0cc4b665d7551512769db96b28d3ce2c Mon Sep 17 00:00:00 2001 From: Antoine POPINEAU Date: Mon, 23 Oct 2023 17:12:40 +0200 Subject: [PATCH] Add a generic --session-wrapper for non-X11 sessions. --- README.md | 2 ++ contrib/man/tuigreet-1.scd | 4 ++++ src/greeter.rs | 6 ++++++ src/ipc.rs | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/README.md b/README.md index bd4203a..e1f978e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Options: -v, --version print version information -c, --cmd COMMAND command to run -s, --sessions DIRS colon-separated list of Wayland session paths + --session-wrapper 'CMD [ARGS]...' + wrapper command to initialize the non-X11 session -x, --xsessions DIRS colon-separated list of X11 session paths --xsession-wrapper 'CMD [ARGS]...' diff --git a/contrib/man/tuigreet-1.scd b/contrib/man/tuigreet-1.scd index 6ea5cd2..dfd2c1c 100644 --- a/contrib/man/tuigreet-1.scd +++ b/contrib/man/tuigreet-1.scd @@ -24,6 +24,10 @@ tuigreet - A graphical console greeter for greetd Location of desktop-files to be used as Wayland session definitions. By default, Wayland sessions are fetched from */usr/share/wayland-sessions*. +*--session-wrapper 'CMD [ARGS]...'* + Specify a wrapper command to execute instead of the session for non-X11 + sessions. This command will receive the session command as its arguments. + *-x, --xsessions DIR1[:DIR2]...* Location of desktop-files to be used as X11 session definitions. By default, X11 sessions are fetched from */usr/share/xsessions*. diff --git a/src/greeter.rs b/src/greeter.rs index 828cfe1..f774f74 100644 --- a/src/greeter.rs +++ b/src/greeter.rs @@ -85,6 +85,7 @@ pub struct Greeter { pub session_path: Option, pub session_paths: Vec<(PathBuf, SessionType)>, pub sessions: Menu, + pub session_wrapper: Option, pub xsession_wrapper: Option, pub username: String, @@ -296,6 +297,7 @@ impl Greeter { opts.optflag("v", "version", "print version information"); opts.optopt("c", "cmd", "command to run", "COMMAND"); opts.optopt("s", "sessions", "colon-separated list of Wayland session paths", "DIRS"); + opts.optopt("", "session-wrapper", "wrapper command to initialize the non-X11 session", "'CMD [ARGS]...'"); opts.optopt("x", "xsessions", "colon-separated list of X11 session paths", "DIRS"); opts.optopt("", "xsession-wrapper", xsession_wrapper_desc.as_str(), "'CMD [ARGS]...'"); opts.optflag("", "no-xsession-wrapper", "do not wrap commands for X11 sessions"); @@ -415,6 +417,10 @@ impl Greeter { self.session_paths.extend(env::split_paths(&dirs).map(|dir| (dir, SessionType::X11))); } + if self.option("session-wrapper").is_some() { + self.session_wrapper = self.option("session-wrapper"); + } + if !self.config().opt_present("no-xsession-wrapper") { self.xsession_wrapper = self.option("xsession-wrapper").or_else(|| Some(DEFAULT_XSESSION_WRAPPER.to_string())); } diff --git a/src/ipc.rs b/src/ipc.rs index 50abc81..49b3cac 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -135,7 +135,11 @@ impl Ipc { if let Some(ref wrap) = greeter.xsession_wrapper { command = format!("{} {}", wrap, command); } + } else if let Some(ref wrap) = greeter.session_wrapper { + command = format!("{} {}", wrap, command); } + } else if let Some(ref wrap) = greeter.session_wrapper { + command = format!("{} {}", wrap, command); } #[cfg(not(debug_assertions))]