Support unlock from logind dbus
This commit is contained in:
parent
e9b5524992
commit
349c009321
2 changed files with 6 additions and 8 deletions
|
|
@ -196,14 +196,13 @@ pub enum Message {
|
||||||
Channel(mpsc::Sender<String>),
|
Channel(mpsc::Sender<String>),
|
||||||
BackgroundState(cosmic_bg_config::state::State),
|
BackgroundState(cosmic_bg_config::state::State),
|
||||||
LogindLock,
|
LogindLock,
|
||||||
LogindUnlock,
|
|
||||||
NetworkIcon(Option<&'static str>),
|
NetworkIcon(Option<&'static str>),
|
||||||
PowerInfo(Option<(String, f64)>),
|
PowerInfo(Option<(String, f64)>),
|
||||||
Prompt(String, bool, Option<String>),
|
Prompt(String, bool, Option<String>),
|
||||||
Submit,
|
Submit,
|
||||||
Suspend,
|
Suspend,
|
||||||
Error(String),
|
Error(String),
|
||||||
Exit,
|
Unlock,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The [`App`] stores application-specific state.
|
/// The [`App`] stores application-specific state.
|
||||||
|
|
@ -410,9 +409,6 @@ impl cosmic::Application for App {
|
||||||
Message::LogindLock => {
|
Message::LogindLock => {
|
||||||
log::warn!("TODO: LogindLock");
|
log::warn!("TODO: LogindLock");
|
||||||
}
|
}
|
||||||
Message::LogindUnlock => {
|
|
||||||
log::warn!("TODO: LogindUnlock");
|
|
||||||
}
|
|
||||||
Message::NetworkIcon(network_icon_opt) => {
|
Message::NetworkIcon(network_icon_opt) => {
|
||||||
self.network_icon_opt = network_icon_opt;
|
self.network_icon_opt = network_icon_opt;
|
||||||
}
|
}
|
||||||
|
|
@ -466,7 +462,7 @@ impl cosmic::Application for App {
|
||||||
Message::Error(error) => {
|
Message::Error(error) => {
|
||||||
self.error_opt = Some(error);
|
self.error_opt = Some(error);
|
||||||
}
|
}
|
||||||
Message::Exit => {
|
Message::Unlock => {
|
||||||
let mut commands = Vec::new();
|
let mut commands = Vec::new();
|
||||||
for (_output, surface_id) in self.surface_ids.drain() {
|
for (_output, surface_id) in self.surface_ids.drain() {
|
||||||
self.surface_images.remove(&surface_id);
|
self.surface_images.remove(&surface_id);
|
||||||
|
|
@ -676,7 +672,7 @@ impl cosmic::Application for App {
|
||||||
if lock {
|
if lock {
|
||||||
Message::LogindLock
|
Message::LogindLock
|
||||||
} else {
|
} else {
|
||||||
Message::LogindUnlock
|
Message::Unlock
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -754,7 +750,7 @@ impl cosmic::Application for App {
|
||||||
match pam_res {
|
match pam_res {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
log::info!("successfully authenticated");
|
log::info!("successfully authenticated");
|
||||||
msg_tx.send(Message::Exit).await.unwrap();
|
msg_tx.send(Message::Unlock).await.unwrap();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,10 @@ pub async fn handler(msg_tx: &mut mpsc::Sender<bool>) -> Result<(), Box<dyn Erro
|
||||||
loop {
|
loop {
|
||||||
// Waits until lock or unlock signals have been received
|
// Waits until lock or unlock signals have been received
|
||||||
tokio::select!(_ = lock.next() => {
|
tokio::select!(_ = lock.next() => {
|
||||||
|
log::info!("logind lock");
|
||||||
msg_tx.send(true).await?;
|
msg_tx.send(true).await?;
|
||||||
}, _ = unlock.next() => {
|
}, _ = unlock.next() => {
|
||||||
|
log::info!("logind unlock");
|
||||||
msg_tx.send(false).await?;
|
msg_tx.send(false).await?;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue