https://github.com/Alexays/Waybar
Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
https://github.com/Alexays/Waybar
bar gtk i3status statusbar sway wayland wlroots
Last synced: 12 months ago
JSON representation
Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
- Host: GitHub
- URL: https://github.com/Alexays/Waybar
- Owner: Alexays
- License: mit
- Created: 2018-08-08T21:53:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-22T07:17:08.000Z (almost 2 years ago)
- Last Synced: 2024-05-22T13:58:18.280Z (almost 2 years ago)
- Topics: bar, gtk, i3status, statusbar, sway, wayland, wlroots
- Language: C++
- Homepage:
- Size: 4.1 MB
- Stars: 5,571
- Watchers: 36
- Forks: 643
- Open Issues: 709
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- stars - Alexays/Waybar
- awesome-linux-ricing - Waybar - Highly customizable Wayland bar. (Bar / Nerd Fonts)
- awesome-repositories - Alexays/Waybar - Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada: (C++)
- awesome-internettime - Waybar
- awesome-ricing - waybar - Highly customizable Wayland bar for Sway and Wlroots based compositors. (C++) (Packages / Bars, Panels, and Widgets)
- awesome-niri - Waybar - Highly customizable Wayland bar based on GTK. (Bars and Widgets / Miscellaneous)
- awesome-starred - Waybar - Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada: (C++)
- awesome-wayland - waybar - Highly customizable bar for wlroots compositors. (Status Bar / Sway Specific)
- StarryDivineSky - Alexays/Waybar - -----|------| | **高度可定制** | JSON 配置中可以自由设置每个模块的位置、字体大小、颜色、宽度等;还支持自定义 `style.css`,使得整个栏可以像 i3bar 那样被切成多块并排布。 | | **多模块支援** | 内置 12+ 模块(如 clock, battery, network, volume, backlight 等),可在一个 bar 同时显示多个信息;每个模块都有自己的 “type” 字段来指示其实现。| | **Wayland 原生** | Waybar 并用 `wlroots` 的 libwlr 以及 sway-client(IPC)直接与合成器交互,支持多屏幕、分辨率切换而不需重启。 | | **主题化 & 动画** | 可以通过 CSS 设置渐变背景、圆角等;模块文字可用 `font`, `color` 等属性定制,甚至可以使用自定义图标(SVG)。| | **插件式架构** | 每个模块本身是一个独立的 C 结构体,可以随时新增或移除。Waybar 的代码里还有 `module.h` 与 “module.c” 模块管理文件;新功能只需添加一个 .c 并在 Makefile 中编译即可。| ### 安装方式 #### A. 系统包 (Arch / Fedora / Ubuntu) ``` # Arch Linux sudo pacman -S waybar # 官方仓库已提供 # Debian/Ubuntu apt-get install waybar # 需 libsway-client, libwlroots # Fedora dnf install waybar ``` > **依赖**: > * `libwayland`(Wayland 库) > * `libsway-client`(与 sway IPC 通信的库) > * `libwlr` (wlroots 的 C 接口) #### B. 源码编译 ``` git clone https://github.com/Alexays/Waybar cd Waybar make # 编译全部模块,需已安装 libwayland、sway-client 等依赖 sudo make install # 安装到 /usr/local/bin 及 /etc/systemd ``` > **配置** > - 配置文件位于 `~/.config/waybar/config.json`。可直接复制 repo 中的示例或使用 `waybar --help` 生成默认结构。 > - 样例: ```json { "layer": "top", "height": 30, "modules-center":[ "clock", "battery" ], "font":"Ubuntu Mono,10:medium" } ``` #### C. 启动 Sway 时只需在 `~/.config/sway/config` 中加入: ``` exec waybar ``` Waybar 将自动读取 JSON 配置并渲染栏。 ### 典型使用案例 - **自定义时钟** - 在 config.json 的 “modules” 对象中添加 `"clock": {"type":"clock","format":"%a %d-%m-%y %H:%M"}`;Waybar 将每分钟更新一次。 - **网络状态监测** ``` "network":{ "type":"network", "interface":"eth0" } ``` Waybar 会根据网卡是否有 IP 或链接决定显示 “Wi‑Fi”/“Ethernet”。 - **音量控制** - `"volume":{"type":"pulseaudio","device":"default"}`;模块会监听 PulseAudio 的事件并渲染当前电量。 ### 核心工作原理(简化) 1. Waybar 启动 → 读取 config.json → 创建各个模块实例。 2. 每个模块根据 “type” 字段决定其实现:`clock`, `battery` 等对应到 C 结构体与函数。 3. 模块通过 sway IPC 或 wlroots 的输出接口注册自己在 Wayland 上的“挂点”(`wlr_surface`)。 4. 当外部事件(如电量变化、网络状态改变)时,模块会收到相应信号并重新渲染自己的文字与图标。 5. 渲染结果通过 Waybar 的 “layout engine” 送给 sway/swaycompositor,以此更新屏幕上的 bar surface。 ### 小结 Waybar 用 JSON 配置实现高度可定制,支持多模块、主题化,并且直接在 Wayland 下工作,无需 X11 或其他旧版技术。它为 Sway 和任何 wlroots 合成器提供一个类似 i3bar 的状态栏,让用户可以通过简单的配置文件自由定义想要显示的信息与样式。 (C/C++程序设计 / 资源传输下载)
README
# Waybar [](LICENSE) [](https://paypal.me/ARouillard)

