@@ -43,6 +43,7 @@ use wayland_protocols_wlr::screencopy::v1::client::zwlr_screencopy_manager_v1::Z
4343use super :: state:: { OverlaySuppression , WaylandGlobals , WaylandState , WaylandStateInit } ;
4444use crate :: {
4545 RESUME_SESSION_ENV ,
46+ backend:: ExitAfterCaptureMode ,
4647 capture:: { CaptureManager , CaptureOutcome } ,
4748 config:: { Action , Config , ConfigSource } ,
4849 input:: { BoardMode , ClickHighlightSettings , InputState } ,
@@ -139,17 +140,23 @@ fn resume_override_from_env() -> Option<bool> {
139140pub struct WaylandBackend {
140141 initial_mode : Option < String > ,
141142 freeze_on_start : bool ,
143+ exit_after_capture_mode : ExitAfterCaptureMode ,
142144 /// Tokio runtime for async capture operations
143145 tokio_runtime : tokio:: runtime:: Runtime ,
144146}
145147
146148impl WaylandBackend {
147- pub fn new ( initial_mode : Option < String > , freeze_on_start : bool ) -> Result < Self > {
149+ pub fn new (
150+ initial_mode : Option < String > ,
151+ freeze_on_start : bool ,
152+ exit_after_capture_mode : ExitAfterCaptureMode ,
153+ ) -> Result < Self > {
148154 let tokio_runtime = tokio:: runtime:: Runtime :: new ( )
149155 . context ( "Failed to create Tokio runtime for capture operations" ) ?;
150156 Ok ( Self {
151157 initial_mode,
152158 freeze_on_start,
159+ exit_after_capture_mode,
153160 tokio_runtime,
154161 } )
155162 }
@@ -259,6 +266,12 @@ impl WaylandBackend {
259266 ( Config :: default ( ) , ConfigSource :: Default )
260267 }
261268 } ;
269+ let exit_after_capture_mode = match self . exit_after_capture_mode {
270+ ExitAfterCaptureMode :: Auto if config. capture . exit_after_capture => {
271+ ExitAfterCaptureMode :: Always
272+ }
273+ other => other,
274+ } ;
262275
263276 info ! ( "Configuration loaded" ) ;
264277 debug ! ( " Color: {:?}" , config. drawing. default_color) ;
@@ -514,6 +527,7 @@ impl WaylandBackend {
514527 capture_manager,
515528 session_options,
516529 tokio_handle,
530+ exit_after_capture_mode,
517531 frozen_enabled : frozen_supported,
518532 preferred_output_identity,
519533 xdg_fullscreen,
@@ -773,6 +787,8 @@ impl WaylandBackend {
773787 state. show_overlay ( ) ;
774788 state. capture . clear_in_progress ( ) ;
775789
790+ let exit_on_success = state. capture . take_exit_on_success ( )
791+ && matches ! ( & outcome, CaptureOutcome :: Success ( _) ) ;
776792 match outcome {
777793 CaptureOutcome :: Success ( result) => {
778794 // Build notification message
@@ -821,6 +837,9 @@ impl WaylandBackend {
821837 log:: info!( "Capture cancelled: {}" , reason) ;
822838 }
823839 }
840+ if exit_on_success {
841+ state. input_state . should_exit = true ;
842+ }
824843 }
825844
826845 // Render if configured and needs redraw, but only if no frame callback pending
0 commit comments