From 7a20c88896d77fc2e004b28f03639df7b576c57e Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 30 Oct 2024 13:02:46 -0700 Subject: [PATCH] Lock session on screen blanking --- src/fade_black.rs | 5 +++++ src/main.rs | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/fade_black.rs b/src/fade_black.rs index 4983c44..47f351b 100644 --- a/src/fade_black.rs +++ b/src/fade_black.rs @@ -137,6 +137,11 @@ impl Dispatch for State { .output_power .set_mode(zwlr_output_power_v1::Mode::Off); output.fade_surface = None; + + // All outputs are done fading + if state.outputs.iter().all(|o| o.fade_surface.is_none()) { + state.fade_done(); + } } else { fade_surface.update(&state.inner); } diff --git a/src/main.rs b/src/main.rs index e2f509a..de050ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -148,6 +148,16 @@ impl State { } } + // Fade surfaces on all outputs have finished fading out + fn fade_done(&mut self) { + if let Some(command) = self + .system_actions + .get(&shortcuts::action::System::LockScreen) + { + crate::run_command(command.to_string()); + } + } + fn update_suspend_idle(&mut self, is_idle: bool) { if is_idle { // TODO: Make command configurable