Skip to content

Compiling

You can compile Ironbar from source using cargo. Just clone the repo and build:

Terminal window
git clone https://github.com/jakestanger/ironbar.git
cd ironbar
cargo build --locked --release
# change path to wherever you want to install
install target/release/ironbar ~/.local/bin/ironbar

It is also recommended to install a Nerd Font for displaying symbols.

Build requirements

To build from source, you must have GTK (>= 4.12) and GTK Layer Shell installed. You also need rust; only the latest stable version is supported.

Docker

A docker image is available which includes all the requirements.

https://github.com/JakeStanger/ironbar/pkgs/container/ironbar-build

Terminal window
docker run -it -v '.:/app' ghcr.io/jakestanger/ironbar-build /bin/bash
$ cd app
$ cargo build

Arch

Build:

Terminal window
pacman -S gtk4 gtk4-layer-shell dbus pkg-config
# for http support
pacman -S openssl
# for volume support
pacman -S libpulse
# for keyboard support
pacman -S libinput
# for lua/cairo support
pacman -S luajit lua51-lgi

Runtime:

Terminal window
# for lua/cairo support
pacman -S lua51-lgi

Ubuntu/Debian

Build:

Terminal window
apt install build-essential libgtk-4-dev libgtk4-layer-shell-dev libdbus-1-dev
# for http support
apt install libssl-dev
# for volume support
apt install libpulse-dev
# for keyboard support
apt install libinput-dev
# for lua/cairo support
apt install libluajit-5.1-dev

Runtime:

Terminal window
apt install gtk4 gtk4-layer-shell
# for lua/cairo support
apt install luajit lua-lgi

Fedora

Build:

Terminal window
dnf install gtk4-devel gtk4-layer-shell-devel dbus-devel pkgconf-pkg-config
# for http support
dnf install openssl-devel
# for volume support
dnf install pulseaudio-libs-devel
# for keyboard support
dnf install libinput-devel
# for lua/cairo support
dnf install luajit-devel

Runtime:

Terminal window
dnf install gtk4 gtk4-layer-shell
# for lua/cairo support
apt install luajit lua-lgi

Features

By default, all features are enabled for convenience. This can result in a significant compile time. If you know you are not going to need all the features, you can compile with only the features you need.

As of v0.15.0, compiling with no features is about 50% faster. On a 3800X, it takes about 45 seconds for no features and 90 seconds for all. This difference is expected to increase as the bar develops.

Features containing a + can be stacked, for example config+json and config+yaml could both be enabled.

To build using only specific features, disable default features and pass a comma separated list to cargo build:

Terminal window
cargo build --release --no-default-features \
--features http,config+json,clock

⚠ Make sure you enable at least one config feature otherwise you will not be able to start the bar!

FeatureDescription
Core
httpEnables HTTP features. Currently this includes the ability to load remote images.
ipcEnables the IPC server.
cliEnables the CLI. Will also enable ipc.
config+allEnables support for all configuration languages.
config+jsonEnables configuration support for JSON.
config+yamlEnables configuration support for YAML.
config+tomlEnables configuration support for TOML.
config+cornEnables configuration support for Corn.
Modules
batteryEnables the battery module.
bindmodeEnables the bindmode module.
bluetoothEnables the bluetooth module.
cairoEnables the cairo module
clipboardEnables the clipboard module.
clockEnables the clock module.
customEnables the custom module.
focusedEnables the focused module.
inhibitEnables the inhibit module.
keyboardEnables the keyboard module without keyboard layout support.
keyboard+allEnables the keyboard module with keyboard layout support for all compositors.
keyboard+swayEnables the keyboard module with keyboard layout support for Sway.
keyboard+hyprlandEnables the keyboard module with keyboard layout support for Hyprland.
labelEnables the label module.
launcherEnables the launcher module.
music+allEnables the music module with support for all player types.
music+mprisEnables the music module with MPRIS support.
music+mpdEnables the music module with MPD support.
network_managerEnables the network_manager module.
notificationsEnables the notiications module.
sys_infoEnables the sys_info module.
scriptEnables the script module.
trayEnables the tray module.
volumeEnables the volume module.
workspaces+allEnables the workspaces module with support for all compositors.
workspaces+swayEnables the workspaces module with support for Sway.
workspaces+hyprlandEnables the workspaces module with support for Hyprland.
workspaces+niriEnables the workspaces module with support for Niri.
Other
extraEnables JSON schema support, shell completion support, and the CLI --print-schema and --print-completions flags.

Shell completions

Compiling Ironbar will produce shell completions for bash, zsh and fish; these can be found in target/completions.

You can install these as follows:

Bash:

Terminal window
install -Dm644 completions/ironbar.bash /usr/share/bash-completion/completions/ironbar

Zsh:

Terminal window
install -Dm644 completions/_ironbar /usr/share/zsh/site-functions/_ironbar

Fish:

Terminal window
install -Dm644 completions/ironbar.fish /usr/share/fish/vendor_completions.d/ironbar.fish

Speeding up compiling

With the full feature set, Ironbar can take a good while to compile. There are a couple of tricks which can be used to improve compile times.

Linker

Rust versions older than 1.90 use the default GCC ld linker. By upgrading to >=1.90, the ldd linker is used instead. This provides a large increase in compliation speeds.

Caching

To speed up subsequent rebuilds, Mozilla’s sccache tool can be used. This provides a cache of Rust modules which can be re-used when compiling any other crate.

Install the package for your distro, create/modify the .cargo/config.toml file inside the project dir, then add the following:

[build]
rustc-wrapper = "/usr/bin/sccache"

Codegen Backend

If working on the Ironbar codebase, you may see some benefit from using the Cranelift compiler backend. This is known to shave a further few seconds off the compile time (bringing down from 10 to 7-8 on my own hardware).

Firstly install the component:

Terminal window
rustup component add rustc-codegen-cranelift-preview --toolchain nightly

Then create/modify the .cargo/config.toml file inside the project dir, and add the following:

[unstable]
codegen-backend = true
[profile.dev]
codegen-backend = "cranelift"