• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

swiftbar/SwiftBar: Powerful macOS menu bar customization tool

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

swiftbar/SwiftBar

开源软件地址(OpenSource Url):

https://github.com/swiftbar/SwiftBar

开源编程语言(OpenSource Language):

Swift 99.8%

开源软件介绍(OpenSource Introduction):

SwiftBar Logo

SwiftBar

Add custom menu bar programs on macOS in three easy steps:

  • Write a shell script
  • Add it to SwiftBar
  • ... there is no 3rd step!

You can get plugins from awesome BitBar repository, or in SwiftBar itself using the Get Plugins... menu item.

How to get SwiftBar

Download from GitHub Releases

or Install with Homebrew

brew install swiftbar

Runs on macOS Catalina (10.15) and up.

...or build it from source

  • Clone or download a copy of this repository
  • Open SwiftBar/SwiftBar.xcodeproj
  • Press play

Plugin Repository

SwiftBar is bundled with a Plugin Repository. You can access it at Swiftbar → Get Plugins...

A screenshot of SwiftBar’s Plugin Repository

If you want to add\remove plugin or have other questions about repository content please refer to this issue.

Creating Plugins

To add a new plugin to SwiftBar, you need to create an executable script following the required format (see below) and put it into Plugin Folder.

Plugin Folder

With the first launch, Swiftbar will ask you to set the Plugin Folder. SwiftBar will try to import every file in this folder as a plugin.

Important:

  • hidden folders are ignored
  • nested folders are traversed by SwiftBar, including symlinks

Plugin Naming

Plugin files must adopt the following format:

{name}.{time}.{ext}
  • name - Anything you want.
  • time - Refresh interval (optional). Should be a number + duration modifier (see below)
  • ext - File extension.

Duration modifiers:

  • ms - milliseconds, e.g. 1ms - refresh every millisecond
  • s - seconds, e.g. 1s - refresh every second
  • m - minute, e.g. 10m - refresh every ten minutes
  • h - hour, e.g. 3h - refresh every three hours
  • d - day, e.g. 1d - refresh every day

Example filename: date.1m.sh

Whether you are using a plugin from the plugin repository, or creating your own, plugins will initially appear in the menu bar in no pre-determined order. However, you can reorder how they appear by holding down Cmd and dragging them (this process can sometimes also be used on some other non-SwiftBar icons in the menu bar too). Plugin position will be remembered unless you change the name of the plugin file, in which case they'll need to be re-positioned again.

Plugin API

Plugin is an executable script in the language of your choice. When SwiftBar detects a new file in Plugin Folder it makes this file executable if needed and runs it.

Script should produce output (STDOUT) in the required format (see next chapter). Script errors should be redirected to STDERR.

Plugin API is adopted from the BitBar, which means that SwiftBar can run any existing BitBar plugin.

Script Output

When parsing plugin output SwiftBar recognizes the following blocks:

  • Header: responsible for what you see in the menu bar
  • Body: responsible for dropdown menu contents

Header is everything before first ---. Each --- after the first one will be interpreted as a menu separator. You have one or more lines in the header.

The simplest plugin looks like this:

echo "This is Menu Title"

If you provide multiple titles, the provided titles will be cycled in the menu bar and shown in the dropdown menu:

echo "This is a primary Menu Title"
echo "This is a secondary Menu Title"
echo "This is a n-th Menu Title"
echo "---"
echo "This is not a Menu Title, this will be showed in the drop-down menu only"

Script output for both header and body is split by line (\n). Each line must follow this format:

<Item Title> | [param = ...] 

Where:

  • "Item Title" can be any string, this will be used as a menu item title.
  • [param = ...] is an optional set of parameters\modificators. Each parameter is a key-value separated by =. Use | to separate parameters from the title.

Parameters

Text Formatting:

Parameter Value Description
color CSS color or HEX, light_color,dark_color Sets item text color. If only one color is provided, it is used for both light and dark appearance.
sfcolor CSS color or HEX, light_color,dark_color Sets SF Symbol color. If only one color is provided, it is used for both light and dark appearance. If you fame multiple SF Symbols you can provide different colors by adding index, like this sfcolor2
font macOS font name Sets font name to use in item text
size Number Sets item text size
md True Enables markdown support in menu title for **bold** and *italic*
sfsize Number Sets size for SF Symbol image embedded in text
length Number Trims item text to a provided number of characters. The full title will be displayed in a tooltip.
trim True Trims whitespace characters
ansi True Enables support of ANSI color codes. Conflicts with: symbolize
emojize False Disables parsing of GitHub style Emojis (e.g., :mushroom: into

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap