mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Add layout background-color setting
This commit is contained in:
+20
-9
@@ -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 {
|
||||
|
||||
+8
-5
@@ -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
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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" {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user