diff --git a/Cargo.lock b/Cargo.lock index ac248b0..a54dfcb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,21 +39,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "almost_everything" -version = "0.4.0-alpha.2" -dependencies = [ - "hyprland", -] - -[[package]] -name = "almost_everything_async" -version = "0.4.0-alpha.2" -dependencies = [ - "hyprland", - "tokio", -] - [[package]] name = "async-channel" version = "1.9.0" @@ -602,16 +587,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" version = "0.32.2" @@ -929,7 +904,6 @@ dependencies = [ "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "socket2 0.5.7", diff --git a/Cargo.toml b/Cargo.toml index f456dde..a35d09d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,6 @@ lto = true [workspace] members = [ - "examples/almost_everything", - "examples/almost_everything_async", "hyprland-macros", ] @@ -44,7 +42,9 @@ serde_repr = "0.1" tokio = { version = "1", features = [ "io-std", "io-util", + "macros", "net", + "rt" ], optional = true } async-net = { version = "2.0", optional = true } async-std = { version = "1.12", optional = true } diff --git a/examples/almost_everything/Cargo.toml b/examples/almost_everything/Cargo.toml deleted file mode 100644 index d63653f..0000000 --- a/examples/almost_everything/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "almost_everything" -edition = "2021" -version.workspace = true -license.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true -authors.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -hyprland = { version = "0.4.0-alpha.1", path = "../..", default-features = false, features = ["config", "ctl", "data", "dispatch", "keyword", "listener", "async-lite"] } diff --git a/examples/almost_everything/src/main.rs b/examples/almost_everything/src/main.rs deleted file mode 100644 index b9b0fcd..0000000 --- a/examples/almost_everything/src/main.rs +++ /dev/null @@ -1,86 +0,0 @@ -use std::fmt::Display; - -use hyprland::data::{Client, Clients, Monitors, Workspace}; -use hyprland::dispatch::*; -use hyprland::event_listener::EventListener; -use hyprland::keyword::*; -use hyprland::prelude::*; -use hyprland::shared::WorkspaceType; - -fn main() -> hyprland::Result<()> { - // We can call dispatchers with the dispatch macro, and struct! - // You can decide what you want to use, below are some examples of their usage - - // Here we are telling hyprland to open kitty using the dispatch macro! - hyprland::dispatch!(Exec, "kitty")?; - - // Here we are moving the cursor to the top left corner! We can also just use the Dispatch - // struct! - Dispatch::call(DispatchType::MoveCursorToCorner(Corner::TopLeft))?; - - // Here we are adding a keybinding to Hyprland using the bind macro! - hyprland::bind!(SUPER, Key, "i" => ToggleFloating, None)?; - - // Here we are getting the border size - let border_size = match Keyword::get("general:border_size")?.value { - OptionValue::Int(i) => i, - _ => panic!("border size can only be a int"), - }; - println!("{border_size}"); - - // Here we change a keyword, in this case we are doubling the border size we got above - Keyword::set("general:border_size", border_size * 2)?; - - // get all monitors - let monitors = Monitors::get()?; - - // and the active window - let win = Client::get_active()?; - - // and all open windows - let clients = Clients::get()?; - - // and the active workspace - let work = Workspace::get_active()?; - - // and printing them all out! - println!("monitors: {monitors:#?},\nactive window: {win:#?},\nclients {clients:#?}\nworkspace: {work:#?}"); - - // Create a event listener - let mut event_listener = EventListener::new()?; - - // Shows when active window changes - event_listener.add_active_window_change_handler(|data| { - println!("{data:#?}"); - }); - - // This changes the workspace to 5 if the workspace is switched to 9 - // this is a performance and mutable state test - event_listener.add_workspace_change_handler(|id, state| { - if id == WorkspaceType::Regular('9'.to_string()) { - state.active_workspace = WorkspaceType::Regular('2'.to_string()); - } - }); - // This makes it so you can't turn on fullscreen lol - event_listener.add_fullscreen_state_change_handler(|fstate| { - if fstate { - dispatch!(ToggleFullscreen, FullscreenType::Real); - } - }); - // Makes a monitor unfocusable - event_listener.add_active_monitor_change_handler(|data, state| { - let hyprland::event_listener::MonitorEventData { monitor_name, .. } = data; - - if monitor_name == *"DP-1".to_string() { - state.active_monitor = "eDP-1".to_string() - } - }); - - // add event, yes functions and closures both work! - event_listener.add_workspace_change_handler(|id| println!("workspace changed to {id:#?}")); - - // and execute the function - // here we are using the blocking variant - // but there is a async version too - event_listener.start_listener() -} diff --git a/examples/almost_everything_async/Cargo.toml b/examples/almost_everything_async/Cargo.toml deleted file mode 100644 index 892a7ac..0000000 --- a/examples/almost_everything_async/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "almost_everything_async" -edition = "2021" -version.workspace = true -license.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true -authors.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -hyprland = { version = "0.4.0-alpha.1", path = "../.." } -tokio = { version = "1", features = [ - "macros", - "io-std", - "rt-multi-thread", - "time", -] } diff --git a/examples/almost_everything_async/src/main.rs b/examples/almost_everything_async/src/main.rs deleted file mode 100644 index a82b15e..0000000 --- a/examples/almost_everything_async/src/main.rs +++ /dev/null @@ -1,108 +0,0 @@ -use hyprland::data::{Animations, Client, Clients, Monitors, Workspace}; -use hyprland::event_listener::AsyncEventListener; -use hyprland::keyword::*; -use hyprland::prelude::*; -//use hyprland::shared::WorkspaceType; -use hyprland::{async_closure, dispatch::*}; - -fn main() -> hyprland::Result<()> { - // It is always a good practice to configure your runtime to your specifications - tokio::runtime::Builder::new_multi_thread().enable_io().enable_time().worker_threads(1).build()?.block_on(async move { - // We can call dispatchers with the dispatch function! - - // Here we are telling hyprland to open kitty using the dispatch macro! - hyprland::dispatch!(async; Exec, "kitty").await?; - - // Here we are adding a keybinding to Hyprland using the bind macro! - hyprland::bind!(async; SUPER, Key, "i" => ToggleFloating, None).await?; - - // Here we are moving the cursor to the top left corner! We can also just use the Dispatch - // struct! - Dispatch::call_async(DispatchType::MoveCursorToCorner(Corner::TopLeft)).await?; - - let border_size = match Keyword::get_async("general:border_size").await?.value { - OptionValue::Int(i) => i, - _ => panic!("border size can only be a int"), - }; - println!("{border_size}"); - - // Here we change a keyword, yes its a dispatcher don't complain - Keyword::set_async("general:border_size", border_size * 2).await?; - // get all monitors - let monitors = Monitors::get_async().await?; - // and the active window - let win = Client::get_active_async().await?; - // and all open windows - let clients = Clients::get_async().await?; - // and the active workspace - let work = Workspace::get_active_async().await?; - // and printing them all out! - println!("monitors: {monitors:#?},\nactive window: {win:#?},\nclients {clients:#?}\nworkspace:{work:#?}"); - let animations = Animations::get_async().await?; - println!("{animations:#?}"); - // Create a event listener - let mut event_listener = AsyncEventListener::new(); - - //This changes the workspace to 5 if the workspace is switched to 9 - //this is a performance and mutable state test - // event_listener.add_workspace_change_handler(async_closure! {|id, state| { - // if id == WorkspaceType::Regular('9'.to_string()) { - // *state.workspace = '2'.to_string(); - // } - // }}); - /* - event_listener.add_workspace_change_handler(|id, state| { - Box::pin(async move { - if id == WorkspaceType::Regular('9'.to_string()) { - *state.workspace = '2'.to_string(); - } - }) - }); - - // This makes it so you can't turn on fullscreen lol - event_listener.add_fullscreen_state_change_handler(async_closure! {|fstate, state| { - if fstate { - *state.fullscreen = false; - } - }}); - // Makes a monitor unfocusable - event_listener.add_active_monitor_change_handler(async_closure! {|data, state| { - let hyprland::event_listener::MonitorEventData{ monitor_name, .. } = data; - - if monitor_name == *"DP-1".to_string() { - *state.monitor = "eDP-1".to_string() - } - }}); - */ - // add event, yes functions and closures both work! - - event_listener.add_workspace_change_handler( - async_closure! { move |id| println!("workspace changed to {id:#?}")}, - ); - event_listener.add_active_window_change_handler( - async_closure! { move |data| println!("window changed to {data:#?}")}, - ); - // Waybar example - // event_listener.add_active_window_change_handler(|data| { - // use hyprland::event_listener::WindowEventData; - // let string = match data { - // Some(WindowEventData(class, title)) => format!("{class}: {title}"), - // None => "".to_string() - // }; - // println!(r#"{{"text": "{string}", class: "what is this?"}}"#); - // }); - - // reset your border size back to normal - tokio::spawn(async move { - tokio::time::sleep(std::time::Duration::from_secs(5)).await; - println!("Resetting border size!"); - Keyword::set_async("general:border_size", border_size).await?; - Ok::<_, hyprland::shared::HyprError>(()) - }); - - // and execute the function - // here we are using the blocking variant - // but there is a async version too - event_listener.start_listener_async().await - }) -} diff --git a/examples/bind.rs b/examples/bind.rs new file mode 100644 index 0000000..abf43e3 --- /dev/null +++ b/examples/bind.rs @@ -0,0 +1,25 @@ +/// Demonstates the use of Hyprland-rs for creating key bindings +/// and using submaps +/// +/// Usage: cargo run --example bind + +use std::io::Read; +use hyprland::dispatch; +use hyprland::dispatch::{Dispatch, DispatchType}; +use hyprland::keyword::Keyword; + +fn main() -> hyprland::Result<()> { + Keyword::set("submap", "example")?; + hyprland::bind!(SUPER, Key, "I" => ToggleFloating, None)?; + hyprland::bind!(l | CTRL ALT, Key, "Delete" => Exec, "sudo reboot"); // Reboot including from lock screen + hyprland::bind!(e | SUPER, Key, "C" => KillActiveWindow); // Kill all your windows + Keyword::set("submap", "reset")?; + + dispatch!(Custom, "submap", "example")?; + println!("Press enter to revert to default keymap"); + let _ = std::io::stdin().read(&mut [0u8]) + .expect("Crashed: Run `hyprctl dispatch submap reset` to return to default submap"); + dispatch!(Custom, "submap", "reset")?; + + Ok(()) +} \ No newline at end of file diff --git a/examples/bind_async.rs b/examples/bind_async.rs new file mode 100644 index 0000000..454cf34 --- /dev/null +++ b/examples/bind_async.rs @@ -0,0 +1,24 @@ +/// Demonstates the use of Hyprland-rs for asyncronous creation key bindings +/// and using submaps +/// +/// Usage: cargo run --example bind + +use std::io::Read; +use hyprland::dispatch; +use hyprland::dispatch::{Dispatch, DispatchType}; +use hyprland::keyword::Keyword; + +#[tokio::main(flavor = "current_thread")] +async fn main() -> hyprland::Result<()> { + Keyword::set_async("submap", "example").await?; + hyprland::bind!(async; SUPER, Key, "I" => ToggleFloating, None).await?; + hyprland::bind!(async; l | CTRL ALT, Key, "Delete" => Exec, "sudo reboot").await?; // Reboot including from lock screen + hyprland::bind!(async; e | SUPER, Key, "C" => KillActiveWindow).await?; // Kill all your windows + Keyword::set_async("submap", "reset").await?; + + dispatch!(async; Custom, "submap", "example").await?; + println!("Press enter to revert to default keymap"); + let _ = std::io::stdin().read(&mut [0u8]).unwrap(); + dispatch!(async; Custom, "submap", "reset").await?; + Ok(()) +} \ No newline at end of file diff --git a/examples/data.rs b/examples/data.rs new file mode 100644 index 0000000..48c1615 --- /dev/null +++ b/examples/data.rs @@ -0,0 +1,29 @@ +/// Demostrates using hyprland-rs to fetch information about clients, workspaces and monitors +/// +/// Usage: cargo run --example data +/// Example: cargo run --example data client (Gets data on active client) +/// Example: cargo run --example data workspaces (Gets data on all workspaces) + +use hyprland::data::{Animations, Binds, Client, Clients, Monitor, Monitors, Workspace, Workspaces}; +use hyprland::shared::{HyprData, HyprDataActive, HyprDataActiveOptional}; +fn main() -> hyprland::Result<()>{ + let args: Vec<_> = std::env::args().skip(1).collect(); + + if args.len() == 0 { + panic!("You have to specify client, workspace or monitor") + } + + match args[0].as_str() { + "client" => println!("{:#?}", Client::get_active()?), + "monitor" => println!("{:#?}", Monitor::get_active()?), + "workspace" => println!("{:#?}", Workspace::get_active()?), + "animations" => println!("{:#?}", Animations::get()?), + "binds" => println!("{:#?}", Binds::get()?), + "clients" => println!("{:#?}", Clients::get()?), + "monitors" => println!("{:#?}", Monitors::get()?), + "workspaces" => println!("{:#?}", Workspaces::get()?), + _ => println!("Specify one of client(s), monitor(s) or workspace(s)") + }; + + Ok(()) +} \ No newline at end of file diff --git a/examples/data_async.rs b/examples/data_async.rs new file mode 100644 index 0000000..d246b82 --- /dev/null +++ b/examples/data_async.rs @@ -0,0 +1,31 @@ +/// Demostrates asynchronously using Hyprland-rs to fetch information about your Hyprland environment +/// +/// Usage: cargo run --example data_async +/// Example: cargo run --example data_async client (Gets data on active client) +/// Example: cargo run --example data_async workspaces (Gets data on all workspaces) + +use hyprland::data::{Animations, Binds, Client, Clients, Monitor, Monitors, Workspace, Workspaces}; +use hyprland::shared::{HyprData, HyprDataActive, HyprDataActiveOptional}; + +#[tokio::main(flavor = "current_thread")] +async fn main() -> hyprland::Result<()>{ + let args: Vec<_> = std::env::args().skip(1).collect(); + + if args.len() == 0 { + panic!("You have to specify client, workspace or monitor") + } + + match args[0].as_str() { + "client" => println!("{:#?}", Client::get_active_async().await?), + "monitor" => println!("{:#?}", Monitor::get_active_async().await?), + "workspace" => println!("{:#?}", Workspace::get_active_async().await?), + "animations" => println!("{:#?}", Animations::get_async().await?), + "binds" => println!("{:#?}", Binds::get_async().await?), + "clients" => println!("{:#?}", Clients::get_async().await?), + "monitors" => println!("{:#?}", Monitors::get_async().await?), + "workspaces" => println!("{:#?}", Workspaces::get_async().await?), + _ => println!("Specify one of client(s), monitor(s) or workspace(s)") + }; + + Ok(()) +} \ No newline at end of file diff --git a/examples/dispatch.rs b/examples/dispatch.rs new file mode 100644 index 0000000..b29588b --- /dev/null +++ b/examples/dispatch.rs @@ -0,0 +1,62 @@ +/// Demonstrates usage of various dispatch calls +/// +/// Usage: cargo run --example dispatch ? ? ? +/// Example: cargo run --example dispatch [workspace 2] kitty + +use hyprland::dispatch; +use hyprland::dispatch::{Corner, Dispatch, DispatchType, FullscreenType, WorkspaceIdentifierWithSpecial}; +use hyprland::dispatch::DispatchType::*; + +fn describe(desc: &str) { + std::thread::sleep(std::time::Duration::from_secs(2)); + println!("{}", desc); +} + +fn main() -> hyprland::Result<()> { + let program = std::env::args().skip(1).collect::>().join(" "); + + dispatch!(Exec, &program)?; + + describe("Moving cursor to top left"); + dispatch!(MoveCursorToCorner, Corner::TopLeft)?; + + describe("Moving cursor to top right"); + dispatch!(MoveCursorToCorner, Corner::TopRight)?; + + describe("Moving cursor to bottom right"); + dispatch!(MoveCursorToCorner, Corner::BottomRight)?; + + describe("Moving cursor to bottom left"); + dispatch!(MoveCursorToCorner, Corner::BottomLeft)?; + + describe("Moving window to next workspace"); + dispatch!(MoveToWorkspace, WorkspaceIdentifierWithSpecial::Relative(1), None)?; + + describe("Moving window to previous workspace"); + dispatch!(MoveToWorkspace, WorkspaceIdentifierWithSpecial::Relative(-1), None)?; + + describe("Toggling fullscreen"); + dispatch!(ToggleFullscreen, FullscreenType::Maximize)?; + describe("Reverting fullscreen"); + Dispatch::call(ToggleFullscreen(FullscreenType::Maximize))?; + + describe("Toggling floating window"); + dispatch!(ToggleFloating, None)?; + describe("Reverting floating window"); + Dispatch::call(ToggleFloating(None))?; + + describe("Toggling split layout"); + Dispatch::call(ToggleSplit)?; + describe("Reverting split layout"); + Dispatch::call(ToggleSplit)?; + + describe("Toggling opaque"); + Dispatch::call(ToggleOpaque)?; + describe("Reverting opaque"); + Dispatch::call(ToggleOpaque)?; + + describe("Closing window"); + Dispatch::call(KillActiveWindow)?; + + Ok(()) +} \ No newline at end of file diff --git a/examples/dispatch_async.rs b/examples/dispatch_async.rs new file mode 100644 index 0000000..12e853b --- /dev/null +++ b/examples/dispatch_async.rs @@ -0,0 +1,64 @@ +/// Demonstrates usage of various asyncronous dispatch calls +/// +/// Usage: cargo run --example dispatch_async + +use hyprland::dispatch; +use hyprland::dispatch::{Corner, Dispatch, DispatchType, FullscreenType, WorkspaceIdentifierWithSpecial}; +use hyprland::dispatch::DispatchType::*; + +fn describe(desc: &str) { + std::thread::sleep(std::time::Duration::from_secs(2)); + println!("{desc}"); +} + + +#[tokio::main(flavor = "current_thread")] +async fn main() -> hyprland::Result<()> { + let program = std::env::args().skip(1).collect::>().join(" "); + + println!("Executing {program}"); + dispatch!(async; Exec, &program).await?; + + describe("Moving cursor to top left"); + dispatch!(async; MoveCursorToCorner, Corner::TopLeft).await?; + + describe("Moving cursor to top right"); + dispatch!(async; MoveCursorToCorner, Corner::TopRight).await?; + + describe("Moving cursor to bottom right"); + dispatch!(async; MoveCursorToCorner, Corner::BottomRight).await?; + + describe("Moving cursor to bottom left"); + dispatch!(async; MoveCursorToCorner, Corner::BottomLeft).await?; + + describe("Moving window to next workspace"); + dispatch!(async; MoveToWorkspace, WorkspaceIdentifierWithSpecial::Relative(1), None).await?; + + describe("Moving window to previous workspace"); + dispatch!(async; MoveToWorkspace, WorkspaceIdentifierWithSpecial::Relative(-1), None).await?; + + describe("Toggling fullscreen"); + dispatch!(async; ToggleFullscreen, FullscreenType::Maximize).await?; + describe("Reverting fullscreen"); + dispatch!(async; ToggleFullscreen, FullscreenType::Maximize).await?; + + describe("Toggling floating window"); + dispatch!(async; ToggleFloating, None).await?; + describe("Reverting floating window"); + Dispatch::call_async(ToggleFloating(None)).await?; + + describe("Toggling split layout"); + Dispatch::call_async(ToggleSplit).await?; + describe("Reverting split layout"); + Dispatch::call_async(ToggleSplit).await?; + + describe("Toggling opaque"); + Dispatch::call_async(ToggleOpaque).await?; + describe("Reverting opaque"); + Dispatch::call_async(ToggleOpaque).await?; + + describe("Closing window"); + Dispatch::call_async(KillActiveWindow).await?; + + Ok(()) +} \ No newline at end of file diff --git a/examples/events.rs b/examples/events.rs new file mode 100644 index 0000000..b53d459 --- /dev/null +++ b/examples/events.rs @@ -0,0 +1,24 @@ +/// Demostrats using hyprland-rs to listen for events +/// +/// Usage: cargo run --example events + +use hyprland::event_listener::EventListener; + +fn main() -> hyprland::Result<()> { + // Create a event listener + let mut event_listener = EventListener::new(); + + event_listener.add_active_window_change_handler(|data| println!("{data:#?}")); + event_listener.add_fullscreen_state_change_handler( + |fstate| println!("Window {} fullscreen", if fstate { "is" } else { "is not" }) + ); + event_listener.add_active_monitor_change_handler(|state| println!("Monitor state: {state:#?}")); + event_listener.add_workspace_change_handler(|id| println!("workspace changed to {id:?}")); + + // and execute the function + // here we are using the blocking variant + // but there is a async version too + event_listener.start_listener()?; + + Ok(()) +} \ No newline at end of file diff --git a/examples/events_async.rs b/examples/events_async.rs new file mode 100644 index 0000000..0c2d960 --- /dev/null +++ b/examples/events_async.rs @@ -0,0 +1,36 @@ +/// Demostrats using hyprland-rs to asynchronously listen for events +/// +/// Usage: cargo run --example events + +use hyprland::async_closure; +use hyprland::event_listener::AsyncEventListener; + +#[tokio::main(flavor = "current_thread")] +async fn main() -> hyprland::Result<()> { + // Create a event listener + let mut event_listener = AsyncEventListener::new(); + + event_listener.add_active_window_change_handler(async_closure! { + |data| println!("{data:#?}") + }); + + event_listener.add_fullscreen_state_change_handler(async_closure! { + |fstate| println!("Window {} fullscreen", if fstate { "is" } else { "is not" }) + }); + + event_listener.add_active_monitor_change_handler(async_closure! { + |state| println!("Monitor state: {state:#?}") + }); + + // add event, yes functions and closures both work! + event_listener.add_workspace_change_handler(async_closure! { + |id| println!("workspace changed to {id:?}") + }); + + // and execute the function + // here we are using the blocking variant + // but there is a async version too + event_listener.start_listener_async().await?; + + Ok(()) +} \ No newline at end of file diff --git a/examples/keyword.rs b/examples/keyword.rs new file mode 100644 index 0000000..399ace7 --- /dev/null +++ b/examples/keyword.rs @@ -0,0 +1,21 @@ +/// Demostrates how to fetch and set keywords +/// +/// Usage: cargo run --example keyword ? +/// Example: cargo run --example keyword decoration:rounding (prints value) +/// Example: cargo run --example keyword decoration:rounding 15 (sets value) + +use hyprland::keyword::Keyword; + +fn main() -> hyprland::Result<()> { + let args: Vec<_> = std::env::args().skip(1).collect(); + let keyword = args[0].clone(); + + match args.len() { + 0 => panic!("You need to pass a keyword"), + 1 => println!("{} value is {}", keyword, Keyword::get(&keyword)?.value), + 2 => Keyword::set(keyword, args[1].clone())? + _ => panic!("Takes up to 2 arguments only!") + } + + Ok(()) +} \ No newline at end of file diff --git a/examples/keyword_async.rs b/examples/keyword_async.rs new file mode 100644 index 0000000..af358bc --- /dev/null +++ b/examples/keyword_async.rs @@ -0,0 +1,22 @@ +/// Demostrates how to fetch and set keywords asyncronously +/// +/// Usage: cargo run --example keyword_async +/// Example: cargo run --example keyword_async decoration:rounding (prints value) +/// Example: cargo run --example keyword_async decoration:rounding 15 (sets value) + +use hyprland::keyword::Keyword; + +#[tokio::main(flavor = "current_thread")] +async fn main() -> hyprland::Result<()> { + let args: Vec<_> = std::env::args().skip(1).collect(); + let keyword = args[0].clone(); + + match args.len() { + 0 => panic!("You need to pass a keyword"), + 1 => println!("{} value is {}", keyword, Keyword::get_async(&keyword).await?.value), + 2 => Keyword::set_async(keyword, args[1].clone()).await? + _ => panic!("Takes up to 2 arguments only!") + } + + Ok(()) +} \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index 0b72bf6..7f7b818 100644 --- a/src/config.rs +++ b/src/config.rs @@ -114,7 +114,7 @@ pub mod binds { "{mods},{key},{dispatcher}", mods = binding.mods.join(), key = binding.key, - dispatcher = gen_dispatch_str(binding.dispatcher, false)? + dispatcher = gen_dispatch_str(binding.dispatcher, false)?.data )) } /// Binds a keybinding