barkust 0.2.0

A Rust client library and CLI for the Bark push notification service
Documentation

barkust

A Rust client library and CLI for the Bark push notification service.

Features

  • Async client built on reqwest
  • Type-safe notification builder
  • Batch push to multiple devices
  • Image, subtitle, markdown, critical level support
  • Update or delete notifications by id
  • Custom Bark server support
  • Thin command-line wrapper
  • MIT licensed

Installation

Library

Add to your Cargo.toml:

[dependencies]
barkust = "0.1"
tokio = { version = "1", features = ["full"] }

CLI

cargo install barkust

Usage

Library

use barkust::{BarkClient, Level, Notification};

#[tokio::main]
async fn main() -> Result<(), barkust::Error> {
    let client = BarkClient::new(Some("your-device-key".into()))?;

    // Simple push
    client.send_simple("Hello", "World").await?;

    // Fully customized push
    let notification = Notification::builder()
        .title("Custom")
        .body("Built with the builder API")
        .sound("minuet")
        .group("demo")
        .level(Level::TimeSensitive)
        .archive(true)
        .build();

    client.send(&notification).await?;

    // Batch push
    let batch = Notification::builder()
        .title("Batch")
        .body("Hello everyone")
        .build();
    client
        .send_batch(&batch, vec!["key1".into(), "key2".into()])
        .await?;

    Ok(())
}

CLI

Send a simple notification using the BARK_KEY environment variable:

export BARK_KEY="your-device-key"
barkust --title "Hello" --body "World"

With image and subtitle:

barkust --title "Hello" --subtitle "Subtitle" --body "World" \
    --image "https://example.com/image.png"

Critical alert that ignores the mute switch:

barkust --title "Alert" --body "Critical!" --critical --volume 10

Batch push to multiple devices:

barkust --device-keys key1,key2 --title "Hello" --body "World"

Update or delete an existing notification by id:

barkust --id "msg-123" --title "Updated" --body "New content"
barkust --id "msg-123" --delete

Use a self-hosted Bark server:

barkust --url https://bark.example.com --title "Hello" --body "World"

See barkust --help for all options.

License

Licensed under the MIT license.