Add suspend to greeter
This commit is contained in:
parent
13e3dcd911
commit
8d91f3c4ea
1 changed files with 21 additions and 5 deletions
|
|
@ -271,10 +271,11 @@ pub enum Message {
|
||||||
Socket(SocketState),
|
Socket(SocketState),
|
||||||
Prompt(String, bool, Option<String>),
|
Prompt(String, bool, Option<String>),
|
||||||
Session(String),
|
Session(String),
|
||||||
Error(String),
|
|
||||||
Username(Arc<UnixStream>, String),
|
Username(Arc<UnixStream>, String),
|
||||||
Auth(Arc<UnixStream>, Option<String>),
|
Auth(Arc<UnixStream>, Option<String>),
|
||||||
Login(Arc<UnixStream>),
|
Login(Arc<UnixStream>),
|
||||||
|
Suspend,
|
||||||
|
Error(String),
|
||||||
Exit,
|
Exit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,9 +372,6 @@ impl cosmic::Application for App {
|
||||||
Message::Session(selected_session) => {
|
Message::Session(selected_session) => {
|
||||||
self.selected_session = selected_session;
|
self.selected_session = selected_session;
|
||||||
}
|
}
|
||||||
Message::Error(error) => {
|
|
||||||
self.error_opt = Some(error);
|
|
||||||
}
|
|
||||||
Message::Username(socket, username) => {
|
Message::Username(socket, username) => {
|
||||||
self.username_opt = Some(username.clone());
|
self.username_opt = Some(username.clone());
|
||||||
return request_command(socket, Request::CreateSession { username });
|
return request_command(socket, Request::CreateSession { username });
|
||||||
|
|
@ -395,6 +393,24 @@ impl cosmic::Application for App {
|
||||||
None => todo!("session {:?} not found", self.selected_session),
|
None => todo!("session {:?} not found", self.selected_session),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::Suspend => {
|
||||||
|
#[cfg(feature = "logind")]
|
||||||
|
return Command::perform(
|
||||||
|
async move {
|
||||||
|
match crate::logind::suspend().await {
|
||||||
|
Ok(()) => message::none(),
|
||||||
|
Err(err) => {
|
||||||
|
log::error!("failed to suspend: {:?}", err);
|
||||||
|
message::app(Message::Error(err.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|x| x,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Message::Error(error) => {
|
||||||
|
self.error_opt = Some(error);
|
||||||
|
}
|
||||||
Message::Exit => {
|
Message::Exit => {
|
||||||
//TODO: cleaner method to exit?
|
//TODO: cleaner method to exit?
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
|
|
@ -456,7 +472,7 @@ impl cosmic::Application for App {
|
||||||
.on_press(Message::None),
|
.on_press(Message::None),
|
||||||
widget::button(widget::icon::from_name("system-suspend-symbolic"))
|
widget::button(widget::icon::from_name("system-suspend-symbolic"))
|
||||||
.padding(12.0)
|
.padding(12.0)
|
||||||
.on_press(Message::None),
|
.on_press(Message::Suspend),
|
||||||
widget::button(widget::icon::from_name("system-reboot-symbolic"))
|
widget::button(widget::icon::from_name("system-reboot-symbolic"))
|
||||||
.padding(12.0)
|
.padding(12.0)
|
||||||
.on_press(Message::None),
|
.on_press(Message::None),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue