diff --git a/Cargo.toml b/Cargo.toml index bc2b234..a66290c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "crates/popcorn", "crates/popcorn-d", "crates/popcorn-conf", + "crates/popcorn-proto", ] [profile.release] @@ -11,4 +12,4 @@ lto = "thin" codegen-units = 1 strip = "symbols" opt-level = "z" -panic = "abort" \ No newline at end of file +panic = "abort" diff --git a/crates/popcorn-d/Cargo.toml b/crates/popcorn-d/Cargo.toml index 9ada8f2..b711b84 100644 --- a/crates/popcorn-d/Cargo.toml +++ b/crates/popcorn-d/Cargo.toml @@ -20,6 +20,7 @@ slint = { version = "1.14.1", default-features = false, features = ["backend-win toml = "0.9.8" popcorn-conf = { path = "../popcorn-conf" } serde = { version = "1.0.228", features = ["derive"] } +popcorn-proto = { path = "../popcorn-proto" } [build-dependencies] slint-build = "1.14.1" diff --git a/crates/popcorn-d/src/osd.rs b/crates/popcorn-d/src/osd.rs index c5d07dd..fad4219 100644 --- a/crates/popcorn-d/src/osd.rs +++ b/crates/popcorn-d/src/osd.rs @@ -1,4 +1,5 @@ use popcorn_conf::PopcornConfig; +use popcorn_proto::OsdArgs; use i_slint_backend_winit::{ Backend, @@ -22,12 +23,6 @@ fn parse_hex_color(s: &str) -> Result { } } -struct OsdArgs { - value: Option, - icon: Option, - color: Option, -} - pub struct OsdUi { ui: OSDpopup, } diff --git a/crates/popcorn-proto/Cargo.toml b/crates/popcorn-proto/Cargo.toml new file mode 100644 index 0000000..c2cd6b8 --- /dev/null +++ b/crates/popcorn-proto/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "popcorn-proto" +version = "0.1.0" +edition = "2024" + +[dependencies] +serde = { version = "1.0.228", features = ["derive"] } diff --git a/crates/popcorn-proto/src/lib.rs b/crates/popcorn-proto/src/lib.rs new file mode 100644 index 0000000..fead7ab --- /dev/null +++ b/crates/popcorn-proto/src/lib.rs @@ -0,0 +1,10 @@ +use serde::{Deserialize, Serialize}; + +// Protocol stuff for IPC comm + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct OsdArgs { + pub value: Option, + pub icon: Option, + pub color: Option, +} diff --git a/crates/popcorn/Cargo.toml b/crates/popcorn/Cargo.toml index 47179a3..84a150c 100644 --- a/crates/popcorn/Cargo.toml +++ b/crates/popcorn/Cargo.toml @@ -12,4 +12,5 @@ keywords = ["OSD", "popup", "desktop", "cli"] license = "GPL-3+" [dependencies] -clap = { version = "4.5.53", features = ["derive"] } \ No newline at end of file +clap = { version = "4.5.53", features = ["derive"] } +popcorn-proto = { path = "../popcorn-proto" } \ No newline at end of file diff --git a/crates/popcorn/src/args.rs b/crates/popcorn/src/args.rs index e63f703..6a41c04 100644 --- a/crates/popcorn/src/args.rs +++ b/crates/popcorn/src/args.rs @@ -1,4 +1,5 @@ use clap::{Parser, ValueHint}; +use popcorn_proto::OsdArgs; #[derive(Parser, Debug)] #[command( @@ -37,12 +38,6 @@ pub struct CliArgs { pub color: Option, } -pub struct OsdArgs { - pub value: Option, - pub icon: Option, - pub color: Option, -} - impl From for OsdArgs { fn from(c: CliArgs) -> Self { Self { diff --git a/crates/popcorn/src/main.rs b/crates/popcorn/src/main.rs index ab05d7f..9009e6e 100644 --- a/crates/popcorn/src/main.rs +++ b/crates/popcorn/src/main.rs @@ -1,6 +1,7 @@ mod args; -use args::{CliArgs, OsdArgs}; +use args::CliArgs; +use popcorn_proto::OsdArgs; use clap::Parser; fn main() {