@@ 35,6 35,7 @@ pub struct ConfigInternal {
#[derive(Debug, Eq, PartialEq, Default)]
pub struct ConfigTerminal {
pub vt: VtSelection,
+ pub switch: bool,
}
#[derive(Debug, Eq, PartialEq)]
@@ 104,7 105,7 @@ fn parse_old_config(config: &HashMap<&str, HashMap<&str, &str>>) -> Result<Confi
};
Ok(ConfigFile {
- terminal: ConfigTerminal { vt },
+ terminal: ConfigTerminal { vt, switch: true },
default_session: ConfigSession {
user: greeter_user,
command: greeter,
@@ 165,6 166,11 @@ fn parse_new_config(config: &HashMap<&str, HashMap<&str, &str>>) -> Result<Confi
.map_err(|e| format!("could not parse vt number: {}", e))?,
),
},
+ switch: section
+ .get("switch")
+ .unwrap_or(&"true")
+ .parse()
+ .map_err(|e| format!("could not parse switch: {}", e))?,
}),
None => Err("no terminal specified"),
}?;
@@ 300,7 306,8 @@ greeter_user = \"greeter\"
config,
ConfigFile {
terminal: ConfigTerminal {
- vt: VtSelection::Specific(1)
+ vt: VtSelection::Specific(1),
+ switch: true,
},
default_session: ConfigSession {
command: "agreety".to_string(),
@@ 322,7 329,8 @@ greeter = \"agreety\"
config,
ConfigFile {
terminal: ConfigTerminal {
- vt: VtSelection::Next
+ vt: VtSelection::Next,
+ switch: true,
},
default_session: ConfigSession {
command: "agreety".to_string(),
@@ 349,7 357,8 @@ command = \"agreety\"
config,
ConfigFile {
terminal: ConfigTerminal {
- vt: VtSelection::Specific(1)
+ vt: VtSelection::Specific(1),
+ switch: true,
},
default_session: ConfigSession {
command: "agreety".to_string(),
@@ 376,7 385,8 @@ user = \"john\"
config,
ConfigFile {
terminal: ConfigTerminal {
- vt: VtSelection::Specific(1)
+ vt: VtSelection::Specific(1),
+ switch: true,
},
default_session: ConfigSession {
command: "agreety".to_string(),
@@ 406,7 416,8 @@ runfile = \"/path/to/greetd.state\"
config,
ConfigFile {
terminal: ConfigTerminal {
- vt: VtSelection::Specific(1)
+ vt: VtSelection::Specific(1),
+ switch: true,
},
default_session: ConfigSession {
command: "agreety".to_string(),
@@ 447,7 458,8 @@ vt = 1
config,
ConfigFile {
terminal: ConfigTerminal {
- vt: VtSelection::Specific(1)
+ vt: VtSelection::Specific(1),
+ switch: true,
},
default_session: ConfigSession {
command: "agreety".to_string(),
@@ 469,7 481,8 @@ vt = next
config,
ConfigFile {
terminal: ConfigTerminal {
- vt: VtSelection::Next
+ vt: VtSelection::Next,
+ switch: true,
},
default_session: ConfigSession {
command: "agreety".to_string(),
@@ 491,7 504,8 @@ vt = current
config,
ConfigFile {
terminal: ConfigTerminal {
- vt: VtSelection::Current
+ vt: VtSelection::Current,
+ switch: true,
},
default_session: ConfigSession {
command: "agreety".to_string(),
@@ 31,6 31,17 @@ fn reset_vt(term_mode: &TerminalMode) -> Result<(), Error> {
Ok(())
}
+fn wait_vt(term_mode: &TerminalMode) -> Result<(), Error> {
+ match term_mode {
+ TerminalMode::Terminal { path, vt, .. } => {
+ let term = Terminal::open(path)?;
+ term.vt_waitactive(*vt)?;
+ }
+ TerminalMode::Stdin => (),
+ }
+ Ok(())
+}
+
fn wrap_result<T>(res: Result<T, Error>) -> Response {
match res {
Ok(_) => Response::Success,
@@ 145,14 156,14 @@ fn get_tty(config: &Config) -> Result<TerminalMode, Error> {
TerminalMode::Terminal {
path: format!("/dev/tty{}", vt),
vt,
- switch: true,
+ switch: config.file.terminal.switch,
}
}
VtSelection::None => TerminalMode::Stdin,
VtSelection::Specific(vt) => TerminalMode::Terminal {
path: format!("/dev/tty{}", vt),
vt,
- switch: true,
+ switch: config.file.terminal.switch,
},
};
return Ok(term);
@@ 215,6 226,10 @@ pub async fn main(config: Config) -> Result<(), Error> {
let term_mode = get_tty(&config)?;
+ if !config.file.terminal.switch {
+ wait_vt(&term_mode).map_err(|e| format!("unable to wait VT: {}", e))?;
+ }
+
let ctx = Rc::new(Context::new(
config.file.default_session.command,
config.file.default_session.user,