any-dialog 0.1.0

Simple dialogs via kdialog, zenity, or osascript. Zero dependencies.
Documentation
  • Coverage
  • 68.42%
    13 out of 19 items documented0 out of 7 items with examples
  • Size
  • Source code size: 22.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 206.4 kB 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
  • Documentation
  • mudhairless/any-dialog
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mudhairless

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)

A macOS backend via osascript is planned. Windows is not supported yet. Support may be added later if a suitable approach turns up, which is why the crate name does not name an OS or a mechanism.

The expanded feature set in ROADMAP.md is version 1.0, and 1.0 will be the first crates.io publish. Until it lands, this README describes the dialogs the code has today.

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

What it does

Three dialogs, each returning Ok(None) when the user cancels:

  • prompt_text: ask for a line of text, with an optional initial value
  • prompt_choice: ask the user to pick one item from a list
  • show_error: show a message with a single dismiss button

Usage

use any_dialog::Dialogs;

fn main() -> Result<(), any_dialog::Error> {
    let dialogs = Dialogs::new();
    if !dialogs.available() {
        eprintln!("install kdialog or zenity to enable dialogs");
        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.