aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-05-06 17:12:07 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-05-06 17:34:40 +0300
commit497f1864221e831a0504a8b3cf546864d3027732 (patch)
tree9fa98e16cb9d161b0cff3b363edf6bade07ba2ea
parent3e31c134a602dd876f2b446071e5802fa4a0c3ec (diff)
downloadniri-497f1864221e831a0504a8b3cf546864d3027732.tar.gz
niri-497f1864221e831a0504a8b3cf546864d3027732.tar.bz2
niri-497f1864221e831a0504a8b3cf546864d3027732.zip
Add layout background-color setting
-rw-r--r--niri-config/src/lib.rs29
-rw-r--r--src/niri.rs13
-rw-r--r--wiki/Configuration:-Layout.md16
-rw-r--r--wiki/Configuration:-Outputs.md2
-rw-r--r--wiki/Overview.md24
5 files changed, 69 insertions, 15 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index d418b4ff..257c78ed 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -448,8 +448,8 @@ pub struct Output {
pub variable_refresh_rate: Option<Vrr>,
#[knuffel(child)]
pub focus_at_startup: bool,
- #[knuffel(child, default = DEFAULT_BACKGROUND_COLOR)]
- pub background_color: Color,
+ #[knuffel(child)]
+ pub background_color: Option<Color>,
#[knuffel(child)]
pub backdrop_color: Option<Color>,
}
@@ -479,7 +479,7 @@ impl Default for Output {
position: None,
mode: None,
variable_refresh_rate: None,
- background_color: DEFAULT_BACKGROUND_COLOR,
+ background_color: None,
backdrop_color: None,
}
}
@@ -541,6 +541,8 @@ pub struct Layout {
pub gaps: FloatOrInt<0, 65535>,
#[knuffel(child, default)]
pub struts: Struts,
+ #[knuffel(child, default = DEFAULT_BACKGROUND_COLOR)]
+ pub background_color: Color,
}
impl Default for Layout {
@@ -560,6 +562,7 @@ impl Default for Layout {
gaps: FloatOrInt(16.),
struts: Default::default(),
preset_window_heights: Default::default(),
+ background_color: DEFAULT_BACKGROUND_COLOR,
}
}
}
@@ -4279,12 +4282,14 @@ mod tests {
},
),
focus_at_startup: true,
- background_color: Color {
- r: 0.09803922,
- g: 0.09803922,
- b: 0.4,
- a: 1.0,
- },
+ background_color: Some(
+ Color {
+ r: 0.09803922,
+ g: 0.09803922,
+ b: 0.4,
+ a: 1.0,
+ },
+ ),
backdrop_color: None,
},
],
@@ -4501,6 +4506,12 @@ mod tests {
0.0,
),
},
+ background_color: Color {
+ r: 0.25,
+ g: 0.25,
+ b: 0.25,
+ a: 1.0,
+ },
},
prefer_no_csd: true,
cursor: Cursor {
diff --git a/src/niri.rs b/src/niri.rs
index 4aa353d1..43a582b6 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -15,7 +15,7 @@ use anyhow::{bail, ensure, Context};
use calloop::futures::Scheduler;
use niri_config::{
Config, FloatOrInt, Key, Modifiers, OutputName, PreviewRender, TrackLayout,
- WarpMouseToFocusMode, WorkspaceReference, DEFAULT_BACKGROUND_COLOR,
+ WarpMouseToFocusMode, WorkspaceReference,
};
use smithay::backend::allocator::Fourcc;
use smithay::backend::input::Keycode;
@@ -1416,6 +1416,9 @@ impl State {
if config.overview.backdrop_color != old_config.overview.backdrop_color {
output_config_changed = true;
}
+ if config.layout.background_color != old_config.layout.background_color {
+ output_config_changed = true;
+ }
*old_config = config;
@@ -1529,8 +1532,8 @@ impl State {
}
let background_color = config
- .map(|c| c.background_color)
- .unwrap_or(DEFAULT_BACKGROUND_COLOR)
+ .and_then(|c| c.background_color)
+ .unwrap_or(full_config.layout.background_color)
.to_array_unpremul();
let background_color = Color32F::from(background_color);
@@ -2725,8 +2728,8 @@ impl Niri {
.unwrap_or(Transform::Normal);
let background_color = c
- .map(|c| c.background_color)
- .unwrap_or(DEFAULT_BACKGROUND_COLOR)
+ .and_then(|c| c.background_color)
+ .unwrap_or(config.layout.background_color)
.to_array_unpremul();
let mut backdrop_color = c
diff --git a/wiki/Configuration:-Layout.md b/wiki/Configuration:-Layout.md
index 4f2cc112..c76bf82e 100644
--- a/wiki/Configuration:-Layout.md
+++ b/wiki/Configuration:-Layout.md
@@ -11,6 +11,7 @@ layout {
always-center-single-column
empty-workspace-above-first
default-column-display "tabbed"
+ background-color "#003300"
preset-column-widths {
proportion 0.33333
@@ -526,3 +527,18 @@ layout {
}
}
```
+
+### `background-color`
+
+<sup>Since: next release</sup>
+
+Set the default background color that niri draws for workspaces.
+This is visible when you're not using any background tools like swaybg.
+
+```kdl
+layout {
+ background-color "#003300"
+}
+```
+
+You can also set the color per-output [in the output config](./Configuration:-Outputs.md#background-color).
diff --git a/wiki/Configuration:-Outputs.md b/wiki/Configuration:-Outputs.md
index 0a86395e..c4e0ab57 100644
--- a/wiki/Configuration:-Outputs.md
+++ b/wiki/Configuration:-Outputs.md
@@ -210,7 +210,7 @@ output "HDMI-A-1" {
Set the backdrop color that niri draws for this output.
This is visible between workspaces or in the overview.
-The alpha channel for this color will be ignored.
+<sup>Until: next release</sup> The alpha channel for this color will be ignored.
```kdl
output "HDMI-A-1" {
diff --git a/wiki/Overview.md b/wiki/Overview.md
index 5c9bae11..aa12b194 100644
--- a/wiki/Overview.md
+++ b/wiki/Overview.md
@@ -76,3 +76,27 @@ This will only work for *background* layer surfaces that ignore exclusive zones
You can run two different wallpaper tools (like swaybg and swww), one for the backdrop and one for the normal workspace background.
This way you could set the backdrop one to a blurred version of the wallpaper for a nice effect.
+
+You can also combine this with a transparent background color if you don't like the wallpaper moving together with workspaces:
+
+```kdl
+// Make the wallpaper stationary, rather than moving with workspaces.
+layer-rule {
+ // This is for swaybg; change for other wallpaper tools.
+ // Find the right namespace by running niri msg layers.
+ match namespace="^wallpaper$"
+ place-within-backdrop true
+}
+
+// Set transparent workspace background color.
+layout {
+ background-color "transparent"
+}
+
+// Optionally, disable the workspace shadows in the overview.
+overview {
+ workspace-shadow {
+ off
+ }
+}
+```