From 432b6d66d4635fa70105c2ae6b6e470d0263c6cd Mon Sep 17 00:00:00 2001 From: MaxVerevkin Date: Wed, 28 Jun 2023 10:54:33 +0300 Subject: Add an option to show any number of tags (not only the first 9) --- README.md | 56 ++++++++++++++++++++++++++----------------- src/config.rs | 25 ++++++++++++++++--- src/wm_info_provider/river.rs | 3 ++- 3 files changed, 58 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index f1cf446..7cc8a39 100644 --- a/README.md +++ b/README.md @@ -46,36 +46,48 @@ riverctl spawn i3bar-river The configuration file should be stored in `$XDG_CONFIG_HOME/i3bar-river/config.toml` or `~/.config/i3bar-river/config.toml`. -Example configuration (every parameter is optional): +The default configuration (every parameter is optional): ```toml -background = "#282828" -color = "#ffffff" -separator = "#9a8a62" -tag_fg = "#d79921" -tag_bg = "#282828" -tag_focused_fg = "#1d2021" -tag_focused_bg = "#689d68" -tag_urgent_fg = "#282828" -tag_urgent_bg = "#cc241d" -tag_inactive_fg = "#d79921" -tag_inactive_bg = "#282828" -font = "JetBrainsMono Nerd Font 10" -height = 20 +# The status generator command. +# Optional: with no status generator the bar will display only tags and layout name. +# command = "your command here" + +# Colors +background = "0x282828ff" +color = "0xffffffff" +separator = "0x9a8a62ff" +tag_fg = "0xd79921ff" +tag_bg = "0x282828ff" +tag_focused_fg = "0x1d2021ff" +tag_focused_bg = "0x689d68ff" +tag_urgent_fg = "0x282828ff" +tag_urgent_bg = "0xcc241dff" +tag_inactive_fg = "0xd79921ff" +tag_inactive_bg = "0x282828ff" + +# The font and various sizes +font = "monospace 10" +height = 24 margin_top = 0 margin_bottom = 0 margin_left = 0 margin_right = 0 -separator_width = 0 -tags_r = 6 -tags_padding = 25 -blocks_r = 6 -blocks_overlap = 0 -command = "i3status-rs" -position = "top" +separator_width = 2.0 +tags_r = 0.0 +tags_padding = 25.0 +blocks_r = 0.0 +blocks_overlap = 0.0 + +# Misc +position = "top" # either "top" or "bottom" hide_inactive_tags = true invert_touchpad_scrolling = true -show_layout_name = false +show_layout_name = true + +# WM-specific options +[wm.river] +max_tag = 9 # Show only the first nine tags ``` ## How progressive short mode and rounded corners work diff --git a/src/config.rs b/src/config.rs index 98d7eb1..8465eee 100644 --- a/src/config.rs +++ b/src/config.rs @@ -11,6 +11,8 @@ use std::{env, fmt}; #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields, default)] pub struct Config { + // command + pub command: Option, // colors pub background: Color, pub color: Color, @@ -35,18 +37,20 @@ pub struct Config { pub tags_padding: f64, pub blocks_r: f64, pub blocks_overlap: f64, - // command - pub command: Option, // misc pub position: Position, pub hide_inactive_tags: bool, pub invert_touchpad_scrolling: bool, pub show_layout_name: bool, + // wm-specific + pub wm: WmConfig, } impl Default for Config { fn default() -> Self { Self { + command: None, + // A kind of gruvbox theme background: Color::from_rgba_hex(0x282828ff), color: Color::from_rgba_hex(0xffffffff), @@ -59,6 +63,7 @@ impl Default for Config { tag_urgent_bg: Color::from_rgba_hex(0xcc241dff), tag_inactive_fg: Color::from_rgba_hex(0xd79921ff), tag_inactive_bg: Color::from_rgba_hex(0x282828ff), + font: Font::new("monospace 10"), height: 24, margin_top: 0, @@ -70,11 +75,15 @@ impl Default for Config { tags_padding: 25.0, blocks_r: 0.0, blocks_overlap: 0.0, - command: None, + position: Position::Top, hide_inactive_tags: true, invert_touchpad_scrolling: true, show_layout_name: true, + + wm: WmConfig { + river: RiverConfig { max_tag: 9 }, + }, } } } @@ -125,6 +134,16 @@ impl From for zwlr_layer_surface_v1::Anchor { } } +#[derive(Debug, Deserialize)] +pub struct WmConfig { + pub river: RiverConfig, +} + +#[derive(Debug, Deserialize)] +pub struct RiverConfig { + pub max_tag: u8, +} + #[derive(Debug)] pub struct Font(pub FontDescription); diff --git a/src/wm_info_provider/river.rs b/src/wm_info_provider/river.rs index 82fa5d8..e708930 100644 --- a/src/wm_info_provider/river.rs +++ b/src/wm_info_provider/river.rs @@ -91,6 +91,7 @@ fn output_status_cb( event: zriver_output_status_v1::Event, ) { let WmInfoProvider::River(river) = &mut state.shared_state.wm_info_provider else { unreachable!() }; + let max_tag = state.shared_state.config.wm.river.max_tag.min(32); let status = river .output_statuses @@ -114,7 +115,7 @@ fn output_status_cb( let info = WmInfo { layout_name: status.layout_name.clone(), - tags: (1..10) + tags: (1..=max_tag) .map(|tag| Tag { name: tag.to_string(), is_focused: status.focused_tags & (1 << (tag - 1)) != 0, -- cgit v1.3.1