Skip to content

Commit 40ffa84

Browse files
committed
update
1 parent acdf24e commit 40ffa84

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

crates/rs-os/rs-cross/try-notify/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,17 @@ edition = "2021"
77

88
[dependencies]
99
notify-rust = "4"
10+
chrono = { version = "0.4", optional = true }
11+
12+
13+
#
14+
# cli usage:
15+
# - cargo run --bin rs-eth-scanner -- scan "http://abc.url" "0xxxxx" "deposit" "100"
16+
#
17+
[[bin]]
18+
name = "run2"
19+
path = "src/run2.rs"
20+
21+
[[bin]]
22+
name = "run3"
23+
path = "src/run3.rs"

crates/rs-os/rs-cross/try-notify/Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tasks:
2323
run:
2424
aliases: [ "r" ]
2525
cmds:
26-
- cargo run
26+
- cargo run {{.CLI_ARGS}}
2727

2828
build:
2929
aliases: [ "b" ]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#[cfg(any(target_os = "windows", target_os = "macos"))]
2+
fn main() {
3+
println!("this is a xdg only feature")
4+
}
5+
6+
#[cfg(all(unix, not(target_os = "macos")))]
7+
fn main() -> Result<(), Box<dyn std::error::Error>> {
8+
use notify_rust::{Hint, Timeout};
9+
10+
notify_rust::Notification::new()
11+
.summary("Persistent notification")
12+
.body("This should not go away unless you want it to.")
13+
.icon("firefox")
14+
.hint(Hint::Resident(true)) // does not work on kde
15+
.timeout(Timeout::Never) // works on kde and gnome
16+
.show()?;
17+
Ok(())
18+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#[cfg(target_os = "macos")]
2+
fn main() -> Result<(), String> {
3+
use notify_rust::{
4+
error::MacOsError, get_bundle_identifier_or_default, set_application, Notification,
5+
};
6+
7+
let safari_id = get_bundle_identifier_or_default("Safari");
8+
set_application(&safari_id).map_err(|f| format!("{}", f))?;
9+
10+
match set_application(&safari_id) {
11+
Ok(_) => {},
12+
Err(MacOsError::Application(error)) => println!("{}", error),
13+
Err(MacOsError::Notification(error)) => println!("{}", error),
14+
}
15+
16+
Notification::new()
17+
.summary("Safari Crashed")
18+
.body("Just kidding, this is just the notify_rust example.")
19+
.appname("Safari")
20+
.icon("Safari")
21+
.show()
22+
.map_err(|f| format!("{}", f))?;
23+
24+
Ok(())
25+
}
26+
27+
#[cfg(all(unix, not(target_os = "macos")))]
28+
fn main() {
29+
println!("this is a mac only feature")
30+
}
31+
32+
#[cfg(target_os = "windows")]
33+
fn main() {
34+
println!("this is a mac only feature")
35+
}

0 commit comments

Comments
 (0)