mirror of
https://github.com/apognu/tuigreet.git
synced 2024-11-29 00:22:43 +03:00
Add --xsession-wrapper
argument for X11 session setup
This commit is contained in:
parent
389e73ea21
commit
1690d71119
@ -14,6 +14,9 @@ Options:
|
||||
-s, --sessions DIRS colon-separated list of Wayland session paths
|
||||
-x, --xsessions DIRS
|
||||
colon-separated list of X11 session paths
|
||||
--xsession-wrapper 'CMD [ARGS]...'
|
||||
wrapper command to initialize X server and launch X11
|
||||
sessions (default: startx /usr/bin/env)
|
||||
-w, --width WIDTH width of the main prompt (default: 80)
|
||||
-i, --issue show the host's issue file
|
||||
-g, --greeting GREETING
|
||||
|
@ -28,6 +28,11 @@ tuigreet - A graphical console greeter for greetd
|
||||
Location of desktop-files to be used as X11 session definitions. By
|
||||
default, X11 sessions are fetched from */usr/share/xsessions*.
|
||||
|
||||
*--xsession-wrapper 'CMD [ARGS]...'*
|
||||
Specify a wrapper command to initialize X server and launch X11 sessions.
|
||||
By default, *startx /usr/bin/env* will be prepended to all X11 session
|
||||
commands.
|
||||
|
||||
*-w, --width COLS*
|
||||
Number of columns the main prompt area should take on the screen.
|
||||
|
||||
|
@ -29,6 +29,9 @@ use crate::{
|
||||
|
||||
const DEFAULT_LOCALE: Locale = Locale::en_US;
|
||||
const DEFAULT_ASTERISKS_CHAR: char = '*';
|
||||
// `startx` wants an absolute path to the executable as a first argument.
|
||||
// We don't want to resolve the session command in the greeter though, so it should be additionally wrapped with a known noop command (like `/usr/bin/env`).
|
||||
const DEFAULT_XSESSION_WRAPPER: &str = "startx /usr/bin/env";
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum AuthStatus {
|
||||
@ -103,6 +106,7 @@ pub struct Greeter {
|
||||
pub session_paths: Vec<(PathBuf, SessionType)>,
|
||||
pub sessions: Vec<Session>,
|
||||
pub selected_session: usize,
|
||||
pub xsession_wrapper: Option<String>,
|
||||
|
||||
pub selected_power_option: usize,
|
||||
|
||||
@ -285,11 +289,14 @@ impl Greeter {
|
||||
async fn parse_options(&mut self) {
|
||||
let mut opts = Options::new();
|
||||
|
||||
let xsession_wrapper_desc = format!("wrapper command to initialize X server and launch X11 sessions (default: {DEFAULT_XSESSION_WRAPPER})");
|
||||
|
||||
opts.optflag("h", "help", "show this usage information");
|
||||
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("x", "xsessions", "colon-separated list of X11 session paths", "DIRS");
|
||||
opts.optopt("", "xsession-wrapper", xsession_wrapper_desc.as_str(), "'CMD [ARGS]...'");
|
||||
opts.optopt("w", "width", "width of the main prompt (default: 80)", "WIDTH");
|
||||
opts.optflag("i", "issue", "show the host's issue file");
|
||||
opts.optopt("g", "greeting", "show custom text above login prompt", "GREETING");
|
||||
@ -402,6 +409,8 @@ impl Greeter {
|
||||
self.session_paths.extend(env::split_paths(&dirs).map(|dir| (dir, SessionType::X11)));
|
||||
}
|
||||
|
||||
self.xsession_wrapper = self.option("xsession-wrapper").or_else(|| Some(DEFAULT_XSESSION_WRAPPER.to_string()));
|
||||
|
||||
if self.config().opt_present("issue") {
|
||||
self.greeting = get_issue();
|
||||
}
|
||||
|
@ -118,16 +118,23 @@ impl Ipc {
|
||||
greeter.mode = Mode::Processing;
|
||||
|
||||
let session = greeter.sessions.get(greeter.selected_session).filter(|s| &s.command == command);
|
||||
let mut command = command.clone();
|
||||
let mut env = vec![];
|
||||
|
||||
if let Some(Session { session_type, .. }) = session {
|
||||
if *session_type != SessionType::None {
|
||||
env.push(format!("XDG_SESSION_TYPE={}", session_type.to_xdg_session_type()));
|
||||
}
|
||||
|
||||
if *session_type == SessionType::X11 {
|
||||
if let Some(ref wrap) = greeter.xsession_wrapper {
|
||||
command = format!("{} {}", wrap, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
self.send(Request::StartSession { cmd: vec![command.clone()], env }).await;
|
||||
self.send(Request::StartSession { cmd: vec![command], env }).await;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user