Skip to content

Commit

Permalink
Add a generic --session-wrapper for non-X11 sessions.
Browse files Browse the repository at this point in the history
  • Loading branch information
apognu committed Oct 23, 2023
1 parent 2f74df5 commit 93da2d5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]...'
Expand Down
4 changes: 4 additions & 0 deletions contrib/man/tuigreet-1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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*.
Expand Down
6 changes: 6 additions & 0 deletions src/greeter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub struct Greeter {
pub session_path: Option<PathBuf>,
pub session_paths: Vec<(PathBuf, SessionType)>,
pub sessions: Menu<Session>,
pub session_wrapper: Option<String>,
pub xsession_wrapper: Option<String>,

pub username: String,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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()));
}
Expand Down
8 changes: 8 additions & 0 deletions src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ impl Ipc {
if let Some(ref wrap) = greeter.xsession_wrapper {
command = format!("{} {}", wrap, command);
}
} else {

Check warning on line 138 in src/ipc.rs

View workflow job for this annotation

GitHub Actions / clippy

this `else { if .. }` block can be collapsed
if let Some(ref wrap) = greeter.session_wrapper {
command = format!("{} {}", wrap, command);
}
}
} else {

Check warning on line 143 in src/ipc.rs

View workflow job for this annotation

GitHub Actions / clippy

this `else { if .. }` block can be collapsed
if let Some(ref wrap) = greeter.session_wrapper {
command = format!("{} {}", wrap, command);
}
}

Expand Down

0 comments on commit 93da2d5

Please sign in to comment.