### Manual Installation Commands Source: https://github.com/anyrun-org/anyrun/blob/master/README.md Basic bash commands to initiate the manual installation process for Anyrun, assuming dependencies are met. ```bash make sudo make install ``` -------------------------------- ### Build and Install Anyrun Source: https://github.com/anyrun-org/anyrun/blob/master/README.md Clone the repository, build all packages, and install the Anyrun binary. Ensure you navigate into the cloned directory before building. ```bash git clone https://github.com/anyrun-org/anyrun && cd anyrun cargo build --release cargo install --path anyrun/ ``` -------------------------------- ### Configure Anyrun with Home-Manager Source: https://github.com/anyrun-org/anyrun/blob/master/README.md Example of how to enable and configure Anyrun using a Home-Manager module. Includes options for window positioning, appearance, and plugin management. Supports inline CSS and configuration files for plugins. ```nix { config, pkgs, ... }: { programs.anyrun = { enable = true; config = { x = { fraction = 0.5; }; y = { fraction = 0.3; }; width = { fraction = 0.3; }; hideIcons = false; ignoreExclusiveZones = false; layer = "overlay"; hidePluginInfo = false; closeOnClick = false; showResultsImmediately = false; maxEntries = null; plugins = [ "${pkgs.anyrun}/lib/libapplications.so" "${pkgs.anyrun}/lib/libsymbols.so" ]; }; # Inline comments are supported for language injection into # multi-line strings with Treesitter! (Depends on your editor) extraCss = /*css */ '' .some_class { background: red; } ''; extraConfigFiles."some-plugin.ron".text = '' Config( // for any other plugin // this file will be put in ~/.config/anyrun/some-plugin.ron // refer to docs of xdg.configFile for available options ) ''; }; } ``` -------------------------------- ### Use Anyrun Flake with Home-Manager Source: https://github.com/anyrun-org/anyrun/blob/master/README.md Example of how to use the Anyrun flake with Home-Manager, disabling the default module to avoid conflicts and including the upstream module. ```nix { inputs, ... }: { home.username = "user"; home.homeDirectory = "/home/user"; # Let Home be managed by Home Manager. imports = [ ./hardware.nix inputs.home-manager.useModules inputs.anyrun.homeManagerModules.default ]; programs.anyrun = { enable = true; # ... other configurations }; # ... other configurations } ``` -------------------------------- ### AnyRun Configuration File (RON) Source: https://context7.com/anyrun-org/anyrun/llms.txt Example of the main AnyRun configuration file in RON format. Controls window properties, plugin loading, and keybinds. Adjust these settings to customize AnyRun's behavior and appearance. ```ron Config( // Position and size — Absolute(px) or Fraction(0.0–1.0 of screen dimension) x: Fraction(0.5), // horizontally centered y: Absolute(0), // at the top width: Absolute(800), height: Absolute(1), // auto-expands; set 0 to never shrink hide_icons: false, ignore_exclusive_zones: false, // true → overlap Waybar etc. layer: Overlay, // Background | Bottom | Top | Overlay hide_plugin_info: false, close_on_click: false, show_results_immediately: false, max_entries: None, // Some(10) to cap total results // Relative paths resolved from ~/.config/anyrun/plugins/ plugins: [ "libapplications.so", "libsymbols.so", "libshell.so", "libtranslate.so", ], keybinds: [ Keybind(key: "Return", action: Select), Keybind(key: "Escape", action: Close), Keybind(key: "Up", action: Up), Keybind(key: "Down", action: Down), Keybind(key: "Tab", action: Down), Keybind(key: "ISO_Left_Tab", action: Up, shift: true), ], ) ``` -------------------------------- ### Rust Plugin Example for AnyRun Source: https://github.com/anyrun-org/anyrun/blob/master/README.md This Rust code demonstrates the basic structure of an AnyRun plugin. It includes initialization, info, matching, and handling functions. Ensure you have the `anyrun_plugin` and `abi_stable` crates. ```rust use abi_stable::std_types::{RString, RVec, ROption}; use anyrun_plugin::*; #[init] fn init(config_dir: RString) { // Your initialization code. This is run in another thread. // The return type is the data you want to share between functions } #[info] fn info() -> PluginInfo { PluginInfo { name: "Demo".into(), icon: "help-about".into(), // Icon from the icon theme } } #[get_matches] fn get_matches(input: RString) -> RVec { // The logic to get matches from the input text in the `input` argument. // The `data` is a mutable reference to the shared data type later specified. vec![Match { title: "Test match".into(), icon: ROption::RSome("help-about".into()), use_pango: false, description: ROption::RSome("Test match for the plugin API demo".into()), id: ROption::RNone, // The ID can be used for identifying the match later, is not required }].into() } #[handler] fn handler(selection: Match) -> HandleResult { // Handle the selected match and return how anyrun should proceed HandleResult::Close } ``` -------------------------------- ### Configure Niri Focus Plugin Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/niri-focus/README.md Example configuration for the niri-focus plugin using RON format. Adjust `max_entries` to control the maximum number of search results displayed. ```ron // /niri-focus.ron Config( max_entries: 2, ) ``` -------------------------------- ### AnyRun Daemon Mode and D-Bus Control Source: https://context7.com/anyrun-org/anyrun/llms.txt Commands for starting AnyRun in daemon mode and launching it with specific plugins via the command line. Daemon mode allows for faster subsequent launches. ```bash # Start the daemon (run this from your compositor's autostart) anyrun daemon # Show the launcher (from a keybind script); config options can be overridden inline anyrun --plugins libapplications.so --plugins libsymbols.so ``` -------------------------------- ### Anyrun Command-Line Arguments Source: https://github.com/anyrun-org/anyrun/blob/master/README.md Override configuration parameters using command-line arguments. For example, specify plugins to load or the position of the Anyrun interface. ```bash anyrun --config-dir anyrun --plugins libapplications.so --plugins libsymbols.so --position top ``` -------------------------------- ### Configure Anyrun Directories Source: https://github.com/anyrun-org/anyrun/blob/master/README.md Create the necessary configuration directory and the plugins subdirectory. Copy the built plugins and the default configuration file to their respective locations. ```bash mkdir -p ~/.config/anyrun/plugins cp target/release/*.so ~/.config/anyrun/plugins cp examples/config.ron ~/.config/anyrun/config.ron ``` -------------------------------- ### `#[init]` Macro Source: https://context7.com/anyrun-org/anyrun/llms.txt Marks the plugin's initialization function. This function runs in a spawned thread, receives the Anyrun configuration directory path, and returns a shared plugin state. ```APIDOC ## `#[init]` Macro Marks the initialisation function for a plugin. ### Signature `fn init(config_dir: RString) -> T` where `T` is the shared plugin state. ### Parameters - **config_dir** (RString) - The path to the Anyrun configuration directory (e.g., `~/.config/anyrun`). ### Return Value - `T` - The shared plugin state, which can be accessed by `get_matches` and `handler` functions. This state can be mutable. ### Behavior - Runs in a spawned thread. - Its return value becomes the shared plugin state. - Panics are caught automatically by the host. ``` -------------------------------- ### Configure Nix-run Plugin Source: https://context7.com/anyrun-org/anyrun/llms.txt Sets up fuzzy searching for nixpkgs and launching packages with `nix run`. Caches the package list for 7 days. Allows configuration for unfree packages. ```ron // ~/.config/anyrun/nix-run.ron Config( prefix: ":nr ", // type ":nr firefox" → nix run nixpkgs#firefox channel: "nixos-unstable", max_entries: 3, allow_unfree: false, // true → also show unfree packages ) ``` -------------------------------- ### Plugin Initialization with `#[init]` Source: https://context7.com/anyrun-org/anyrun/llms.txt The `#[init]` macro marks the plugin's initialization function, which receives the config directory path and returns shared plugin state. It can load configuration from files, providing custom settings for `get_matches` and `handler`. Ensure `serde::Deserialize` is implemented for the config struct. ```rust use abi_stable::std_types::RString; use anyrun_plugin::*; use serde::Deserialize; use std::fs; #[derive(Deserialize)] struct Config { prefix: String, } impl Default for Config { fn default() -> Self { Config { prefix: ":sh".into() } } } #[init] fn init(config_dir: RString) -> Config { // config_dir is typically ~/.config/anyrun match fs::read_to_string(format!("{}/myplugin.ron", config_dir)) { Ok(content) => ron::from_str(&content).unwrap_or_default(), Err(_) => Config::default(), } // returned Config becomes the shared state passed to get_matches / handler } ``` -------------------------------- ### Configure Nix-run Plugin Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/nix-run/README.md Configure the nix-run plugin by specifying settings like the command prefix, whether to allow unfree packages, the nixpkgs channel to use, and the maximum number of entries to display. ```ron // /nix-run.ron Config( prefix: ":nr ", // Whether or not to allow unfree packages allow_unfree: false, // Nixpkgs channel to get the package list from channel: "nixpkgs-unstable", max_entries: 3, ) ``` -------------------------------- ### Configure Dictionary Plugin Prefix and Max Entries Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/dictionary/README.md This RON configuration snippet shows how to set the command prefix and the maximum number of definition entries to display. Ensure this file is placed in your Anyrun config directory. ```ron // /dictionary.ron Config( prefix: ":def", max_entries: 5, ) ``` -------------------------------- ### Minimal AnyRun Plugin Skeleton in Rust Source: https://context7.com/anyrun-org/anyrun/llms.txt A complete, minimal AnyRun plugin demonstrating the four required functions: `init`, `info`, `get_matches`, and `handler`. This serves as a basic template for creating new plugins. ```rust // Cargo.toml: // [lib] // crate-type = ["cdylib"] // [dependencies] // anyrun-plugin = { git = "https://github.com/anyrun-org/anyrun" } // abi_stable = "0.11.1" use abi_stable::std_types::{ROption, RString, RVec}; use anyrun_plugin::*; #[init] fn init(_config_dir: RString) { // No persistent state needed; return type is () → state is () } #[info] fn info() -> PluginInfo { PluginInfo { name: "Demo".into(), icon: "help-about".into(), } } #[get_matches] fn get_matches(input: RString) -> RVec { if input.is_empty() { return RVec::new(); } vec![Match { title: format!("Echo: {}", input).into(), icon: ROption::RSome("help-about".into()), use_pango: false, description: ROption::RSome("Demo plugin result".into()), id: ROption::RNone, }] .into() } #[handler] fn handler(selection: Match) -> HandleResult { // Copy the displayed title to the clipboard HandleResult::Copy(selection.title.into_bytes()) } ``` -------------------------------- ### Default Power Actions Configuration Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/actions/README.md This configuration shows the RON settings equivalent to the default built-in power actions, demonstrating how to set up actions for locking, logging out, powering off, rebooting, suspending, and hibernating. ```ron Config( enable_power_actions: false, custom_actions: [ ( title: "Lock", command: "loginctl lock-session", description: "Lock the session screen", icon: "system-lock-screen", confirm: false, ), ( title: "Log out", command: "loginctl terminate-session $XDG_SESSION_ID", description: "Terminate the session", icon: "system-log-out", confirm: true, ), ( title: "Power off", command: "systemctl poweroff || poweroff", description: "Shut down the system", icon: "system-shutdown", confirm: true, ), ( title: "Reboot", command: "systemctl reboot || reboot", description: "Restart the system", icon: "system-reboot", confirm: true, ), ( title: "Suspend", command: "systemctl suspend || pm-suspend", description: "Suspend the system to RAM", icon: "system-suspend", confirm: false, ), ( title: "Hibernate", command: "systemctl hibernate || pm-hibernate", description: "Suspend the system to disk", icon: "system-suspend-hibernate", confirm: false, ), ], ) ``` -------------------------------- ### Stdin Plugin Usage and Configuration Source: https://context7.com/anyrun-org/anyrun/llms.txt Use the Stdin plugin to turn Anyrun into a fuzzy dmenu replacement. It reads lines from stdin at startup and writes the selected line to stdout. ```bash # Usage as dmenu replacement printf "option1\noption2\noption3" | anyrun --plugins libstdin.so # selected line is written to stdout when the launcher closes ``` ```ron // ~/.config/anyrun/stdin.ron Config( max_entries: 5, allow_invalid: false, // true → allow selecting text not in the list preserve_order: false, // true → do not reorder by fuzzy score ) ``` -------------------------------- ### Configure Nix Binary Cache for Anyrun Source: https://github.com/anyrun-org/anyrun/blob/master/README.md Configuration for Nix to use the Anyrun binary cache, enabling faster builds by downloading pre-compiled packages. Includes settings for substituters and trusted public keys. ```nix nix.settings = { builders-use-substitutes = true; extra-substituters = [ "https://anyrun.cachix.org" ]; extra-trusted-public-keys = [ "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" ]; }; ``` -------------------------------- ### Basic Anyrun Commands Source: https://context7.com/anyrun-org/anyrun/llms.txt These commands control the Anyrun application's visibility and daemon state. The Nvidia workaround is specific to certain hardware configurations. ```bash anyrun close ``` ```bash anyrun quit ``` ```bash anyrun --config-dir /path/to/custom/config ``` ```bash GSK_RENDERER=ngl anyrun ``` -------------------------------- ### Anyrun Plugin Development: Cargo.toml Source: https://github.com/anyrun-org/anyrun/blob/master/README.md Configure your plugin's Cargo.toml file to build a dynamic library loadable by Anyrun. Include necessary dependencies like `anyrun-plugin` and `abi_stable`. ```toml [package] # omitted [lib] crate-type = ["cdylib"] # Required to build a dynamic library that can be loaded by anyrun [dependencies] anyrun-plugin = { git = "https://github.com/anyrun-org/anyrun" } abi_stable = "0.11.1" ``` -------------------------------- ### NixOS/Home-Manager Integration with Anyrun Source: https://context7.com/anyrun-org/anyrun/llms.txt Integrates Anyrun into Home-Manager using a Nix flake. Enables Anyrun, configures its appearance, and specifies plugins and extra CSS/config files. ```nix # flake.nix — using anyrun flake with home-manager module { inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; home-manager.url = "github:nix-community/home-manager"; anyrun.url = "github:anyrun-org/anyrun"; }; outputs = { self, nixpkgs, home-manager, anyrun, ... }: { homeConfigurations.user = home-manager.lib.homeManagerConfiguration { modules = [ ({ modulesPath, ... }: { disabledModules = [ "${modulesPath}/programs/anyrun.nix" ]; }) anyrun.homeManagerModules.default { programs.anyrun = { enable = true; config = { x = { fraction = 0.5; }; y = { fraction = 0.3; }; width = { fraction = 0.3; }; hideIcons = false; layer = "overlay"; maxEntries = null; plugins = [ "${pkgs.anyrun}/lib/libapplications.so" "${pkgs.anyrun}/lib/libshell.so" "${pkgs.anyrun}/lib/libwebsearch.so" ]; }; extraCss = /*css*/ '' box.main { border-radius: 12px; background: #1e1e2e; } label.match { color: #cdd6f4; } ''; extraConfigFiles."websearch.ron".text = '' Config(prefix: "?", engines: [DuckDuckGo]) ''; }; } ]; }; }; }; } ``` -------------------------------- ### Applications Plugin Configuration Source: https://context7.com/anyrun-org/anyrun/llms.txt Configure the Applications plugin to fuzzy-search `.desktop` entries. Supports desktop actions, terminal overrides, and preprocessing exec commands. ```ron // ~/.config/anyrun/applications.ron Config( desktop_actions: true, // show .desktop Actions as separate entries max_entries: 5, hide_description: false, terminal: Some(Terminal( command: "foot", args: "-e \"{ }\"", // {} is replaced with the exec string )), preprocess_exec_script: None, // Some("/path/to/script.sh") for exec rewriting ) ``` -------------------------------- ### Rink Plugin Configuration Source: https://context7.com/anyrun-org/anyrun/llms.txt Configure the Rink plugin for unit conversions and calculations. It fetches live currency rates and copies results to the clipboard. ```ron // ~/.config/anyrun/rink.ron Config( prefix: "", // empty = always active; set e.g. "=" to require prefix ) // Usage examples (in anyrun input box): // "100 USD to EUR" → "85.23 EUR (live rate)" // "60 mph to km/h" → "96.56 km/h" // "2^10" → "1024" ``` -------------------------------- ### Configure Randr Plugin Source: https://context7.com/anyrun-org/anyrun/llms.txt Provides quick changes to monitor resolution and rotation. Currently Hyprland-only. ```ron randr.ron ``` -------------------------------- ### Configure Applications Plugin Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/applications/README.md Customize the behavior of the applications plugin by setting options like enabling desktop actions, limiting the number of entries, hiding descriptions, defining a preprocessing script for commands, and specifying a terminal emulator with its arguments. ```ron Config( // Also show the Desktop Actions defined in the desktop files, e.g. "New Window" from LibreWolf desktop_actions: true, max_entries: 5, hide_description: true, // A command to preprocess the command from the desktop file. The commands should take arguments in this order: // command_name preprocess_exec_script: Some("/home/user/.local/share/anyrun/preprocess_application_command.sh") // The terminal used for running terminal based desktop entries, if left as `None` a static list of terminals is used // to determine what terminal to use. terminal: Some(Terminal( // The main terminal command command: "alacritty", // What arguments should be passed to the terminal process to run the command correctly // {} is replaced with the command in the desktop entry args: "-e {}", )), ) ``` -------------------------------- ### Plugin Metadata with `#[info]` Source: https://context7.com/anyrun-org/anyrun/llms.txt The `#[info]` macro designates the function that provides static metadata for the plugin, including its display name and icon. This function takes no arguments and must return a `PluginInfo` struct. This metadata is used by the host to label the plugin in its UI. ```rust use anyrun_plugin::*; #[info] fn info() -> PluginInfo { PluginInfo { name: "Shell".into(), // label shown in the info panel icon: "utilities-terminal".into(), // XDG icon theme name } } ``` -------------------------------- ### Configure Kidex Plugin Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/kidex/README.md Configure the maximum number of entries for the Kidex plugin. Place this file in your Anyrun config directory. ```ron // /kidex.ron Config( max_entries: 3, ) ``` -------------------------------- ### Shell Plugin Configuration Source: https://context7.com/anyrun-org/anyrun/llms.txt Configure the Shell plugin to run arbitrary shell commands. Commands are executed when the input begins with the specified prefix. ```ron // ~/.config/anyrun/shell.ron Config( prefix: ":sh", // type ":sh ls -la" → runs ls -la shell: Some("bash"), // override $SHELL; None = use $SHELL env var ) ``` -------------------------------- ### Configure niri-focus Plugin Source: https://context7.com/anyrun-org/anyrun/llms.txt Enables fuzzy searching of open windows on the niri compositor and focuses the selected one via the niri IPC socket. Configures the maximum number of entries displayed. ```ron // ~/.config/anyrun/niri-focus.ron Config( max_entries: 2, ) // Matches against both window title and app_id ``` -------------------------------- ### GTK4 CSS Styling for Anyrun Source: https://context7.com/anyrun-org/anyrun/llms.txt Customize the appearance of Anyrun by creating a `style.css` file in `~/.config/anyrun/`. Use `GTK_DEBUG=interactive anyrun` to edit styles live. ```css /* ~/.config/anyrun/style.css */ /* Main container */ box.main { padding: 5px; border-radius: 10px; border: 2px solid #5599d2; background-color: #161616; box-shadow: 0 0 5px black; } /* Input entry */ text { min-height: 30px; color: #eeeeee; } /* Each result row */ .match { background: transparent; } .match:selected { border-left: 4px solid #5599d2; animation: fade 0.1s linear; } /* Result title and description labels */ label.match { color: #eeeeee; } label.match.description { font-size: 10px; color: #cccccc; } /* Plugin info panel (icon + name) */ box.plugin.info { min-width: 200px; } label.plugin.info { font-size: 14px; color: #eeeeee; } ``` -------------------------------- ### Configure Translate Plugin Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/translate/README.md Set the prefix, language delimiter, and maximum entries for the translate plugin. Ensure this configuration file is placed in the Anyrun config directory. ```ron // /translate.ron Config( prefix: ":", language_delimiter: ">", max_entries: 3, ) ``` -------------------------------- ### Configure Actions Plugin Source: https://context7.com/anyrun-org/anyrun/llms.txt Defines custom actions for power management and user-defined commands. Supports a confirmation step for destructive actions. ```ron // ~/.config/anyrun/actions.ron Config( enable_power_actions: true, custom_actions: [ Action( title: "Reload Waybar", command: "pkill -SIGUSR2 waybar", description: "Reload the Waybar config", icon: "view-refresh", confirm: false, ), Action( title: "Screenshot", command: "grim ~/Pictures/screenshot.png", icon: "camera-photo", confirm: false, ), ], ) ``` -------------------------------- ### Configure Stdin Plugin Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/stdin/README.md Customize the behavior of the Stdin plugin using a RON configuration. Options include allowing arbitrary text input, setting the maximum number of entries to display, and preserving the original order of entries. ```ron Config( // Whether to allow the user to input any arbitrary text besides the options provided allow_invalid: false, // How many entries should be displayed at max max_entries: 5, // Whether to preserve the original order of entries instead of sorting by fuzzy match score. Matches are still filtered out if there is no similarity to input. preserve_order: false, ) ``` -------------------------------- ### `#[info]` Macro Source: https://context7.com/anyrun-org/anyrun/llms.txt Marks the function that returns static metadata for the plugin, including its name and icon, which is displayed in the plugin information panel. ```APIDOC ## `#[info]` Macro Marks the function that returns static plugin metadata. ### Signature `fn info() -> PluginInfo` ### Parameters None. ### Return Value - `PluginInfo` - An object containing the plugin's name and icon. - **name** (RString) - The label shown in the info panel. - **icon** (RString) - The XDG icon theme name for the plugin. ``` -------------------------------- ### Randr Plugin Configuration Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/randr/README.md Configure the Randr plugin's prefix and maximum displayed entries in the Anyrun configuration directory. ```ron ///randr.ron Config( prefix: ":dp", max_entries: 5, ) ``` -------------------------------- ### Configure Custom Actions in RON Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/actions/README.md Define custom actions, including their title, command, description, icon, and confirmation requirement, within the actions.ron configuration file. ```ron Config( // Set to false to disable built-in power actions (default: true). enable_power_actions: true, // Add your own custom actions here. custom_actions: [ ( // Required. title: "Open Browser", // Required. The command is passed through shell. command: "xdg-open https://example.com", // Optional. description: "Launch the default web browser", // Optional. icon: "web-browser", // Optional (default: false). confirm: false, ), ], ) ``` -------------------------------- ### Dictionary Plugin Configuration Source: https://context7.com/anyrun-org/anyrun/llms.txt Configure the Dictionary plugin to look up English word definitions using the Free Dictionary API. It copies the selected definition to the clipboard. ```ron // ~/.config/anyrun/dictionary.ron Config( prefix: ":def", // type ":def ephemeral" max_entries: 3, ) ``` -------------------------------- ### Configure Shell Plugin Prefix and Shell Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/shell/README.md Customize the command prefix and override the default shell interpreter for the Shell plugin. This configuration is typically placed in the Anyrun config directory. ```ron // /shell.ron Config( prefix: ":sh", // Override the shell used to launch the command shell: None, ) ``` -------------------------------- ### Symbols Plugin Configuration Source: https://github.com/anyrun-org/anyrun/blob/master/plugins/symbols/README.md Configure the symbols plugin by specifying a search prefix, custom symbols, and the maximum number of entries. The configuration file should be located at /symbols.ron. ```ron Config( // The prefix that the search needs to begin with to yield symbol results prefix: "", // Custom user defined symbols to be included along the unicode symbols symbols: { // "name": "text to be copied" "shrug": "¯\\_(ツ)_/¯", }, max_entries: 3, ) ``` -------------------------------- ### Anyrun Plugin Core Types Source: https://context7.com/anyrun-org/anyrun/llms.txt Defines the core data structures used by Anyrun plugins: `Match` for search results, `PluginInfo` for plugin metadata, and `HandleResult` for actions after selection. Ensure correct types from `abi_stable` and `anyrun_plugin` are used. ```rust use abi_stable::std_types::{ROption, RString, RVec}; use anyrun_plugin::*; // Match — a result row let m = Match { title: "Firefox".into(), // displayed title (required) icon: ROption::RSome("firefox".into()), // XDG icon name or RNone use_pango: false, // enable Pango markup in title description: ROption::RSome("Web browser".into()),// subtitle or RNone id: ROption::RSome(42u64), // opaque id passed back to handler }; // PluginInfo — shown in the plugin info panel let info = PluginInfo { name: "MyPlugin".into(), icon: "application-x-executable".into(), }; // HandleResult — returned from the handler function HandleResult::Close // close the launcher HandleResult::Copy(b"text to copy".to_vec()) // copy bytes → clipboard HandleResult::Stdout(b"selected\n".to_vec()) // write to stdout (dmenu mode) HandleResult::Refresh(true) // keep launcher open, clear input = true ``` -------------------------------- ### `#[get_matches]` Macro Source: https://context7.com/anyrun-org/anyrun/llms.txt Marks the function responsible for generating a list of `Match` results based on the current user input string and the plugin's shared state. ```APIDOC ## `#[get_matches]` Macro Marks the function that produces results based on user input. ### Signature `fn get_matches(input: RString, state: &T) -> RVec` where `T` is the shared state from `init`. ### Parameters - **input** (RString) - The current text input from the user. - **state** (&T) - A reference to the shared plugin state initialized by the `#[init]` function. ### Return Value - `RVec` - A vector of `Match` objects representing the results. ### Behavior - Converts the input string into a list of `Match` results. - Panics are caught automatically, resulting in an empty list being returned. ``` -------------------------------- ### Core Plugin Types Source: https://context7.com/anyrun-org/anyrun/llms.txt Defines the fundamental data structures used by Anyrun plugins: `Match` for result rows, `PluginInfo` for plugin metadata, and `HandleResult` for actions after selection. ```APIDOC ## Core Plugin Types ### `Match` Represents a single result row returned by a plugin. - **title** (string) - Required - The displayed title of the result. - **icon** (ROption) - Optional - The XDG icon name or RNone. - **use_pango** (bool) - Enable Pango markup in the title. - **description** (ROption) - Optional - A subtitle for the result or RNone. - **id** (ROption) - Optional - An opaque ID passed back to the handler. ### `PluginInfo` Provides the plugin's display name and icon. - **name** (RString) - Required - The plugin's display name. - **icon** (RString) - Required - The XDG icon name for the plugin. ### `HandleResult` Determines the action Anyrun should take after a user selects a result. - **Close** - Close the launcher window. - **Copy(Vec)** - Copy the provided bytes to the clipboard. - **Stdout(Vec)** - Write the provided bytes to stdout (used in dmenu mode). - **Refresh(bool)** - Keep the launcher open and optionally clear the input field. ``` -------------------------------- ### Rust ConfigArgs Macro for CLI Overrides Source: https://context7.com/anyrun-org/anyrun/llms.txt Derives a struct for command-line argument parsing and merging them into a configuration. Use `#[config_args(skip)]` to exclude fields from CLI arguments. This simplifies applying runtime overrides to loaded configurations. ```rust use anyrun_macros::ConfigArgs; use serde::Deserialize; #[derive(Deserialize, ConfigArgs)] #[config_args(pub)] // pub makes the Args struct and merge_opt public struct Config { pub width: u32, pub hide_icons: bool, #[config_args(skip)] // not exposed as a CLI argument pub keybinds: Vec, } // Generated: pub struct ConfigArgs { width: Option, hide_icons: Option } // Generated: impl Config { pub fn merge_opt(&mut self, opt: ConfigArgs) { … } } // Usage at runtime: let mut config = Config { width: 800, hide_icons: false, keybinds: vec![] }; let cli_args = ConfigArgs { width: Some(600), hide_icons: None }; config.merge_opt(cli_args); // config.width is now 600; hide_icons and keybinds unchanged ``` -------------------------------- ### Generating Matches with `#[get_matches]` Source: https://context7.com/anyrun-org/anyrun/llms.txt The `#[get_matches]` macro marks the function responsible for converting user input into a list of `Match` results. It receives the input string and optionally the shared state from `init`. Panics within this function are caught, resulting in an empty match list. ```rust use abi_stable::std_types::{ROption, RString, RVec}; use anyrun_plugin::*; #[get_matches] fn get_matches(input: RString, config: &Config) -> RVec { // Only activate when input starts with the configured prefix if !input.starts_with(&config.prefix) { return RVec::new(); } let command = input.trim_start_matches(&config.prefix).trim(); if command.is_empty() { return RVec::new(); } vec![Match { title: command.into(), description: ROption::RSome("Run shell command".into()), use_pango: false, icon: ROption::RNone, id: ROption::RNone, }] .into() } ``` -------------------------------- ### Websearch Plugin Configuration Source: https://context7.com/anyrun-org/anyrun/llms.txt Configure the Websearch plugin to open web searches in the default browser. Supports multiple search engines, including custom ones. ```ron // ~/.config/anyrun/websearch.ron Config( prefix: "?", // type "? rust async" → search entries for each engine engines: [ Google, DuckDuckGo, Custom(name: "Sourcehut", url: "search.sourcehut.org/?q={}"), ], ) ```