From a1a9933640980034783f5070d16d781f0f7cbee9 Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Fri, 9 Aug 2024 21:02:22 +0300 Subject: config: add layer option --- README.md | 1 + src/bar.rs | 2 +- src/config.rs | 24 +++++++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e50f1a..07abd64 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ blocks_overlap = 0.0 # Misc position = "top" # either "top" or "bottom" +layer = "top" # one of "top", "overlay", "bottom" or "background" hide_inactive_tags = true invert_touchpad_scrolling = true show_layout_name = true diff --git a/src/bar.rs b/src/bar.rs index 0fe5415..ed1a2c9 100644 --- a/src/bar.rs +++ b/src/bar.rs @@ -57,7 +57,7 @@ impl Bar { conn, surface, Some(output.wl), - zwlr_layer_shell_v1::Layer::Top, + state.shared_state.config.layer.into(), c"i3bar-river".into(), layer_surface_cb, ); diff --git a/src/config.rs b/src/config.rs index 72ebd5f..0863e1d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,5 @@ use crate::color::Color; -use crate::protocol::zwlr_layer_surface_v1; +use crate::protocol::{zwlr_layer_shell_v1, zwlr_layer_surface_v1}; use anyhow::{Context, Result}; use pangocairo::pango::FontDescription; use serde::{de, Deserialize}; @@ -41,6 +41,7 @@ pub struct Config { pub blocks_overlap: f64, // misc pub position: Position, + pub layer: Layer, pub hide_inactive_tags: bool, pub invert_touchpad_scrolling: bool, pub show_layout_name: bool, @@ -84,6 +85,7 @@ impl Default for Config { blocks_overlap: 0.0, position: Position::Top, + layer: Layer::Top, hide_inactive_tags: true, invert_touchpad_scrolling: true, show_layout_name: true, @@ -161,6 +163,26 @@ impl From for zwlr_layer_surface_v1::Anchor { } } +#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq)] +#[serde(rename_all = "lowercase")] +pub enum Layer { + Background, + Bottom, + Top, + Overlay, +} + +impl From for zwlr_layer_shell_v1::Layer { + fn from(layer: Layer) -> Self { + match layer { + Layer::Background => Self::Background, + Layer::Bottom => Self::Bottom, + Layer::Top => Self::Top, + Layer::Overlay => Self::Overlay, + } + } +} + #[derive(Debug, Deserialize)] pub struct WmConfig { pub river: RiverConfig, -- cgit v1.3.1