> Highly customizable Wayland bar for Sway and Wlroots based compositors.
> Available in [all major distributions](https://github.com/Alexays/Waybar/wiki/Installation)
> *Waybar [examples](https://github.com/Alexays/Waybar/wiki/Examples)*
#### Current features
- Sway (Workspaces, Binding mode, Focused window name)
- River (Mapping mode, Tags, Focused window name)
- Hyprland (Window Icons, Workspaces, Focused window name)
- Niri (Workspaces, Focused window name, Language)
- DWL (Tags, Focused window name) [requires dwl ipc patch](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/ipc)
- Tray [#21](https://github.com/Alexays/Waybar/issues/21)
- Local time
- Battery
- UPower
- Power profiles daemon
- Network
- Bluetooth
- Pulseaudio
- Privacy Info
- Wireplumber
- Disk
- Memory
- Cpu load average
- Temperature
- MPD
- Custom scripts
- Custom image
- Multiple output configuration
- And many more customizations
#### Configuration and Styling
[See the wiki for more details](https://github.com/Alexays/Waybar/wiki).
### Installation
Waybar is available from a number of Linux distributions:
[](https://repology.org/project/waybar/versions)
An Ubuntu PPA with more recent versions is available
[here](https://launchpad.net/~nschloe/+archive/ubuntu/waybar).
#### Building from source
```bash
$ git clone https://github.com/Alexays/Waybar
$ cd Waybar
$ meson setup build
$ ninja -C build
$ ./build/waybar
# If you want to install it
$ ninja -C build install
$ waybar
```
**Dependencies**
```
gtkmm3
jsoncpp
libsigc++
fmt
wayland
chrono-date
spdlog
libgtk-3-dev [gtk-layer-shell]
gobject-introspection [gtk-layer-shell]
libgirepository1.0-dev [gtk-layer-shell]
libpulse [Pulseaudio module]
libnl [Network module]
libappindicator-gtk3 [Tray module]
libdbusmenu-gtk3 [Tray module]
libmpdclient [MPD module]
libsndio [sndio module]
libevdev [KeyboardState module]
xkbregistry
upower [UPower battery module]
```
**Build dependencies**
```
cmake
meson
scdoc
wayland-protocols
```
On Ubuntu, you can install all the relevant dependencies using this command (tested with 19.10 and 20.04):
```
sudo apt install \
clang-tidy \
gobject-introspection \
libdbusmenu-gtk3-dev \
libevdev-dev \
libfmt-dev \
libgirepository1.0-dev \
libgtk-3-dev \
libgtkmm-3.0-dev \
libinput-dev \
libjsoncpp-dev \
libmpdclient-dev \
libnl-3-dev \
libnl-genl-3-dev \
libpulse-dev \
libsigc++-2.0-dev \
libspdlog-dev \
libwayland-dev \
scdoc \
upower \
libxkbregistry-dev
```
Contributions welcome!
Have fun :)
The style guidelines are [Google's](https://google.github.io/styleguide/cppguide.html)
## License
Waybar is licensed under the MIT license. [See LICENSE for more information](https://github.com/Alexays/Waybar/blob/master/LICENSE).