any-dialog 1.0.0

Simple dialogs via kdialog, zenity, osascript, or PowerShell. Zero dependencies.
Documentation
  • Coverage
  • 72.22%
    26 out of 36 items documented1 out of 19 items with examples
  • Size
  • Source code size: 155.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.1 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • mudhairless/any-dialog
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mudhairless

CI

any-dialog

Simple desktop dialogs via whatever dialog tool the system already has.

any-dialog does not link a GUI toolkit. It drives an external helper program instead, so it has zero dependencies and uses only the Rust standard library.

Backends

Probed in order:

  1. kdialog (Linux, common on KDE installs)
  2. zenity (Linux, common on GNOME installs)
  3. osascript (macOS, bundled with the OS)
  4. powershell (Windows, bundled with the OS)

On macOS and Windows the order flips: the OS's own bundled helper (osascript or powershell) goes first there, since it is part of the OS, with the other tools as fallbacks.

Version 1.0 is the first full release. Version 0.1.0 was published early to reserve the crate name.

If no helper is installed, calls return Error::NoBackend.

API documentation lives on docs.rs, with runnable examples in this repository's examples/ directory. The minimum supported Rust version is 1.85.

What it does

The prompt dialogs return Ok(None) when the user cancels:

  • prompt_text: ask for a line of text, with an optional initial value
  • prompt_password: ask for a password or other secret, masked while typed
  • prompt_choice: ask the user to pick one item from a list
  • prompt_choices: ask the user to pick any number of items from a list
  • prompt_color: ask the user to pick a color, returned as #rrggbb
  • prompt_open_file / prompt_open_files: pick one or several files to open, with optional named extension filters
  • prompt_save_file: pick a file to save to, with an optional suggested path
  • prompt_folder: pick a folder
  • confirm: ask a yes/no question, returning a bool
  • show_info, show_warning, show_error: show a message with a single dismiss button, at three levels of seriousness

Usage

use any_dialog::Dialogs;

fn main() -> Result<(), any_dialog::Error> {
    let dialogs = Dialogs::new();
    if !dialogs.available() {
        eprintln!("no dialog backend available on this system");
        return Ok(());
    }

    if let Some(name) = dialogs.prompt_text("Example", "Your name:", None)? {
        println!("hello, {name}");
    }

    Ok(())
}

Every call blocks until the user answers. Run calls on a worker thread, not on a UI or event-loop thread.

License

MIT. See LICENSE.