mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
[cfg-breaking] Move layout settings into their own scope
This commit is contained in:
@@ -75,11 +75,7 @@ input {
|
||||
position x=1280 y=0
|
||||
}
|
||||
|
||||
// Add lines like this to spawn processes at startup.
|
||||
// Note that running niri as a session supports xdg-desktop-autostart,
|
||||
// which may be more convenient to use.
|
||||
// spawn-at-startup "alacritty" "-e" "fish"
|
||||
|
||||
layout {
|
||||
// You can change how the focus ring looks.
|
||||
focus-ring {
|
||||
// Uncomment this line to disable the focus ring.
|
||||
@@ -106,18 +102,6 @@ border {
|
||||
inactive-color 80 80 80 255
|
||||
}
|
||||
|
||||
cursor {
|
||||
// Change the theme and size of the cursor as well as set the
|
||||
// `XCURSOR_THEME` and `XCURSOR_SIZE` env variables.
|
||||
// xcursor-theme "default"
|
||||
// xcursor-size 24
|
||||
}
|
||||
|
||||
// Uncomment this line to ask the clients to omit their client-side decorations if possible.
|
||||
// If the client will specifically ask for CSD, the request will be honored.
|
||||
// Additionally, clients will be informed that they are tiled, removing some rounded corners.
|
||||
// prefer-no-csd
|
||||
|
||||
// You can customize the widths that "switch-preset-column-width" (Mod+R) toggles between.
|
||||
preset-column-widths {
|
||||
// Proportion sets the width as a fraction of the output width, taking gaps into account.
|
||||
@@ -150,6 +134,24 @@ struts {
|
||||
// top 64
|
||||
// bottom 64
|
||||
}
|
||||
}
|
||||
|
||||
// Add lines like this to spawn processes at startup.
|
||||
// Note that running niri as a session supports xdg-desktop-autostart,
|
||||
// which may be more convenient to use.
|
||||
// spawn-at-startup "alacritty" "-e" "fish"
|
||||
|
||||
cursor {
|
||||
// Change the theme and size of the cursor as well as set the
|
||||
// `XCURSOR_THEME` and `XCURSOR_SIZE` env variables.
|
||||
// xcursor-theme "default"
|
||||
// xcursor-size 24
|
||||
}
|
||||
|
||||
// Uncomment this line to ask the clients to omit their client-side decorations if possible.
|
||||
// If the client will specifically ask for CSD, the request will be honored.
|
||||
// Additionally, clients will be informed that they are tiled, removing some rounded corners.
|
||||
// prefer-no-csd
|
||||
|
||||
// You can change the path where screenshots are saved.
|
||||
// A ~ at the front will be expanded to the home directory.
|
||||
|
||||
+41
-29
@@ -17,21 +17,11 @@ pub struct Config {
|
||||
#[knuffel(children(name = "spawn-at-startup"))]
|
||||
pub spawn_at_startup: Vec<SpawnAtStartup>,
|
||||
#[knuffel(child, default)]
|
||||
pub focus_ring: FocusRing,
|
||||
#[knuffel(child, default = default_border())]
|
||||
pub border: FocusRing,
|
||||
pub layout: Layout,
|
||||
#[knuffel(child, default)]
|
||||
pub prefer_no_csd: bool,
|
||||
#[knuffel(child, default)]
|
||||
pub cursor: Cursor,
|
||||
#[knuffel(child, unwrap(children), default)]
|
||||
pub preset_column_widths: Vec<PresetWidth>,
|
||||
#[knuffel(child)]
|
||||
pub default_column_width: Option<DefaultColumnWidth>,
|
||||
#[knuffel(child, unwrap(argument), default = 16)]
|
||||
pub gaps: u16,
|
||||
#[knuffel(child, default)]
|
||||
pub struts: Struts,
|
||||
#[knuffel(
|
||||
child,
|
||||
unwrap(argument),
|
||||
@@ -165,6 +155,22 @@ pub struct Mode {
|
||||
pub refresh: Option<f64>,
|
||||
}
|
||||
|
||||
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
|
||||
pub struct Layout {
|
||||
#[knuffel(child, default)]
|
||||
pub focus_ring: FocusRing,
|
||||
#[knuffel(child, default = default_border())]
|
||||
pub border: FocusRing,
|
||||
#[knuffel(child, unwrap(children), default)]
|
||||
pub preset_column_widths: Vec<PresetWidth>,
|
||||
#[knuffel(child)]
|
||||
pub default_column_width: Option<DefaultColumnWidth>,
|
||||
#[knuffel(child, unwrap(argument), default = 16)]
|
||||
pub gaps: u16,
|
||||
#[knuffel(child, default)]
|
||||
pub struts: Struts,
|
||||
}
|
||||
|
||||
#[derive(knuffel::Decode, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SpawnAtStartup {
|
||||
#[knuffel(arguments)]
|
||||
@@ -607,8 +613,7 @@ mod tests {
|
||||
mode "1920x1080@144"
|
||||
}
|
||||
|
||||
spawn-at-startup "alacritty" "-e" "fish"
|
||||
|
||||
layout {
|
||||
focus-ring {
|
||||
width 5
|
||||
active-color 0 100 200 255
|
||||
@@ -621,13 +626,6 @@ mod tests {
|
||||
inactive-color 255 200 100 0
|
||||
}
|
||||
|
||||
prefer-no-csd
|
||||
|
||||
cursor {
|
||||
xcursor-theme "breeze_cursors"
|
||||
xcursor-size 16
|
||||
}
|
||||
|
||||
preset-column-widths {
|
||||
proportion 0.25
|
||||
proportion 0.5
|
||||
@@ -644,6 +642,16 @@ mod tests {
|
||||
right 2
|
||||
top 3
|
||||
}
|
||||
}
|
||||
|
||||
spawn-at-startup "alacritty" "-e" "fish"
|
||||
|
||||
prefer-no-csd
|
||||
|
||||
cursor {
|
||||
xcursor-theme "breeze_cursors"
|
||||
xcursor-size 16
|
||||
}
|
||||
|
||||
screenshot-path "~/Screenshots/screenshot.png"
|
||||
|
||||
@@ -694,9 +702,7 @@ mod tests {
|
||||
refresh: Some(144.),
|
||||
}),
|
||||
}],
|
||||
spawn_at_startup: vec![SpawnAtStartup {
|
||||
command: vec!["alacritty".to_owned(), "-e".to_owned(), "fish".to_owned()],
|
||||
}],
|
||||
layout: Layout {
|
||||
focus_ring: FocusRing {
|
||||
off: false,
|
||||
width: 5,
|
||||
@@ -729,18 +735,15 @@ mod tests {
|
||||
a: 0,
|
||||
},
|
||||
},
|
||||
prefer_no_csd: true,
|
||||
cursor: Cursor {
|
||||
xcursor_theme: String::from("breeze_cursors"),
|
||||
xcursor_size: 16,
|
||||
},
|
||||
preset_column_widths: vec![
|
||||
PresetWidth::Proportion(0.25),
|
||||
PresetWidth::Proportion(0.5),
|
||||
PresetWidth::Fixed(960),
|
||||
PresetWidth::Fixed(1280),
|
||||
],
|
||||
default_column_width: Some(DefaultColumnWidth(vec![PresetWidth::Proportion(0.25)])),
|
||||
default_column_width: Some(DefaultColumnWidth(vec![PresetWidth::Proportion(
|
||||
0.25,
|
||||
)])),
|
||||
gaps: 8,
|
||||
struts: Struts {
|
||||
left: 1,
|
||||
@@ -748,6 +751,15 @@ mod tests {
|
||||
top: 3,
|
||||
bottom: 0,
|
||||
},
|
||||
},
|
||||
spawn_at_startup: vec![SpawnAtStartup {
|
||||
command: vec!["alacritty".to_owned(), "-e".to_owned(), "fish".to_owned()],
|
||||
}],
|
||||
prefer_no_csd: true,
|
||||
cursor: Cursor {
|
||||
xcursor_theme: String::from("breeze_cursors"),
|
||||
xcursor_size: 16,
|
||||
},
|
||||
screenshot_path: Some(String::from("~/Screenshots/screenshot.png")),
|
||||
binds: Binds(vec![
|
||||
Bind {
|
||||
|
||||
+7
-6
@@ -164,7 +164,8 @@ impl Default for Options {
|
||||
|
||||
impl Options {
|
||||
fn from_config(config: &Config) -> Self {
|
||||
let preset_column_widths = &config.preset_column_widths;
|
||||
let layout = &config.layout;
|
||||
let preset_column_widths = &layout.preset_column_widths;
|
||||
|
||||
let preset_widths = if preset_column_widths.is_empty() {
|
||||
Options::default().preset_widths
|
||||
@@ -178,17 +179,17 @@ impl Options {
|
||||
|
||||
// Missing default_column_width maps to Some(ColumnWidth::Proportion(0.5)),
|
||||
// while present, but empty, maps to None.
|
||||
let default_width = config
|
||||
let default_width = layout
|
||||
.default_column_width
|
||||
.as_ref()
|
||||
.map(|w| w.0.first().copied().map(ColumnWidth::from))
|
||||
.unwrap_or(Some(ColumnWidth::Proportion(0.5)));
|
||||
|
||||
Self {
|
||||
gaps: config.gaps.into(),
|
||||
struts: config.struts,
|
||||
focus_ring: config.focus_ring,
|
||||
border: config.border,
|
||||
gaps: layout.gaps.into(),
|
||||
struts: layout.struts,
|
||||
focus_ring: layout.focus_ring,
|
||||
border: layout.border,
|
||||
preset_widths,
|
||||
default_width,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user