Module ashpd::desktop::inhibit [−][src]
Expand description
Inhibit the session from being restarted or the user from logging out.
Examples
How to inhibit logout/user switch
use ashpd::desktop::inhibit::{InhibitFlags, InhibitProxy, SessionState}; use std::{thread, time}; async fn run() -> Result<(), ashpd::Error> { let connection = zbus::azync::Connection::new_session().await?; let proxy = InhibitProxy::new(&connection).await?; let session = proxy.create_monitor(Default::default()).await?; let state = proxy.receive_state_changed().await?; match state.session_state() { SessionState::Running => (), SessionState::QueryEnd => { proxy .inhibit( Default::default(), InhibitFlags::Logout | InhibitFlags::UserSwitch, "please save the opened project first", ) .await?; thread::sleep(time::Duration::from_secs(1)); proxy.query_end_response(&session).await?; } SessionState::Ending => { println!("ending the session"); } } Ok(()) }
Structs
InhibitProxy | The interface lets sandboxed applications inhibit the user session from ending, suspending, idling or getting switched away. |
InhibitState | A response received when the |
Enums
InhibitFlags | The actions to inhibit that can end the user’s session |
SessionState | The current state of the user’s session. |