From 41ca57898d104faeb521490b95a4e0c0e25a509a Mon Sep 17 00:00:00 2001 From: EliasSchriefer Date: Sun, 30 Aug 2020 16:41:59 +0200 Subject: [PATCH] Initialize all the stuff ...like D-Bus connection to system bus, env_logger, and tokio --- sfsmcctl/src/main.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sfsmcctl/src/main.rs diff --git a/sfsmcctl/src/main.rs b/sfsmcctl/src/main.rs new file mode 100644 index 0000000..e17e671 --- /dev/null +++ b/sfsmcctl/src/main.rs @@ -0,0 +1,28 @@ +use log::{ debug, info, warn, error }; + +#[tokio::main] +async fn main() -> Result<(), Box> { + // env_logger initialization + // If running with debug profile and `RUST_LOG` environment variable isn't set, set it to "debug" + if cfg!(debug_assertions) && std::env::var_os(env_logger::DEFAULT_FILTER_ENV).is_none() { + std::env::set_var(env_logger::DEFAULT_FILTER_ENV, "debug"); + } + env_logger::init(); + + // TODO: use clap + + // Connect with D-Bus + let (resource, c) = dbus_tokio::connection::new_system_sync()?; + debug!("D-Bus unique name: {}", c.unique_name()); + + // Spawn a new task for the D-Bus resource + tokio::spawn(async move { + let err = resource.await; + panic!("Lost connection to D-Bus: {}", err); + }); + + // TODO: + // Perform operations + + Ok(()) +} \ No newline at end of file