fixup! feat: add basic timer
This commit is contained in:
parent
a0d9498e59
commit
ad3e8a3261
25
src/main.rs
25
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<String>;
|
||||
actions: &[&str],
|
||||
hints: HashMap<&str, zvariant::Value<'_>>,
|
||||
expire_timeout: i32,
|
||||
) -> Result<u32>;
|
||||
}
|
||||
|
||||
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::<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) {
|
||||
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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user