Compare commits

..

No commits in common. "0ae682ef8bb106a87325e268612a8b56694103e7" and "4b264c5da845a9704c121826a3182e5649cb975d" have entirely different histories.

3 changed files with 11 additions and 19 deletions

View File

@ -52,7 +52,7 @@ pub fn gather_sessions(user: &User) -> Vec<Session> {
true => gather_hm_sessions(&hm_profile), true => gather_hm_sessions(&hm_profile),
false => vec![Session { false => vec![Session {
name: String::from("Shell"), name: String::from("Shell"),
init: user.shell.to_str().unwrap().to_owned(), init: user.shell.clone(),
}], }],
} }
} }
@ -105,11 +105,7 @@ fn gather_session_data(path: &PathBuf) -> Session {
let session_path = path.join("session"); let session_path = path.join("session");
let name = read_to_string(session_path.join("name")).unwrap(); let name = read_to_string(session_path.join("name")).unwrap();
let init = format!( let init = session_path.join("init");
"{} && {}",
path.join("activate").display(),
session_path.join("init").display()
);
Session { name, init } Session { name, init }
} }

View File

@ -30,7 +30,7 @@ pub fn login(
return Ok(LoginResult::Success); return Ok(LoginResult::Success);
} else { } else {
starting = true; starting = true;
let cmd = vec![session.init.clone()]; let cmd = vec![session.init.to_str().unwrap().to_owned()];
let env = vec![]; let env = vec![];
Request::StartSession { cmd, env }.write_to(&mut stream)?; Request::StartSession { cmd, env }.write_to(&mut stream)?;
} }

View File

@ -29,7 +29,7 @@ fn main() -> io::Result<()> {
} }
struct App { struct App {
start_time: Instant, start_time: Instant,
exit_time: Option<Instant>, exit: bool,
error: bool, error: bool,
focus: Focus, focus: Focus,
status: Status, status: Status,
@ -111,7 +111,7 @@ impl Display for User {
#[derive(PartialEq, Eq, Clone)] #[derive(PartialEq, Eq, Clone)]
struct Session { struct Session {
name: String, name: String,
init: String, init: PathBuf,
} }
impl Display for Session { impl Display for Session {
@ -123,7 +123,7 @@ impl Display for Session {
impl Default for App { impl Default for App {
fn default() -> Self { fn default() -> Self {
let start_time = Instant::now(); let start_time = Instant::now();
let exit_time = None; let exit = false;
let error = false; let error = false;
let focus = Focus::User; let focus = Focus::User;
let status = Status::Nothing; let status = Status::Nothing;
@ -141,7 +141,7 @@ impl Default for App {
Self { Self {
start_time, start_time,
exit_time, exit,
error, error,
focus, focus,
status, status,
@ -155,10 +155,7 @@ impl Default for App {
impl App { impl App {
pub fn run(&mut self, terminal: &mut DefaultTerminal) -> io::Result<()> { pub fn run(&mut self, terminal: &mut DefaultTerminal) -> io::Result<()> {
self.start_time = Instant::now(); self.start_time = Instant::now();
while match self.exit_time { while !self.exit {
Some(exit_time) => Instant::now() < exit_time,
None => true,
} {
terminal.draw(|frame| self.draw(frame))?; terminal.draw(|frame| self.draw(frame))?;
self.handle_events()?; self.handle_events()?;
} }
@ -310,7 +307,7 @@ impl App {
} }
fn exit(&mut self) { fn exit(&mut self) {
self.exit_time = Some(Instant::now()); self.exit = true;
} }
fn submit(&mut self) { fn submit(&mut self) {
@ -328,12 +325,11 @@ impl App {
{ {
LoginResult::Success => { LoginResult::Success => {
self.error = false; self.error = false;
self.status = Status::Success; self.status = Status::Success
self.exit_time = Some(Instant::now() + Duration::from_millis(300));
} }
LoginResult::Failure => { LoginResult::Failure => {
self.error = true; self.error = true;
self.status = Status::Error; self.status = Status::Error
} }
}; };
} }