Rename project to multibg-wayland, update documentation

This commit is contained in:
Gergő Sályi 2025-04-26 17:07:40 +02:00
parent 1544cc8f99
commit 552c0ae7e1
12 changed files with 94 additions and 152 deletions

View file

@ -1,5 +1,23 @@
# Changelog
## 0.2.0 - 2025-04-26
### Breaking changes
- Project is being renamed to multibg-wayland to signify support for Wayland compositors other than Sway
- Terminate gracefully on signals INT, HUP or TERM with exit code 0. A second of such signals still kills. USR1 and USR2 are reserved for future use
- License of the source files is still MIT OR Apache-2.0 but built objects now might be under GPL-3.0-or-later.
- Arch Linux package now depends on dav1d
### Other changes
- Added support for the Hyprland and niri wayland compositors
- Inside the wallpaper directory wallpapers symlinked to the same image are now loaded only once and shared saving memory use
- Correct docs about the memory type we use. We only used CPU memory and will only use CPU memory unless the new --gpu option is given.
- Add ability to store wallpapers in GPU memory with the --gpu command line option. Requires Vulkan 1.1 or newer. This might save a few milliseconds latency on wallpaper switches avoiding the use of CPU memory and PCIe bandwidth
- Added support for AVIF images. Requires dav1d native dependency and the avif compile time feature (disabled by default for from source builds, enabled by default for Arch Linux package)
- Update README for the new features
- Update dependencies, require Rust compiler version 1.82 or newer
- Lots of internal changes supporting all the above
## 0.1.10 - 2024-11-17
- Fix sometimes disappearing mouse cursor above wallpapers
- Add small clarifications to README

2
Cargo.lock generated
View file

