fixup! feat: add basic timer

This commit is contained in:
koalp 2024-04-09 23:11:27 +02:00
parent a0d9498e59
commit ad3e8a3261
2 changed files with 18 additions and 9 deletions

2
.envrc
View File

@ -1 +1 @@
use flake . --impure use flake -L . --impure

View File

@ -1,7 +1,8 @@
use std::collections::HashMap;
use std::io::{stdout, Write}; use std::io::{stdout, Write};
use std::{env, thread}; use std::{env, thread};
use zbus::blocking::Connection; use zbus::blocking::Connection;
use zbus::{proxy, Result}; use zbus::{proxy, zvariant, Result};
#[proxy( #[proxy(
interface = "org.freedesktop.Notifications", interface = "org.freedesktop.Notifications",
@ -11,21 +12,29 @@ use zbus::{proxy, Result};
trait MyGreeter { trait MyGreeter {
fn notify( fn notify(
&self, &self,
something: &str, app_name: &str,
semothing_2: u32, replace_id: u32,
title: &str, app_icon: &str,
summary: &str,
body: &str, body: &str,
) -> Result<String>; actions: &[&str],
hints: HashMap<&str, zvariant::Value<'_>>,
expire_timeout: i32,
) -> Result<u32>;
} }
fn send_dbus_timer_out() { fn send_dbus_timer_out() {
let connection = Connection::session().unwrap(); let connection = Connection::session().unwrap();
let proxy = MyGreeterProxyBlocking::new(&connection).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() { fn main() {
let total_duration: u32 = env::args().nth(1).unwrap().parse::<u32>().unwrap() * 60; // FIXME: use clap and "start {}" instead of the second arg
let total_duration: u32 = env::args().nth(2).unwrap().parse::<u32>().unwrap() * 60;
for n in 0..(total_duration) { for n in 0..(total_duration) {
let left = total_duration - n; let left = total_duration - n;
@ -34,5 +43,5 @@ fn main() {
thread::sleep(std::time::Duration::from_secs(1)); thread::sleep(std::time::Duration::from_secs(1));
} }
// send_dbus_timer_out(); send_dbus_timer_out();
} }