pub struct SwiftBar { /* private fields */ }
Expand description
A type-safe handle for SwiftBar-specific features.
Some SwiftBar-specific features are currently unsupported:
- Script metadata is unsupported since
cargo
does not support adding metadata to binaries it produces. You will have to add any metadata viaxattr
.
Implementations§
source§impl SwiftBar
impl SwiftBar
sourcepub fn check() -> Option<Self>
pub fn check() -> Option<Self>
Checks whether the plugins is running in SwiftBar by checking environment variables. If it does, returns a handle allowing use of SwiftBar-specific features.
sourcepub fn assume() -> Self
Available on crate feature assume-flavor
only.
pub fn assume() -> Self
assume-flavor
only.Returns a handle allowing use of SwiftBar-specific features without checking whether the plugin is actually running inside SwiftBar. If the plugin is actually running in a different implementation or an outdated version of SwiftBar, this may lead to incorrect behavior.
sourcepub fn plugin_name(&self) -> Result<String, PluginNameError>
pub fn plugin_name(&self) -> Result<String, PluginNameError>
The name of the plugin, including refresh time and file extension, as used in swiftbar:
URLs.
sourcepub fn running_version(&self) -> Result<Version, VersionCheckError>
pub fn running_version(&self) -> Result<Version, VersionCheckError>
Returns the SwiftBar version on which the plugin is running by checking environment variables.
sourcepub fn command(&self, cmd: impl IntoParams) -> Params
pub fn command(&self, cmd: impl IntoParams) -> Params
Unlike BitBar, SwiftBar supports more than 5 parameters for bash=
commands.
sourcepub fn themed_color(&self, light: Color, dark: Color) -> Color
pub fn themed_color(&self, light: Color, dark: Color) -> Color
Returns a Color
that renders differently depending on whether the system is in dark mode.
sourcepub fn sf_image(&self, item: &mut ContentItem, image: impl ToString)
pub fn sf_image(&self, item: &mut ContentItem, image: impl ToString)
Adds a SF Symbols image to a menu item.
sourcepub fn checked(&self, item: &mut ContentItem)
pub fn checked(&self, item: &mut ContentItem)
Adds a checkmark to a menu item.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SwiftBar
impl RefUnwindSafe for SwiftBar
impl Send for SwiftBar
impl Sync for SwiftBar
impl Unpin for SwiftBar
impl UnwindSafe for SwiftBar
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more