@@ -139,17 +139,23 @@ fn resume_override_from_env() -> Option<bool> {
139139pub struct WaylandBackend {
140140 initial_mode : Option < String > ,
141141 freeze_on_start : bool ,
142+ exit_after_capture_override : bool ,
142143 /// Tokio runtime for async capture operations
143144 tokio_runtime : tokio:: runtime:: Runtime ,
144145}
145146
146147impl WaylandBackend {
147- pub fn new ( initial_mode : Option < String > , freeze_on_start : bool ) -> Result < Self > {
148+ pub fn new (
149+ initial_mode : Option < String > ,
150+ freeze_on_start : bool ,
151+ exit_after_capture_override : bool ,
152+ ) -> Result < Self > {
148153 let tokio_runtime = tokio:: runtime:: Runtime :: new ( )
149154 . context ( "Failed to create Tokio runtime for capture operations" ) ?;
150155 Ok ( Self {
151156 initial_mode,
152157 freeze_on_start,
158+ exit_after_capture_override,
153159 tokio_runtime,
154160 } )
155161 }
@@ -259,6 +265,8 @@ impl WaylandBackend {
259265 ( Config :: default ( ) , ConfigSource :: Default )
260266 }
261267 } ;
268+ let exit_after_capture =
269+ self . exit_after_capture_override || config. capture . exit_after_capture ;
262270
263271 info ! ( "Configuration loaded" ) ;
264272 debug ! ( " Color: {:?}" , config. drawing. default_color) ;
@@ -514,6 +522,7 @@ impl WaylandBackend {
514522 capture_manager,
515523 session_options,
516524 tokio_handle,
525+ exit_after_capture,
517526 frozen_enabled : frozen_supported,
518527 preferred_output_identity,
519528 xdg_fullscreen,
@@ -773,6 +782,8 @@ impl WaylandBackend {
773782 state. show_overlay ( ) ;
774783 state. capture . clear_in_progress ( ) ;
775784
785+ let exit_on_success =
786+ state. exit_after_capture && matches ! ( & outcome, CaptureOutcome :: Success ( _) ) ;
776787 match outcome {
777788 CaptureOutcome :: Success ( result) => {
778789 // Build notification message
@@ -821,6 +832,9 @@ impl WaylandBackend {
821832 log:: info!( "Capture cancelled: {}" , reason) ;
822833 }
823834 }
835+ if exit_on_success {
836+ state. input_state . should_exit = true ;
837+ }
824838 }
825839
826840 // Render if configured and needs redraw, but only if no frame callback pending
0 commit comments