Crate bitbar[−][src]
Expand description
This is bitbar
, a library crate which includes helpers for writing BitBar or SwiftBar plugins in Rust.
There are two main entry points:
- It’s recommended to use the
main
attribute and write amain
function that returns aMenu
, along with optionalcommand
functions and an optionalfallback_command
function. - For additional control over your plugin’s behavior, you can directly
Display
aMenu
.
Features
The following feature is enabled by default:
The following features can be enabled via Cargo:
base64
: Adds a depencency to thebase64
crate and implements conversion methods from PNG files that aren’t already base64-encoded toImage
s.css-colors
: Adds a dependency to thecss-colors
crate and implementsIntoColor
for its color typesRGB
,RGBA
,HSL
, andHSLA
.image
: Adds a depencency to theimage
crate. If thebase64
feature is also enabled, implementsTryFrom<DynamicImage>
forImage
.serenity
: Adds a dependency to theserenity
crate and implementsIntoColor
for itsColour
type.tokio02
: Adds a dependency to the outdated version 0.2 of thetokio
crate, allowing you to useasync fn
s with themain
attribute while using that version’s runtime. Thetokio
feature should be disabled when using this feature.tokio03
: Adds a dependency to the outdated version 0.3 of thetokio
crate, allowing you to useasync fn
s with themain
attribute while using that version’s runtime. Thetokio
feature should be disabled when using this feature.url1
: Adds a dependency to the outdated version 1 of theurl
crate and implementsIntoUrl
for itsUrl
type.
Example
use bitbar::{Menu, MenuItem}; #[bitbar::main] fn main() -> Menu { Menu(vec![ MenuItem::new("Title"), MenuItem::Sep, MenuItem::new("Menu Item"), ]) }
Or:
use bitbar::{Menu, MenuItem}; fn main() { print!("{}", Menu(vec![ MenuItem::new("Title"), MenuItem::Sep, MenuItem::new("Menu Item"), ])); }
Re-exports
pub use crate::flavor::Flavor;
Modules
Structs
Used by ContentItem::command
.
A menu item that’s not a separator.
Used by ContentItem::image
and ContentItem::template_image
.
A BitBar menu.
Enums
A menu item’s alternate mode or submenu.
A menu item can either be a separator or a content item.
BitBar only supports up to five parameters for bash=
commands (see https://github.com/matryer/bitbar/issues/490).
Traits
Members of this trait can be returned from a subcommand function annotated with command
or fallback_command
.
Used by ContentItem::color
.
Used by ContentItem::href
.
Members of this trait can be returned from a main function annotated with main
.
Attribute Macros
Registers a subcommand that you can run from a menu item’s command
.
Registers a function that is called when no other bitbar::command
matches.
Annotate your main
function with this.