Skip to content

Commit

Permalink
Update readme, replace capturer=wlroots with capturer=wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
maximbaz committed Oct 25, 2024
1 parent 8fbd0f7 commit ce02fd3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body:
### Thanks for your time and effort in making the project better!
- type: markdown
attributes:
value: Is your issue related to `wlroots`? Remember that you must change `capturer` to `none` in the config, if you are not using wlroots-based compositor (such as `sway`).
value: Is your issue related to screen capturing? Remember that your compositor must support one of the protocols listed in README, otherwise you must change `capturer` to `none` in the config.
- type: textarea
id: repro-steps
attributes:
Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# wluma

A tool for wlroots-based compositors that automatically adjusts screen brightness based on the screen contents and amount of ambient light around you.
A tool for Wayland compositors to automatically adjust screen brightness based on the screen contents and amount of ambient light around you.

## Supported screen capture protocols

With default config, `wluma` will automatically detect which protocols are supported, and pick the most appropriate one. See "configuration" section below for how to force a specific protocol.

The list of available protocols:

- `wlr-screencopy-unstable-v1` - supported by any `wlroots`-based compositors (e.g. `sway`), as well as Hyprland.
- requires `linux-dmabuf-v1` protocol to be supported as well.
- `wlr-export-dmabuf-unstable-v1` - supported by any `wlroots`-based compositors (e.g. `sway`).

Subscribe for [#121](https://github.com/maximbaz/wluma/issues/121) to see when the new `ext-image-capture-source-v1` protocol will land, which will potentially support any modern Wayland compositor once they implement the support as well.

## Idea

Expand All @@ -18,7 +30,7 @@ Simply launch `wluma` and continue adjusting your screen brightness as you usual

## Performance

The app has minimal impact on system resources and battery life even though it is able to monitor screen contents several times a second. This is achieved by using [export-dmabuf](https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/blob/master/unstable/wlr-export-dmabuf-unstable-v1.xml) Wayland protocol to get access to the screen contents and doing computations entirely on GPU using Vulkan API.
The app has minimal impact on system resources and battery life even though it is able to monitor screen contents several times a second. This is achieved by using Wayland protocols to get access to the screen contents and doing computations entirely on GPU using Vulkan API.

## Installation

Expand All @@ -31,7 +43,6 @@ Use one of the available packages and methods below:
- Alpine Linux: [wluma](https://pkgs.alpinelinux.org/packages?name=wluma) (from Alpine Edge; it will be available in stable branches since Alpine v3.16)
- Arch Linux: [wluma](https://aur.archlinux.org/packages/wluma/) or [wluma-git](https://aur.archlinux.org/packages/wluma-git/)
- NixOS: [wluma](https://search.nixos.org/packages?channel=unstable&show=wluma&from=0&size=50&sort=relevance&type=packages&query=wluma)
- Pre-compiled [Github release artifact](https://github.com/maximbaz/wluma/releases) (it is linked against Vulkan ICD loader, which you must install, and the latest available `glibc`, which might not work on your machine if your version is too old)
- Build the app yourself using the instructions below and install it via `sudo make install`

## Build
Expand Down Expand Up @@ -68,7 +79,7 @@ Each output is identified by compositor using model, manufacturer and serial num

The `name` field in the output config will be matched as a substring, so you are free to put simply `eDP-1`, or a serial number (if you have two identical external screens). It is your responsibility to make sure that the values you use match **uniquely** to one output only.

The `capturer` field will determine how screen contents will be captured. Currently supported values are `wlroots` (works only on wlroots-based Wayland compositors) and `none` (ignores screen contents and predicts brightness only based on ALS).
The `capturer` field will determine how screen contents will be captured. Currently supported values are `wayland` (works only on Wayland compositors that support protocols listed in the top) and `none` (ignores screen contents and predicts brightness only based on ALS). The value `wayland` will automatically choose the most appropriate protocol, but if you want to force a specific one, you can use `wlr-screencopy-unstable-v1` or `wlr-export-dmabuf-unstable-v1` as the value.

_Tip:_ run `wluma` with `RUST_LOG=debug` to see how your outputs are being identified, so that you can choose an appropriate `name` configuration value.

Expand All @@ -86,7 +97,7 @@ For more complex selectors, see [env_logger's documentation](https://docs.rs/env

Help is wanted and much appreciated! If you want to implement some of these, feel free to open an issue and I'll provide more details and try to help you along the way.

- Support for frames with custom DRM modifiers (e.g. multi-planar frames) is currently not implemented. This was recently [implemented in mesa](https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1466) and can finally be added to `wluma`. Until then, a workaround is to export `WLR_DRM_NO_MODIFIERS=1` before launching your wlroots-based compositor.
- Support for frames with custom DRM modifiers (e.g. multi-planar frames) is currently not implemented. This was [implemented in mesa](https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1466) and can finally be added to `wluma`. Until then, a workaround is to export `WLR_DRM_NO_MODIFIERS=1` before launching your wlroots-based compositor.
- Changing screen resolution while `wluma` is running is not supported yet, and should crash the app. Workaround: restart `wluma` after changing resolution.
- Plugging in a screen while `wluma` is running. Workaround: restart `wluma`.

Expand Down
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ thresholds = { 0 = "night", 20 = "dark", 80 = "dim", 250 = "normal", 500 = "brig
[[output.backlight]]
name = "eDP-1"
path = "/sys/class/backlight/intel_backlight"
capturer = "wlroots"
capturer = "wayland"

# [[output.ddcutil]]
# name = "Dell Inc. DELL P2415Q"
Expand Down
2 changes: 2 additions & 0 deletions src/config/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use std::collections::HashMap;
pub enum Capturer {
#[serde(rename = "wlroots")]
Wlroots,
#[serde(rename = "wayland")]
Wayland,
#[serde(rename = "wlr-export-dmabuf-unstable-v1")]
WlrExportDmabufUnstableV1,
#[serde(rename = "wlr-screencopy-unstable-v1")]
Expand Down
12 changes: 12 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ fn parse() -> Result<app::Config, toml::de::Error> {
capturer: match o.capturer {
file::Capturer::None => app::Capturer::None,
file::Capturer::Wlroots => {
log::warn!(
"Config value capturer=\"wlroots\" is deprecated, use capturer=\"wayland\" instead"
);
app::Capturer::Wayland(app::WaylandProtocol::Any)
}
file::Capturer::Wayland => {
app::Capturer::Wayland(app::WaylandProtocol::Any)
}
file::Capturer::WlrScreencopyUnstableV1 => {
Expand All @@ -54,6 +60,12 @@ fn parse() -> Result<app::Config, toml::de::Error> {
capturer: match o.capturer {
file::Capturer::None => app::Capturer::None,
file::Capturer::Wlroots => {
log::warn!(
"Config value capturer=\"wlroots\" is deprecated, use capturer=\"wayland\" instead"
);
app::Capturer::Wayland(app::WaylandProtocol::Any)
}
file::Capturer::Wayland => {
app::Capturer::Wayland(app::WaylandProtocol::Any)
}
file::Capturer::WlrScreencopyUnstableV1 => {
Expand Down
2 changes: 1 addition & 1 deletion src/frame/capturer/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl super::Capturer for Capturer {
} else if self.dmabuf_manager.is_some() {
WaylandProtocol::WlrExportDmabufUnstableV1
} else {
panic!("No supported Wayland protocols found to capture screen contents");
panic!("No supported Wayland protocols found to capture screen contents, set capturer=\"none\" in the config, or report an issue if you believe it's a mistake");
}
}
};
Expand Down

0 comments on commit ce02fd3

Please sign in to comment.