neferbar
A dead simple status bar for Wayland: one line of terminal text, nothing else.
Each part of the bar is a script. A script prints text, and neferbar shows it. If you can write echo, you can write a module.
[The bundled bar on a NeferWL desktop with a terminal and an empty Firefox: workspaces on the left, the focused app and its title in the middle, the clock on the right]
- Text only. ASCII, Unicode and Nerd Font icons. No images, no widgets, no clicks.
- Exactly one character high. The bar is as tall as a terminal row, and it follows your monitor's scale.
- Scripts do the work. Any language, anything that prints to stdout.
- Fast when you ask. Print 60 times a second and the bar redraws 60 times a second. Print nothing and it uses no CPU or GPU.
It needs a compositor with wlr-layer-shell, such as Sway, Hyprland, Niri, River or NeferWL. GNOME is not supported.
Install
You need Go 1.27, a Vulkan 1.3 GPU driver, and a Nerd Font.
go build -o neferbar ./cmd/neferbar
./neferbar
Start it from your compositor's autostart. For NeferWL:
startup = /full/path/to/neferbar
Create ~/.config/neferbar/config.toml:
[bar]
font = "JetBrainsMono Nerd Font Mono" # use a "Mono" Nerd Font so icons fit one cell
size = 14 # text size
theme = "auto" # colors of your terminal, or the path of a theme file
[[module]]
name = "clock" # a unique name
zone = "center" # left, center or right
exec = "~/.config/neferbar/clock.sh"
Add one [[module]] block per script. Save the file and the bar updates immediately. If you make a typo, the bar keeps the old config and prints the error.
| Setting |
Default |
Meaning |
bar.font |
JetBrainsMono Nerd Font Mono |
A font family known to fontconfig (fc-list). |
bar.size |
14 |
Text size in logical pixels. |
bar.scale |
1.0 |
Extra zoom on top of the monitor scale. |
bar.output |
any |
A monitor name such as HDMI-A-1. Needs a restart. |
bar.theme |
auto |
auto reads the colors of the terminal you use. Or the path of a theme file (see Colors). |
bar.accent |
4 |
Which of the theme's 16 colors (0-15) the highlights use. 4 is the ANSI blue; try 2 (green), 6 (cyan) or 5 (magenta) to match your theme. |
bar.background, bar.foreground |
from the theme |
#rrggbb. Set them to override the theme. |
If the font is not installed, neferbar warns and falls back to another font, and icons may be missing.
Colors
The bar takes its colors from your terminal, so it matches the rest of your desktop.
theme = "auto" # the terminal you use
theme = "~/.config/kitty/themes/mytheme.conf" # or one file
auto reads the theme of the terminal named by the $TERMINAL environment variable, and nothing else. It knows kitty, ghostty, foot and alacritty (TERMINAL=kitty, or a path such as /usr/bin/foot). A theme file can be any of those formats, and the bar recognizes it by its content. Includes and ghostty theme = names are followed. Colors the file does not set come from a built-in dark theme.
Set $TERMINAL for your whole session, not only in a shell. A variable you set -x in an open terminal is not seen by programs your compositor starts. The simplest place is a systemd user environment file, read when a session starts, whatever your shell is:
# ~/.config/environment.d/10-terminal.conf
TERMINAL=kitty
Then start a new session. If $TERMINAL is missing, the bar says so in its log and uses the built-in colors.
The bar watches every file it read: change your terminal's theme and the bar changes with it. If the theme cannot be read, the bar uses the built-in colors and says why in its log.
Scripts get the colors as environment variables, each #rrggbb, so a script never hard-codes one:
| Variable |
Color |
NEFERBAR_BACKGROUND, NEFERBAR_FOREGROUND |
the bar's own background and text |
NEFERBAR_ACCENT |
the highlight color, the theme color that bar.accent picks |
NEFERBAR_COLOR0 .. NEFERBAR_COLOR15 |
the theme's 16 ANSI colors |
The 16 ANSI codes a script prints (\033[31m red, \033[44m blue background and so on) use the theme as well.
Write a script
A module is any program that prints lines. Each line replaces what the module showed before.
The smallest module:
#!/bin/sh
echo "hello"
sleep 100000
A clock, updated every second:
#!/bin/sh
while true; do
date +%H:%M:%S
sleep 1
done
Make it executable (chmod +x clock.sh) and put its path in exec. That's all.
Rules:
- Print one line, then print another line later. The new line replaces the old one.
- A frame ends at a newline (
\n) or a form feed (\f). They mean the same thing. Text after the last one, with no ending yet, is not shown until its frame is finished.
- Keep the script running. A script that exits is restarted after a short delay, and the bar shows
[name!] in the meantime.
- Print errors to stderr. They go to the bar's log and not to the screen.
- Frames are cut to 16 KiB, and text wider than the bar is clipped.
Colors and styles
Use ordinary terminal escape codes. If it works in a terminal, it works here.
printf '\033[32mOK\033[0m \033[1;31mFAIL\033[0m\n'
| Code |
Effect |
\033[1m |
bold |
\033[2m |
dim |
\033[3m |
italic |
\033[4m |
underline |
\033[7m |
inverse |
\033[9m |
strikethrough |
\033[30m..\033[37m |
foreground colors |
\033[40m..\033[47m |
background colors |
\033[38;5;Nm / \033[48;5;Nm |
256-color palette |
\033[38;2;R;G;Bm / \033[48;2;R;G;Bm |
true color |
\033[0m |
reset |
Italic, bold and bold italic use the font's own files when it has them.
Icons
Nerd Font icons are ordinary characters, but GitHub cannot draw them in a code block, so the examples here write them as escape sequences. Give printf the icon's code point:
printf '\Uf017 %s\n' "$(date +%H:%M)" # clock icon (U+F017)
\U works in bash. Some minimal shells do not support it; the UTF-8 bytes work everywhere: printf '\357\200\227 %s\n' "$(date +%H:%M)".
Find icon names and code points at https://www.nerdfonts.com/cheat-sheet. In an editor with a Nerd Font you can also paste the icon itself into the script.
Animation
Print faster. Each frame ends with \f:
#!/bin/sh
# a spinner at 20 fps
while true; do
for c in '|' '/' '-' '\'; do
printf '%s\f' "$c"
sleep 0.05
done
done
neferbar draws at most as often as your monitor refreshes. If a script prints faster than that, only the latest frame is drawn. A script that prints nothing costs nothing.
The bundled bar
examples/bundle is a ready-made bar: workspaces on the left, the focused app in the middle, the clock on the right, in your terminal's colors.
Copy it to ~/.config/neferbar/ (the install steps are at the top of examples/bundle/config.toml).
Its helper lib.sh has what a themed script needs: fg/bg to set a color from #rrggbb, mix to blend two, fade for the soft edge, and state_changed_loop to react to NeferWL. Read the three scripts: each is about thirty lines.
On NeferWL the workspaces show one dot per window and the stash. On other compositors the workspace and focus modules show nothing yet, and the clock still works.
Reacting to your compositor (workspace effects)
A module can watch anything, including the compositor's own state. NeferWL keeps a JSON file up to date and passes its path to every program it starts as $NEFERWL_STATE. It replaces the file on each change, so a module only has to check the file's modification time:
stamp=$(mktemp)
touch -r "$NEFERWL_STATE" "$stamp"
while sleep 0.1; do
if [[ $NEFERWL_STATE -nt $stamp ]]; then # the file changed
touch -r "$NEFERWL_STATE" "$stamp"
jq -r '.outputs[] | "\(.name) is on workspace \(.active)"' "$NEFERWL_STATE"
fi
done
That is all it takes to draw an effect when you switch workspace. examples/bundle/left.sh redraws the workspaces that way.
Example modules
The examples/modules directory has these:
static.sh: one line, then idle.
clock.sh: a clock with an icon.
rainbow.sh [fps] [width]: a 60 fps scrolling rainbow.
Layout
The bar has three zones. Modules in the same zone appear side by side, in the order of the config file.
- left starts at the left edge.
- right ends at the right edge.
- center sits in the middle of the space that is left. If the bar is too narrow, the center is cut first.
Command line
neferbar [-config file] [-display socket] [-pprof addr] [-memstats interval]
| Flag |
Meaning |
-config |
Config file. Default: $XDG_CONFIG_HOME/neferbar/config.toml. |
-display |
Wayland socket name or path. Default: $NEFERBAR_DISPLAY, then $WAYLAND_DISPLAY. |
-pprof |
Serve Go profiling on a loopback address, such as localhost:6060. |
-memstats |
Log allocation counters at this interval. |
Reading the focused window
neferbar app prints fields of the window that has the focus: one line now, then a new one each time the focus or a title changes. It works on compositors that offer zwlr_foreign_toplevel_manager_v1 (NeferWL, Sway, Hyprland, River, Niri).
neferbar app title # Dumber - docs
neferbar app id # com.github.bnema.dumber
neferbar app name # dumber (the part of the id after the last dot)
neferbar app name title # several fields, separated by a tab
neferbar app -once title # print once and exit
A line is empty when no window has the focus. Control characters are removed from every field, so a title cannot move a terminal's cursor. Scripts started by the bar find the binary in $NEFERBAR_BIN.
Test without touching your desktop
go test ./...
scripts/headless.sh examples/config.toml 5 # runs in a nested headless NeferWL
SCALE=1.5 SIZE=1200x200 scripts/headless.sh examples/config.toml 5
Screenshots land in /tmp/neferbar-shots.
License
MIT.
source
1# neferbar
2
3A dead simple status bar for Wayland: **one line of terminal text, nothing else.**
4
5Each part of the bar is a script. A script prints text, and neferbar shows it. If you can write `echo`, you can write a module.
6
7
8
9- **Text only.** ASCII, Unicode and Nerd Font icons. No images, no widgets, no clicks.
10- **Exactly one character high.** The bar is as tall as a terminal row, and it follows your monitor's scale.
11- **Scripts do the work.** Any language, anything that prints to stdout.
12- **Fast when you ask.** Print 60 times a second and the bar redraws 60 times a second. Print nothing and it uses no CPU or GPU.
13
14It needs a compositor with `wlr-layer-shell`, such as Sway, Hyprland, Niri, River or NeferWL. GNOME is not supported.
15
16## Install
17
18You need Go 1.27, a Vulkan 1.3 GPU driver, and a [Nerd Font](https://www.nerdfonts.com/).
19
20```sh
21go build -o neferbar ./cmd/neferbar
22./neferbar
23```
24
25Start it from your compositor's autostart. For NeferWL:
26
27```
28startup = /full/path/to/neferbar
29```
30
31## Configure
32
33Create `~/.config/neferbar/config.toml`:
34
35```toml
36[bar]
37font = "JetBrainsMono Nerd Font Mono" # use a "Mono" Nerd Font so icons fit one cell
38size = 14 # text size
39theme = "auto" # colors of your terminal, or the path of a theme file
40
41[[module]]
42name = "clock" # a unique name
43zone = "center" # left, center or right
44exec = "~/.config/neferbar/clock.sh"
45```
46
47Add one `[[module]]` block per script. Save the file and the bar updates immediately. If you make a typo, the bar keeps the old config and prints the error.
48
49| Setting | Default | Meaning |
50|---|---|---|
51| `bar.font` | `JetBrainsMono Nerd Font Mono` | A font family known to fontconfig (`fc-list`). |
52| `bar.size` | `14` | Text size in logical pixels. |
53| `bar.scale` | `1.0` | Extra zoom on top of the monitor scale. |
54| `bar.output` | any | A monitor name such as `HDMI-A-1`. Needs a restart. |
55| `bar.theme` | `auto` | `auto` reads the colors of the terminal you use. Or the path of a theme file (see Colors). |
56| `bar.accent` | `4` | Which of the theme's 16 colors (0-15) the highlights use. 4 is the ANSI blue; try 2 (green), 6 (cyan) or 5 (magenta) to match your theme. |
57| `bar.background`, `bar.foreground` | from the theme | `#rrggbb`. Set them to override the theme. |
58
59If the font is not installed, neferbar warns and falls back to another font, and icons may be missing.
60
61## Colors
62
63The bar takes its colors from your terminal, so it matches the rest of your desktop.
64
65```toml
66theme = "auto" # the terminal you use
67theme = "~/.config/kitty/themes/mytheme.conf" # or one file
68```
69
70`auto` reads the theme of the terminal named by the **`$TERMINAL`** environment variable, and nothing else. It knows kitty, ghostty, foot and alacritty (`TERMINAL=kitty`, or a path such as `/usr/bin/foot`). A theme file can be any of those formats, and the bar recognizes it by its content. Includes and ghostty `theme =` names are followed. Colors the file does not set come from a built-in dark theme.
71
72**Set `$TERMINAL` for your whole session**, not only in a shell. A variable you `set -x` in an open terminal is not seen by programs your compositor starts. The simplest place is a systemd user environment file, read when a session starts, whatever your shell is:
73
74```
75# ~/.config/environment.d/10-terminal.conf
76TERMINAL=kitty
77```
78
79Then start a new session. If `$TERMINAL` is missing, the bar says so in its log and uses the built-in colors.
80
81The bar watches every file it read: change your terminal's theme and the bar changes with it. If the theme cannot be read, the bar uses the built-in colors and says why in its log.
82
83Scripts get the colors as environment variables, each `#rrggbb`, so a script never hard-codes one:
84
85| Variable | Color |
86|---|---|
87| `NEFERBAR_BACKGROUND`, `NEFERBAR_FOREGROUND` | the bar's own background and text |
88| `NEFERBAR_ACCENT` | the highlight color, the theme color that `bar.accent` picks |
89| `NEFERBAR_COLOR0` .. `NEFERBAR_COLOR15` | the theme's 16 ANSI colors |
90
91The 16 ANSI codes a script prints (`\033[31m` red, `\033[44m` blue background and so on) use the theme as well.
92
93## Write a script
94
95A module is any program that prints lines. **Each line replaces what the module showed before.**
96
97The smallest module:
98
99```sh
100#!/bin/sh
101echo "hello"
102sleep 100000
103```
104
105A clock, updated every second:
106
107```sh
108#!/bin/sh
109while true; do
110 date +%H:%M:%S
111 sleep 1
112done
113```
114
115Make it executable (`chmod +x clock.sh`) and put its path in `exec`. That's all.
116
117Rules:
118
1191. Print one line, then print another line later. The new line replaces the old one.
1202. A frame ends at a newline (`\n`) or a form feed (`\f`). They mean the same thing. Text after the last one, with no ending yet, is not shown until its frame is finished.
1213. Keep the script running. A script that exits is restarted after a short delay, and the bar shows `[name!]` in the meantime.
1224. Print errors to stderr. They go to the bar's log and not to the screen.
1235. Frames are cut to 16 KiB, and text wider than the bar is clipped.
124
125### Colors and styles
126
127Use ordinary terminal escape codes. If it works in a terminal, it works here.
128
129```sh
130printf '\033[32mOK\033[0m \033[1;31mFAIL\033[0m\n'
131```
132
133| Code | Effect |
134|---|---|
135| `\033[1m` | **bold** |
136| `\033[2m` | dim |
137| `\033[3m` | *italic* |
138| `\033[4m` | underline |
139| `\033[7m` | inverse |
140| `\033[9m` | ~~strikethrough~~ |
141| `\033[30m`..`\033[37m` | foreground colors |
142| `\033[40m`..`\033[47m` | background colors |
143| `\033[38;5;Nm` / `\033[48;5;Nm` | 256-color palette |
144| `\033[38;2;R;G;Bm` / `\033[48;2;R;G;Bm` | true color |
145| `\033[0m` | reset |
146
147Italic, bold and bold italic use the font's own files when it has them.
148
149### Icons
150
151Nerd Font icons are ordinary characters, but GitHub cannot draw them in a code block, so the examples here write them as escape sequences. Give `printf` the icon's code point:
152
153```sh
154printf '\Uf017 %s\n' "$(date +%H:%M)" # clock icon (U+F017)
155```
156
157`\U` works in bash. Some minimal shells do not support it; the UTF-8 bytes work everywhere: `printf '\357\200\227 %s\n' "$(date +%H:%M)"`.
158
159Find icon names and code points at <https://www.nerdfonts.com/cheat-sheet>. In an editor with a Nerd Font you can also paste the icon itself into the script.
160
161### Animation
162
163Print faster. Each frame ends with `\f`:
164
165```sh
166#!/bin/sh
167# a spinner at 20 fps
168while true; do
169 for c in '|' '/' '-' '\'; do
170 printf '%s\f' "$c"
171 sleep 0.05
172 done
173done
174```
175
176neferbar draws at most as often as your monitor refreshes. If a script prints faster than that, only the latest frame is drawn. A script that prints nothing costs nothing.
177
178### The bundled bar
179
180`examples/bundle` is a ready-made bar: workspaces on the left, the focused app in the middle, the clock on the right, in your terminal's colors.
181
182 Copy it to `~/.config/neferbar/` (the install steps are at the top of `examples/bundle/config.toml`).
183
184Its helper `lib.sh` has what a themed script needs: `fg`/`bg` to set a color from `#rrggbb`, `mix` to blend two, `fade` for the soft edge, and `state_changed_loop` to react to NeferWL. Read the three scripts: each is about thirty lines.
185
186On NeferWL the workspaces show one dot per window and the stash. On other compositors the workspace and focus modules show nothing yet, and the clock still works.
187
188### Reacting to your compositor (workspace effects)
189
190A module can watch anything, including the compositor's own state. NeferWL keeps a JSON file up to date and passes its path to every program it starts as `$NEFERWL_STATE`. It replaces the file on each change, so a module only has to check the file's modification time:
191
192```sh
193stamp=$(mktemp)
194touch -r "$NEFERWL_STATE" "$stamp"
195while sleep 0.1; do
196 if [[ $NEFERWL_STATE -nt $stamp ]]; then # the file changed
197 touch -r "$NEFERWL_STATE" "$stamp"
198 jq -r '.outputs[] | "\(.name) is on workspace \(.active)"' "$NEFERWL_STATE"
199 fi
200done
201```
202
203That is all it takes to draw an effect when you switch workspace. `examples/bundle/left.sh` redraws the workspaces that way.
204
205### Example modules
206
207The `examples/modules` directory has these:
208
209- `static.sh`: one line, then idle.
210- `clock.sh`: a clock with an icon.
211- `rainbow.sh [fps] [width]`: a 60 fps scrolling rainbow.
212
213## Layout
214
215The bar has three zones. Modules in the same zone appear side by side, in the order of the config file.
216
217- **left** starts at the left edge.
218- **right** ends at the right edge.
219- **center** sits in the middle of the space that is left. If the bar is too narrow, the center is cut first.
220
221## Command line
222
223```
224neferbar [-config file] [-display socket] [-pprof addr] [-memstats interval]
225```
226
227| Flag | Meaning |
228|---|---|
229| `-config` | Config file. Default: `$XDG_CONFIG_HOME/neferbar/config.toml`. |
230| `-display` | Wayland socket name or path. Default: `$NEFERBAR_DISPLAY`, then `$WAYLAND_DISPLAY`. |
231| `-pprof` | Serve Go profiling on a loopback address, such as `localhost:6060`. |
232| `-memstats` | Log allocation counters at this interval. |
233
234## Reading the focused window
235
236`neferbar app` prints fields of the window that has the focus: one line now, then a new one each time the focus or a title changes. It works on compositors that offer `zwlr_foreign_toplevel_manager_v1` (NeferWL, Sway, Hyprland, River, Niri).
237
238```
239neferbar app title # Dumber - docs
240neferbar app id # com.github.bnema.dumber
241neferbar app name # dumber (the part of the id after the last dot)
242neferbar app name title # several fields, separated by a tab
243neferbar app -once title # print once and exit
244```
245
246A line is empty when no window has the focus. Control characters are removed from every field, so a title cannot move a terminal's cursor. Scripts started by the bar find the binary in `$NEFERBAR_BIN`.
247
248## Test without touching your desktop
249
250```sh
251go test ./...
252scripts/headless.sh examples/config.toml 5 # runs in a nested headless NeferWL
253SCALE=1.5 SIZE=1200x200 scripts/headless.sh examples/config.toml 5
254```
255
256Screenshots land in `/tmp/neferbar-shots`.
257
258## License
259
260MIT.