diff --git a/.gitignore b/.gitignore index ea8c4bf..185ca35 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target + +.idea diff --git a/Cargo.lock b/Cargo.lock index a786524..aa7cd5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "abi_stable" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467388fe07f5a809f4df42226142cadd5a7706810b76a0896fd68d156b1ea886" +checksum = "69d6512d3eb05ffe5004c59c206de7f99c34951504056ce23fc953842f12c445" dependencies = [ "abi_stable_derive", "abi_stable_shared", @@ -149,8 +149,8 @@ name = "anyrun" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-interface", - "anyrun-macros", + "anyrun-interface 0.1.0", + "anyrun-macros 0.1.0", "clap", "gtk", "gtk-layer-shell", @@ -167,9 +167,26 @@ dependencies = [ "abi_stable", ] +[[package]] +name = "anyrun-interface" +version = "0.1.0" +source = "git+https://github.com/Kirottu/anyrun#e14da6c37337ffa3ee1bc66965d58ef64c1590e5" +dependencies = [ + "abi_stable", +] + +[[package]] +name = "anyrun-macros" +version = "0.1.0" +dependencies = [ + "quote", + "syn 2.0.29", +] + [[package]] name = "anyrun-macros" version = "0.1.0" +source = "git+https://github.com/Kirottu/anyrun#e14da6c37337ffa3ee1bc66965d58ef64c1590e5" dependencies = [ "quote", "syn 2.0.29", @@ -180,8 +197,18 @@ name = "anyrun-plugin" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-interface", - "anyrun-macros", + "anyrun-interface 0.1.0", + "anyrun-macros 0.1.0", +] + +[[package]] +name = "anyrun-plugin" +version = "0.1.0" +source = "git+https://github.com/Kirottu/anyrun#e14da6c37337ffa3ee1bc66965d58ef64c1590e5" +dependencies = [ + "abi_stable", + "anyrun-interface 0.1.0 (git+https://github.com/Kirottu/anyrun)", + "anyrun-macros 0.1.0 (git+https://github.com/Kirottu/anyrun)", ] [[package]] @@ -189,7 +216,7 @@ name = "applications" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "fuzzy-matcher", "ron", "serde", @@ -515,7 +542,7 @@ name = "dictionary" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "reqwest", "ron", "serde", @@ -1159,6 +1186,14 @@ dependencies = [ "hashbrown 0.14.0", ] +[[package]] +name = "input" +version = "0.1.0" +dependencies = [ + "abi_stable", + "anyrun-plugin 0.1.0 (git+https://github.com/Kirottu/anyrun)", +] + [[package]] name = "ipnet" version = "2.8.0" @@ -1196,7 +1231,7 @@ name = "kidex" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "fuzzy-matcher", "kidex-common", "open", @@ -1633,7 +1668,7 @@ name = "randr" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "fuzzy-matcher", "hyprland", "ron", @@ -1746,7 +1781,7 @@ name = "rink" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "reqwest", "rink-core", ] @@ -1939,7 +1974,7 @@ name = "shell" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "ron", "serde", ] @@ -2005,7 +2040,7 @@ name = "stdin" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "fuzzy-matcher", "ron", "serde", @@ -2050,7 +2085,7 @@ name = "symbols" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "fuzzy-matcher", "ron", "serde", @@ -2285,7 +2320,7 @@ name = "translate" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "futures", "fuzzy-matcher", "reqwest", @@ -2578,7 +2613,7 @@ name = "websearch" version = "0.1.0" dependencies = [ "abi_stable", - "anyrun-plugin", + "anyrun-plugin 0.1.0", "ron", "serde", "strum", diff --git a/Cargo.toml b/Cargo.toml index a197e03..2fb094b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,4 +14,5 @@ members = [ "plugins/stdin", "plugins/dictionary", "plugins/websearch", + "plugins/input", ] diff --git a/README.md b/README.md index 49d236b..197228b 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ The flake provides multiple packages: - symbols - the symbols plugin - translate - the translate plugin - websearch - the websearch plugin +- input - the input field plugin #### home-manager module diff --git a/plugins/input/Cargo.toml b/plugins/input/Cargo.toml new file mode 100644 index 0000000..778d5e6 --- /dev/null +++ b/plugins/input/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "input" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +anyrun-plugin = { git = "https://github.com/Kirottu/anyrun" } +abi_stable = "0.11.3" diff --git a/plugins/input/README.md b/plugins/input/README.md new file mode 100644 index 0000000..8638402 --- /dev/null +++ b/plugins/input/README.md @@ -0,0 +1,7 @@ +# Input +A simple plugin to make anyrun act like an input field, or in other words, it will return what you typed. + +## Note +It's important to have this plugin loaded last, because otherwise, it will take priority over other ones, which makes it the permanent first option. +It's probably most useful as the only plugin loaded anyway. +I also recommend using `--hide-plugin-info true`. \ No newline at end of file diff --git a/plugins/input/src/lib.rs b/plugins/input/src/lib.rs new file mode 100644 index 0000000..d2e0f95 --- /dev/null +++ b/plugins/input/src/lib.rs @@ -0,0 +1,30 @@ +use abi_stable::std_types::{ROption, RString, RVec}; +use anyrun_plugin::{get_matches, handler, HandleResult, info, init, Match, PluginInfo}; + +#[info] +fn info() -> PluginInfo { + PluginInfo { + name: "Input".into(), + icon: "input-keyboard".into(), + } +} + +#[init] +fn init(_config_dir: RString) {} + +#[get_matches] +fn get_matches(input: RString) -> RVec { + vec![Match { + title: input, + description: ROption::RNone, + use_pango: false, + icon: ROption::RNone, + id: ROption::RNone, + }] + .into() +} + +#[handler] +fn handler(selection: Match) -> HandleResult { + HandleResult::Stdout(selection.title.into_bytes()) +}