From ad3e8a326145e59e552def42a7ff7e2d4f9452c0 Mon Sep 17 00:00:00 2001 From: koalp Date: Tue, 9 Apr 2024 23:11:27 +0200 Subject: [PATCH] fixup! feat: add basic timer --- .envrc | 2 +- src/main.rs | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.envrc b/.envrc index cffc922..9b0757c 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use flake . --impure +use flake -L . --impure diff --git a/src/main.rs b/src/main.rs index 1ca0a45..7a31f1e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,8 @@ +use std::collections::HashMap; use std::io::{stdout, Write}; use std::{env, thread}; use zbus::blocking::Connection; -use zbus::{proxy, Result}; +use zbus::{proxy, zvariant, Result}; #[proxy( interface = "org.freedesktop.Notifications", @@ -11,21 +12,29 @@ use zbus::{proxy, Result}; trait MyGreeter { fn notify( &self, - something: &str, - semothing_2: u32, - title: &str, + app_name: &str, + replace_id: u32, + app_icon: &str, + summary: &str, body: &str, - ) -> Result; + actions: &[&str], + hints: HashMap<&str, zvariant::Value<'_>>, + expire_timeout: i32, + ) -> Result; } fn send_dbus_timer_out() { let connection = Connection::session().unwrap(); let proxy = MyGreeterProxyBlocking::new(&connection).unwrap(); - proxy.notify("", 0, "a", "b").unwrap(); + let result = proxy + .notify("", 0, "", "🍎", "Timer fini", &["a"], HashMap::new(), 0) + .unwrap(); + dbg!(result); } fn main() { - let total_duration: u32 = env::args().nth(1).unwrap().parse::().unwrap() * 60; + // FIXME: use clap and "start {}" instead of the second arg + let total_duration: u32 = env::args().nth(2).unwrap().parse::().unwrap() * 60; for n in 0..(total_duration) { let left = total_duration - n; @@ -34,5 +43,5 @@ fn main() { thread::sleep(std::time::Duration::from_secs(1)); } - // send_dbus_timer_out(); + send_dbus_timer_out(); }