@@ -90,11 +90,13 @@ impl SwayOSDApplication {
9090 server_config,
9191 async move {
9292 while let Ok ( ( arg_type, data) ) = action_receiver. recv( ) . await {
93- osd_app. action_activated(
93+ if let Err ( error ) = osd_app. action_activated(
9494 server_config. clone( ) ,
9595 arg_type,
9696 ( !data. is_empty( ) ) . then_some( data) ,
97- ) ;
97+ ) {
98+ eprintln!( "Could not activate action: {:?}" , error)
99+ }
98100 }
99101 Break
100102 }
@@ -133,7 +135,11 @@ impl SwayOSDApplication {
133135 }
134136 _ => continue ,
135137 } ;
136- osd_app. action_activated( server_config. clone( ) , arg_type, data) ;
138+ if let Err ( error) =
139+ osd_app. action_activated( server_config. clone( ) , arg_type, data)
140+ {
141+ eprintln!( "Could not activate action: {:?}" , error)
142+ }
137143 }
138144 Break
139145 }
@@ -192,11 +198,13 @@ impl SwayOSDApplication {
192198 // (automatically or through a firmware-handled hotkey being pressed)
193199 continue ;
194200 }
195- self . action_activated (
201+ if let Err ( error ) = self . action_activated (
196202 server_config. clone ( ) ,
197203 ArgTypes :: KbdBacklight ,
198204 Some ( format ! ( "{}:{}" , args. value, max_brightness) ) ,
199- ) ;
205+ ) {
206+ eprintln ! ( "Could not activate action: {:?}" , error)
207+ }
200208 } else {
201209 eprintln ! ( "UPower args aren't valid {:?}" , msg. args( ) ) ;
202210 }
@@ -386,10 +394,10 @@ impl SwayOSDApplication {
386394 server_config : Arc < ServerConfig > ,
387395 arg_type : ArgTypes ,
388396 value : Option < String > ,
389- ) {
397+ ) -> Result < ( ) , Box < dyn std :: error :: Error > > {
390398 match ( arg_type, value) {
391399 ( ArgTypes :: SinkVolumeRaise , step) => {
392- let mut device_type = VolumeDeviceType :: Sink ( SinkController :: create ( ) . unwrap ( ) ) ;
400+ let mut device_type = VolumeDeviceType :: Sink ( SinkController :: create ( ) ? ) ;
393401 if let Some ( device) =
394402 change_device_volume ( & mut device_type, VolumeChangeType :: Raise , step)
395403 {
@@ -402,7 +410,7 @@ impl SwayOSDApplication {
402410 reset_monitor_name ( ) ;
403411 }
404412 ( ArgTypes :: SinkVolumeLower , step) => {
405- let mut device_type = VolumeDeviceType :: Sink ( SinkController :: create ( ) . unwrap ( ) ) ;
413+ let mut device_type = VolumeDeviceType :: Sink ( SinkController :: create ( ) ? ) ;
406414 if let Some ( device) =
407415 change_device_volume ( & mut device_type, VolumeChangeType :: Lower , step)
408416 {
@@ -415,7 +423,7 @@ impl SwayOSDApplication {
415423 reset_monitor_name ( ) ;
416424 }
417425 ( ArgTypes :: SinkVolumeMuteToggle , _) => {
418- let mut device_type = VolumeDeviceType :: Sink ( SinkController :: create ( ) . unwrap ( ) ) ;
426+ let mut device_type = VolumeDeviceType :: Sink ( SinkController :: create ( ) ? ) ;
419427 if let Some ( device) =
420428 change_device_volume ( & mut device_type, VolumeChangeType :: MuteToggle , None )
421429 {
@@ -428,7 +436,7 @@ impl SwayOSDApplication {
428436 reset_monitor_name ( ) ;
429437 }
430438 ( ArgTypes :: SourceVolumeRaise , step) => {
431- let mut device_type = VolumeDeviceType :: Source ( SourceController :: create ( ) . unwrap ( ) ) ;
439+ let mut device_type = VolumeDeviceType :: Source ( SourceController :: create ( ) ? ) ;
432440 if let Some ( device) =
433441 change_device_volume ( & mut device_type, VolumeChangeType :: Raise , step)
434442 {
@@ -441,7 +449,7 @@ impl SwayOSDApplication {
441449 reset_monitor_name ( ) ;
442450 }
443451 ( ArgTypes :: SourceVolumeLower , step) => {
444- let mut device_type = VolumeDeviceType :: Source ( SourceController :: create ( ) . unwrap ( ) ) ;
452+ let mut device_type = VolumeDeviceType :: Source ( SourceController :: create ( ) ? ) ;
445453 if let Some ( device) =
446454 change_device_volume ( & mut device_type, VolumeChangeType :: Lower , step)
447455 {
@@ -454,7 +462,7 @@ impl SwayOSDApplication {
454462 reset_monitor_name ( ) ;
455463 }
456464 ( ArgTypes :: SourceVolumeMuteToggle , _) => {
457- let mut device_type = VolumeDeviceType :: Source ( SourceController :: create ( ) . unwrap ( ) ) ;
465+ let mut device_type = VolumeDeviceType :: Source ( SourceController :: create ( ) ? ) ;
458466 if let Some ( device) =
459467 change_device_volume ( & mut device_type, VolumeChangeType :: MuteToggle , None )
460468 {
@@ -468,12 +476,9 @@ impl SwayOSDApplication {
468476 }
469477 // TODO: Brightness
470478 ( ArgTypes :: BrightnessRaise , step) => {
471- if let Ok ( mut brightness_backend) =
472- change_brightness ( BrightnessChangeType :: Raise , step)
473- {
474- for window in self . choose_windows ( ) {
475- window. changed_brightness ( brightness_backend. as_mut ( ) ) ;
476- }
479+ let mut brightness_backend = change_brightness ( BrightnessChangeType :: Raise , step) ?;
480+ for window in self . choose_windows ( ) {
481+ window. changed_brightness ( brightness_backend. as_mut ( ) ) ;
477482 }
478483 reset_min_brightness ( ) ;
479484 reset_monitor_name ( ) ;
@@ -490,12 +495,9 @@ impl SwayOSDApplication {
490495 reset_monitor_name ( ) ;
491496 }
492497 ( ArgTypes :: BrightnessSet , value) => {
493- if let Ok ( mut brightness_backend) =
494- change_brightness ( BrightnessChangeType :: Set , value)
495- {
496- for window in self . choose_windows ( ) {
497- window. changed_brightness ( brightness_backend. as_mut ( ) ) ;
498- }
498+ let mut brightness_backend = change_brightness ( BrightnessChangeType :: Set , value) ?;
499+ for window in self . choose_windows ( ) {
500+ window. changed_brightness ( brightness_backend. as_mut ( ) ) ;
499501 }
500502 reset_min_brightness ( ) ;
501503 reset_monitor_name ( ) ;
@@ -556,8 +558,7 @@ impl SwayOSDApplication {
556558 ( ArgTypes :: Player , name) => set_player ( name. unwrap_or ( "" . to_string ( ) ) ) ,
557559 ( ArgTypes :: Playerctl , value) => {
558560 let value = & value. unwrap_or ( "" . to_string ( ) ) ;
559-
560- let action = PlayerctlAction :: from ( value) . unwrap ( ) ;
561+ let action = PlayerctlAction :: from ( value) ?;
561562 if let Ok ( mut player) = Playerctl :: new ( action, server_config) {
562563 match player. run ( ) {
563564 Ok ( _) => {
@@ -647,5 +648,6 @@ impl SwayOSDApplication {
647648 )
648649 }
649650 } ;
651+ Ok ( ( ) )
650652 }
651653}
0 commit comments