@@ -19,26 +19,26 @@ use inputmodule_control::commands::ClapCli;
1919use inputmodule_control:: inputmodule:: { serial_commands} ;
2020use clap:: { Parser , Subcommand } ;
2121
22+ use log:: debug;
23+
2224fn handle_message ( msg : & Message ) {
23- println ! ( "Got message from DBus: {:?}" , msg) ;
25+ debug ! ( "Got message from DBus: {:?}" , msg) ;
26+
2427 let mut iter = msg. iter_init ( ) ;
2528 while let Some ( arg) = iter. get_refarg ( ) {
26- // Extract the inner value as a string and convert it to a String
2729 if let Some ( string_ref) = arg. as_str ( ) {
2830 let string_value: String = string_ref. to_string ( ) ;
29- println ! ( "String value: {}" , string_value) ;
31+ debug ! ( "String value: {}" , string_value) ;
3032
3133 if string_value. contains ( "calendar.google.com" ) {
3234 run_inputmodule_command ( vec ! [ "led-matrix" , "--pattern" , "all-on" , "--blink-n-times" , "3" ] ) ;
3335 run_inputmodule_command ( vec ! [ "led-matrix" , "--brightness" , "0" ] ) ;
3436 }
35- } else {
36- println ! ( "Not a string." ) ;
3737 }
3838 iter. next ( ) ;
3939 }
4040
41- println ! ( "Message handled" ) ;
41+ debug ! ( "DBus Message handled" ) ;
4242}
4343
4444pub fn run_inputmodule_command ( args : Vec < & str > ) {
@@ -52,7 +52,7 @@ pub fn run_inputmodule_command(args: Vec<&str>){
5252pub fn run_dbus_monitor ( ) {
5353 // First open up a connection to the desired bus.
5454 let conn = Connection :: new_session ( ) . expect ( "D-Bus connection failed" ) ;
55- println ! ( "Connection to DBus session monitor opened" ) ;
55+ debug ! ( "Connection to DBus session monitor opened" ) ;
5656
5757 // Second create a rule to match messages we want to receive; in this example we add no
5858 // further requirements, so all messages will match
@@ -72,23 +72,23 @@ pub fn run_dbus_monitor() {
7272 "BecomeMonitor" ,
7373 ( vec ! [ rule. match_str( ) ] , 0u32 ) ,
7474 ) ;
75- println ! ( "Monitoring DBus channel..." ) ;
75+ debug ! ( "Monitoring DBus channel..." ) ;
7676
7777 match result {
7878 // BecomeMonitor was successful, start listening for messages
7979 Ok ( _) => {
8080 conn. start_receive (
8181 rule,
8282 Box :: new ( |msg, _| {
83- println ! ( "Start listening" ) ;
83+ debug ! ( "Start listening" ) ;
8484 handle_message ( & msg) ;
8585 true
8686 } ) ,
8787 ) ;
8888 }
8989 // BecomeMonitor failed, fallback to using the old scheme
9090 Err ( e) => {
91- eprintln ! (
91+ debug ! (
9292 "Failed to BecomeMonitor: '{}', falling back to eavesdrop" ,
9393 e
9494 ) ;
@@ -113,7 +113,7 @@ pub fn run_dbus_monitor() {
113113 // This can sometimes fail, for example when listening to the system bus as a non-root user.
114114 // So, just like `dbus-monitor`, we attempt to fallback without `eavesdrop=true`:
115115 Err ( e) => {
116- eprintln ! ( "Failed to eavesdrop: '{}', trying without it" , e) ;
116+ debug ! ( "Failed to eavesdrop: '{}', trying without it" , e) ;
117117 conn. add_match ( rule, |_: ( ) , _, msg| {
118118 handle_message ( & msg) ;
119119 true
0 commit comments