@ -629,7 +629,7 @@ dependencies = [
]
[[package]]
name = "multibg-sway"
name = "multibg-wayland"
version = "0.2.0"
dependencies = [
"anyhow",

View file

@ -1,17 +1,17 @@
[package]
name = "multibg-sway"
name = "multibg-wayland"
version = "0.2.0"
authors = ["Gergő Sályi <salyigergo94@gmail.com>"]
edition = "2021"
rust-version = "1.82"
description = "Set a different wallpaper for the background of each Sway workspace"
description = "Set a different wallpaper for the background of each Sway or Hyprland or niri workspace"
readme = "README.md"
homepage = "https://github.com/gergo-salyi/multibg-sway"
repository = "https://github.com/gergo-salyi/multibg-sway"
homepage = "https://github.com/gergo-salyi/multibg-wayland"
repository = "https://github.com/gergo-salyi/multibg-wayland"
license = "MIT OR Apache-2.0"
keywords = ["wallpaper", "background", "desktop", "wayland", "sway"]
categories = ["command-line-utilities", "multimedia::images"]
exclude = ["/PKGBUILD", "/scripts/"]
exclude = ["/PKGBUILD", "/PKGBUILD.in", "/scripts/"]
[dependencies]
anyhow = "1.0.97"

View file

@ -1,4 +1,4 @@
Copyright 2023 Gergő Sályi and multibg-sway contributors
Copyright 2023 Gergő Sályi and multibg-wayland contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal

View file

@ -1,40 +0,0 @@
# Maintainer: Gergő Sályi <salyigergo94@gmail.com>
# shellcheck shell=bash disable=SC2034,SC2154
pkgname=multibg-sway
pkgver=0.1.10
pkgrel=1
pkgdesc='Set a different wallpaper for the background of each Sway workspace'
arch=('x86_64' 'i686' 'pentium4' 'armv7h' 'aarch64')
url="https://github.com/gergo-salyi/multibg-sway"
# Direct source files are MIT OR Apache-2.0 but have GPL-3.0-or-later dependencies
license=('GPL-3.0-or-later')
depends=('dav1d>=1.3.0' 'gcc-libs' 'glibc')
makedepends=('cargo')
optdepends=(
'hyprland: supported window manager to set the wallpapers with'
'niri: supported window manager to set the wallpapers with'
'sway: supported window manager to set the wallpapers with'
'vulkan-driver: upload and serve wallpapers from GPU memory'
'vulkan-icd-loader: upload and serve wallpapers from GPU memory'
)
source=("$pkgname-$pkgver.tar.gz::https://static.crates.io/crates/$pkgname/$pkgname-$pkgver.crate")
sha256sums=('2b087124ea07635e53d411e707f7d22f73c69b40f3986a42c841f9cc19fc2d51')
prepare() {
cd "$pkgname-$pkgver"
export RUSTUP_TOOLCHAIN=stable
cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}
build() {
cd "$pkgname-$pkgver"
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --frozen --release --features avif
}
package() {
cd "$pkgname-$pkgver"
install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/$pkgname"
install -Dm644 "README.md" "$pkgdir/usr/share/doc/${pkgname}/README.md"
}

View file

@ -1,11 +1,11 @@
# Maintainer: Gergő Sályi <salyigergo94@gmail.com>
# shellcheck shell=bash disable=SC2034,SC2154
pkgname=multibg-sway
pkgname=multibg-wayland
pkgver=@pkgver@
pkgrel=1
pkgdesc='Set a different wallpaper for the background of each Sway workspace'
arch=('x86_64' 'i686' 'pentium4' 'armv7h' 'aarch64')
url="https://github.com/gergo-salyi/multibg-sway"
url="https://github.com/gergo-salyi/multibg-wayland"
# Direct source files are MIT OR Apache-2.0 but have GPL-3.0-or-later dependencies
license=('GPL-3.0-or-later')
depends=('dav1d>=1.3.0' 'gcc-libs' 'glibc')
@ -36,5 +36,6 @@ build() {
package() {
cd "$pkgname-$pkgver"
install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/$pkgname"
ln -rs "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/bin/multibg-sway"
install -Dm644 "README.md" "$pkgdir/usr/share/doc/${pkgname}/README.md"
}

View file

@ -1,35 +1,39 @@
# multibg-sway
# multibg-wayland
Set a different wallpaper for the background of each Sway workspace
Set a different wallpaper for the background of each Sway / Hyprland / niri workspace
## News
Project is being renamed to multibg-wayland to signify support for Wayland compositors other than Sway. The name multibg-sway remains as an alias or redirect.
## Usage
$ multibg-sway <WALLPAPER_DIR>
$ multibg-wayland <WALLPAPER_DIR>
Wallpapers should be arranged in the following directory structure:
wallpaper_dir/output/workspace_name.{jpg|png|...}
Eg.
Such as:
~/my_wallpapers/HDMI-A-1/1.jpg
In more detail:
- **wallpaper_dir**: A directory, this will be the argument for the multibg-sway command
- **wallpaper_dir**: A directory, this will be the command line argument
- **output**: A directory with the same name as a sway output eg. eDP-1, HDMI-A-1
- If one has multiple outputs with the same resolution this can be a symlink to the directory of the other output.
- To get the name of current outputs from sway one may run:
- **output**: A directory with the same name as a Wayland output such as eDP-1, HDMI-A-1
- For multiple outputs this can be a symlink to the directory of an other output.
- Get the name of current outputs from the compositor with these Sway / Hyprland / niri commands:
$ swaymsg -t get_outputs
$ hyprctl monitors
$ niri msg outputs
- **workspace_name**: The name of the sway workspace, by sway defaults: 1, 2, 3, ..., 10
- Can be a manually defined workspace name (eg. in sway config), but renaming workspaces while multibg-sway is running is not supported currently
- **workspace_name**: The name of the workspace, by default use the compositors assigned workspace numbers as names: 1, 2, 3, ..., 10
- Can be the name of a named workspace usually defined in the config file of the compositor. (Renaming workspaces while multibg-workspace is running might not be supported yet.)
- Can define a **fallback wallpaper** with the special name: **_default**
- Can be a symlink to use a wallpaper image for multiple workspaces
Wallpaper images are now automatically resized at startup to _fill_ the output. Still it is better to have wallpaper images the same resolution as the output, which automatically avoids resizing operations and decreases startup time.
- Can be a symlink to the wallpaper of an other workspace
### Example
@ -45,52 +49,64 @@ For one having a laptop with a built-in display eDP-1 and an external monitor HD
├─ 1.jpg
└─ 3.png
Then start multibg_sway:
Then start multibg-wayland:
$ multibg-sway ~/my_wallpapers
$ multibg-wayland ~/my_wallpapers
It is recommended to edit the wallpaper images in a dedicated image editor. Nevertheless the contrast and brightness might be adjusted here:
### Options
$ multibg-sway --contrast=-25 --brightness=-60 ~/my_wallpapers
In case of errors we log to stderr and try to continue. Redirect stderr to a log file if necessary.
In case of errors multibg-sway logs to stderr and tries to continue. One may wish to redirect stderr if multibg-sway is being run as a daemon.
By default, without the `--gpu` option only CPU memory is used to store wallpapers, shared with the Wayland compositor. (All of this might be reported as memory used by the compositor process instead of our process.)
With the `--gpu` option set GPU memory (again, shared with the compositor) is used. This requires Vulkan loader and driver with Vulkan 1.1 or newer, and might save a few milliseconds latency on wallpaper switches avoiding the use of CPU memory and PCIe bandwidth. (I recommend to try this out, I just can't test it with many GPUs.)
The running Wayland compositor is autodetected based on environment variables. If this fails then try to set the `--compositor {sway|hyprland|niri}` command line option.
It is recommended to resize the wallpapers to the resolution of the output and color adjust with dedicated tools like imagemagick or gimp.
This app can do _some_ imperfect image processing at the expense of startup time. Wallpaper images with different resolution than their output are resized (with high quality filter but incorrect gamma) to _fill_ the output. Contrast and brightness (on some bad arbitrary scale) might be adjusted such as:
$ multibg-wayland --contrast=-25 --brightness=-60 ~/my_wallpapers
### Resource usage
Loaded wallpapers are stored uncompressed to enable fast wallpaper switching with nearly zero CPU use. For example for 10 full HD wallpaper this means 10\*1920\*1080\*4 = 83 MB graphics memory use.
Because multibg-sway doesn't have its own GPU context and manages graphics memory through sway, all this usage might be reported as additional memory used by the sway process.
For active outputs all wallpapers from the corresponding `wallpaper_dir/output` are loaded and stored uncompressed to enable fast wallpaper switching. Wallpapers with multiple symlinks pointing to it are only loaded once and shared. For example for 10 unique full HD wallpaper this means 10\*1920\*1080\*4 = 83 MB memory use.
## Installation
Requires `Rust`, get it from your package manager or from the official website: [https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install)
- Latest release (from [crates.io](https://crates.io/crates/multibg-sway)) with Cargo install provided by Rust:
- Latest release (from [crates.io](https://crates.io/crates/multibg-wayland)) with Cargo install provided by Rust:
$ cargo install --locked multibg-sway
$ cargo install --locked multibg-wayland
Run `~/.cargo/bin/multibg-sway`
Run `~/.cargo/bin/multibg-wayland`
- Directly from the current git source:
$ git clone https://github.com/gergo-salyi/multibg-sway.git
$ cd multibg-sway
$ git clone https://github.com/gergo-salyi/multibg-wayland.git
$ cd multibg-wayland
$ cargo build --release --locked
Run `./target/release/multibg-sway`
Run `./target/release/multibg-wayland`
- For Arch Linux from AUR: [https://aur.archlinux.org/packages/multibg-sway](https://aur.archlinux.org/packages/multibg-sway)
- For Arch Linux from AUR: [https://aur.archlinux.org/packages/multibg-wayland](https://aur.archlinux.org/packages/multibg-wayland)
- eg. with paru
$ paru -S multibg-sway
$ paru -S multibg-wayland
## Bug reporting
Reports on any problems are appreciated, look for an existing or open a new issue at [https://github.com/gergo-salyi/multibg-sway/issues](https://github.com/gergo-salyi/multibg-sway/issues)
Reports on any problems are appreciated, look for an existing or open a new issue at [https://github.com/gergo-salyi/multibg-wayland/issues](https://github.com/gergo-salyi/multibg-wayland/issues)
Please include a verbose log from you terminal by running with `RUST_BACKTRACE=1` and `RUST_LOG=trace` environment variables set, such as
Please include a verbose log from you terminal by running with `RUST_BACKTRACE=1` and `RUST_LOG=info,multibg_wayland=trace` environment variables set, such as
$ RUST_BACKTRACE=1 RUST_LOG=info,multibg_sway=trace multibg-sway ~/my_wallpapers
$ export RUST_BACKTRACE=1
$ export RUST_LOG=info,multibg_wayland=trace
$ multibg-wayland ~/my_wallpapers
If using the --gpu option also consider installing Vulkan validation layers from your distro. It which will be automatically enabled at the log levels defined above.
## Alternatives

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bpftrace
/*
* Trace the timings of wayland and sway-ipc unix socket
* send and receive syscalls on multibg-sway
* send and receive syscalls on multibg-wayland
*
* On Linux with bpftrace installed one can run this script as root
* to get microsecond resolution timings printed to stdout
@ -15,7 +15,7 @@
tracepoint:syscalls:sys_enter_sendto
{
if (comm != "multibg-sway") {
if (comm != "multibg-wayland") {
return;
}
@ -28,7 +28,7 @@ tracepoint:syscalls:sys_enter_sendto
tracepoint:syscalls:sys_enter_sendmsg
{
if (comm != "multibg-sway") {
if (comm != "multibg-wayland") {
return;
}
@ -41,7 +41,7 @@ tracepoint:syscalls:sys_enter_sendmsg
tracepoint:syscalls:sys_enter_write
{
if (comm != "multibg-sway") {
if (comm != "multibg-wayland") {
return;
}
@ -60,7 +60,7 @@ tracepoint:syscalls:sys_enter_write
tracepoint:syscalls:sys_exit_recvfrom
{
if (comm != "multibg-sway") {
if (comm != "multibg-wayland") {
return;
}
@ -72,7 +72,7 @@ tracepoint:syscalls:sys_exit_recvfrom
tracepoint:syscalls:sys_exit_recvmsg
{
if (comm != "multibg-sway") {
if (comm != "multibg-wayland") {
return;
}
@ -86,7 +86,7 @@ tracepoint:syscalls:sys_exit_recvmsg
/*
tracepoint:raw_syscalls:sys_enter
{
if (comm != "multibg-sway") {
if (comm != "multibg-wayland") {
return;
}

View file

@ -2,13 +2,13 @@
set -euo pipefail
if [[ "$(head -2 Cargo.toml)" != '[package]
name = "multibg-sway"' ]]; then
name = "multibg-wayland"' ]]; then
echo 'Not in crate root'
exit 1
fi
version=$(cargo pkgid | cut -d '#' -f2)
crate="target/package/multibg-sway-$version.crate"
crate="target/package/multibg-wayland-$version.crate"
sum=$(sha256sum "$crate" | cut -d ' ' -f1)
if [[ PKGBUILD -nt "$crate" ]]; then

View file

@ -2,52 +2,15 @@ use clap::{Parser, ValueEnum};
#[derive(Parser)]
#[command(author, version, long_about = None, about = "\
Set a different wallpaper for the background of each Sway workspace
Set a different wallpaper for the background of each Sway / Hyprland / niri workspace
$ multibg-sway <WALLPAPER_DIR> [--compositor <COMPOSITOR>]
$ multibg-wayland <WALLPAPER_DIR>
Wallpapers should be arranged in the following directory structure:
wallpaper_dir/output/workspace_name.{jpg|png|...}
Eg.
~/my_wallpapers/HDMI-A-1/1.jpg
In more detail:
- wallpaper_dir: A directory, this will be the argument
for the multibg-sway command
- output: A directory with the same name as a sway output
eg. eDP-1, HDMI-A-1
- If one has multiple outputs with the same resolution this
can be a symlink to the directory of the other output
- To get the name of current outputs from sway one may run:
$ swaymsg -t get_outputs
- workspace_name: The name of the sway workspace,
by sway defaults: 1, 2, 3, ..., 10
- Can be a manually defined workspace name (eg. in sway config),
but renaming workspaces while multibg-sway is running
is not supported currently
- Can define a fallback wallpaper with the special name: _default
- Can be a symlink to use a wallpaper image for multiple workspaces
Wallpaper images are now automatically resized at startup to fill the output.
Still it is better to have wallpaper images the same resolution as the output,
which automatically avoids resizing operations and decreases startup time.
Example:
For one having a laptop with a built-in display eDP-1
and an external monitor HDMI-A-1, wallpapers can be arranged such as:
Such as:
~/my_wallpapers
eDP-1
@ -59,24 +22,8 @@ and an external monitor HDMI-A-1, wallpapers can be arranged such as:
1.jpg
3.png
Then start multibg_sway:
$ multibg-sway ~/my_wallpapers
It is recommended to edit the wallpaper images in a dedicated image editor.
Nevertheless the contrast and brightness might be adjusted here:
$ multibg-sway --contrast=-25 --brightness=-60 ~/my_wallpapers
In case of errors multibg-sway logs to stderr and tries to continue.
One may wish to redirect stderr if multibg-sway is being run as a daemon.
multibg-sway supports multiple compositors,
currently only sway, hyprland and niri.
It tries to autodetect the compositor based on environment variables,
defaulting to sway if that fails.
Pass --compositor {hyprland|niri} to ensure it can to talk to them")]
For more details please read the README at:
https://github.com/gergo-salyi/multibg-wayland/blob/master/README.md")]
pub struct Cli {
/// adjust contrast, eg. -c=-25 (default: 0)
#[arg(short, long)]

View file

@ -88,7 +88,7 @@ fn run() -> anyhow::Result<()> {
env_logger::Builder::from_env(
env_logger::Env::default().default_filter_or(
#[cfg(debug_assertions)]
"info,multibg_sway=trace",
"info,multibg_wayland=trace",
#[cfg(not(debug_assertions))]
"info",
)

View file

@ -677,8 +677,8 @@ impl OutputHandler for State {
if bg_layer.width != width || bg_layer.height != height {
warn!("Handling of output mode or transform changes are not yet \
implemented. Restart multibg-sway or expect broken wallpapers \
or low quality due to scaling");
implemented. Restart this application or expect broken \
wallpapers or low quality due to scaling");
}
let layer = &bg_layer.layer;
@ -970,7 +970,7 @@ fn load_wallpapers(
wl_shm::Format::Bgr888 => {
// Align buffer stride to both 4 and pixel format
// block size. Not being aligned to 4 caused
// https://github.com/gergo-salyi/multibg-sway/issues/6
// https://github.com/gergo-salyi/multibg-wayland/issues/6
(width as usize * 3).next_multiple_of(4)
},
_ => unreachable!(),