Added urgent tags, very similar to DWM logic.
Browse files
+1 −0 resources/test-config.lua
| @@ -56,6 +56,7 @@ oxwm.bar.set_font("JetBrainsMono Nerd Font:style=Bold:size=12") | |||
| 56 | oxwm.bar.set_scheme_normal(colors.fg, colors.bg, 0x444444) | 56 | oxwm.bar.set_scheme_normal(colors.fg, colors.bg, 0x444444) |
| 57 | oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan) | 57 | oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan) |
| 58 | oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple) | 58 | oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple) |
| 59 | +oxwm.bar.set_scheme_urgent(colors.red, colors.bg, colors.red) | ||
| 59 | 60 | ||
| 60 | oxwm.key.chord({ | 61 | oxwm.key.chord({ |
| 61 | { { modkey }, "Space" }, | 62 | { { modkey }, "Space" }, |
+8 −1 src/bar/bar.rs
| @@ -30,6 +30,7 @@ pub struct Bar { | |||
| 30 | scheme_normal: crate::ColorScheme, | 30 | scheme_normal: crate::ColorScheme, |
| 31 | scheme_occupied: crate::ColorScheme, | 31 | scheme_occupied: crate::ColorScheme, |
| 32 | scheme_selected: crate::ColorScheme, | 32 | scheme_selected: crate::ColorScheme, |
| 33 | + scheme_urgent: crate::ColorScheme, | ||
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | impl Bar { | 36 | impl Bar { |
| @@ -136,6 +137,7 @@ impl Bar { | |||
| 136 | scheme_normal: config.scheme_normal, | 137 | scheme_normal: config.scheme_normal, |
| 137 | scheme_occupied: config.scheme_occupied, | 138 | scheme_occupied: config.scheme_occupied, |
| 138 | scheme_selected: config.scheme_selected, | 139 | scheme_selected: config.scheme_selected, |
| 140 | + scheme_urgent: config.scheme_urgent, | ||
| 139 | }) | 141 | }) |
| 140 | } | 142 | } |
| 141 | 143 | ||
| @@ -183,6 +185,7 @@ impl Bar { | |||
| 183 | display: *mut x11::xlib::Display, | 185 | display: *mut x11::xlib::Display, |
| 184 | current_tags: u32, | 186 | current_tags: u32, |
| 185 | occupied_tags: u32, | 187 | occupied_tags: u32, |
| 188 | + urgent_tags: u32, | ||
| 186 | draw_blocks: bool, | 189 | draw_blocks: bool, |
| 187 | layout_symbol: &str, | 190 | layout_symbol: &str, |
| 188 | keychord_indicator: Option<&str>, | 191 | keychord_indicator: Option<&str>, |
| @@ -218,11 +221,14 @@ impl Bar { | |||
| 218 | let tag_mask = 1 << tag_index; | 221 | let tag_mask = 1 << tag_index; |
| 219 | let is_selected = (current_tags & tag_mask) != 0; | 222 | let is_selected = (current_tags & tag_mask) != 0; |
| 220 | let is_occupied = (occupied_tags & tag_mask) != 0; | 223 | let is_occupied = (occupied_tags & tag_mask) != 0; |
| 224 | + let is_urgent = (urgent_tags & tag_mask) != 0; | ||
| 221 | 225 | ||
| 222 | let tag_width = self.tag_widths[tag_index]; | 226 | let tag_width = self.tag_widths[tag_index]; |
| 223 | 227 | ||
| 224 | let scheme = if is_selected { | 228 | let scheme = if is_selected { |
| 225 | &self.scheme_selected | 229 | &self.scheme_selected |
| 230 | + } else if is_urgent { | ||
| 231 | + &self.scheme_urgent | ||
| 226 | } else if is_occupied { | 232 | } else if is_occupied { |
| 227 | &self.scheme_occupied | 233 | &self.scheme_occupied |
| 228 | } else { | 234 | } else { |
| @@ -238,7 +244,7 @@ impl Bar { | |||
| 238 | self.font_draw | 244 | self.font_draw |
| 239 | .draw_text(font, scheme.foreground, text_x, text_y, tag); | 245 | .draw_text(font, scheme.foreground, text_x, text_y, tag); |
| 240 | 246 | ||
| 241 | - if is_selected { | 247 | + if is_selected || is_urgent { |
| 242 | let font_height = font.height(); | 248 | let font_height = font.height(); |
| 243 | let underline_height = font_height / 8; | 249 | let underline_height = font_height / 8; |
| 244 | let bottom_gap = 3; | 250 | let bottom_gap = 3; |
| @@ -406,6 +412,7 @@ impl Bar { | |||
| 406 | self.scheme_normal = config.scheme_normal; | 412 | self.scheme_normal = config.scheme_normal; |
| 407 | self.scheme_occupied = config.scheme_occupied; | 413 | self.scheme_occupied = config.scheme_occupied; |
| 408 | self.scheme_selected = config.scheme_selected; | 414 | self.scheme_selected = config.scheme_selected; |
| 415 | + self.scheme_urgent = config.scheme_urgent; | ||
| 409 | 416 | ||
| 410 | self.status_text.clear(); | 417 | self.status_text.clear(); |
| 411 | self.needs_redraw = true; | 418 | self.needs_redraw = true; |
+1 −0 src/config/lua.rs
| @@ -48,6 +48,7 @@ pub fn parse_lua_config( | |||
| 48 | scheme_normal: builder_data.scheme_normal, | 48 | scheme_normal: builder_data.scheme_normal, |
| 49 | scheme_occupied: builder_data.scheme_occupied, | 49 | scheme_occupied: builder_data.scheme_occupied, |
| 50 | scheme_selected: builder_data.scheme_selected, | 50 | scheme_selected: builder_data.scheme_selected, |
| 51 | + scheme_urgent: builder_data.scheme_urgent, | ||
| 51 | autostart: builder_data.autostart, | 52 | autostart: builder_data.autostart, |
| 52 | auto_tile: builder_data.auto_tile, | 53 | auto_tile: builder_data.auto_tile, |
| 53 | path: None, | 54 | path: None, |
+22 −0 src/config/lua_api.rs
| @@ -32,6 +32,7 @@ pub struct ConfigBuilder { | |||
| 32 | pub scheme_normal: ColorScheme, | 32 | pub scheme_normal: ColorScheme, |
| 33 | pub scheme_occupied: ColorScheme, | 33 | pub scheme_occupied: ColorScheme, |
| 34 | pub scheme_selected: ColorScheme, | 34 | pub scheme_selected: ColorScheme, |
| 35 | + pub scheme_urgent: ColorScheme, | ||
| 35 | pub autostart: Vec<String>, | 36 | pub autostart: Vec<String>, |
| 36 | pub auto_tile: bool, | 37 | pub auto_tile: bool, |
| 37 | } | 38 | } |
| @@ -72,6 +73,11 @@ impl Default for ConfigBuilder { | |||
| 72 | background: 0x000000, | 73 | background: 0x000000, |
| 73 | underline: 0x444444, | 74 | underline: 0x444444, |
| 74 | }, | 75 | }, |
| 76 | + scheme_urgent: ColorScheme { | ||
| 77 | + foreground: 0xff5555, | ||
| 78 | + background: 0x000000, | ||
| 79 | + underline: 0xff5555, | ||
| 80 | + }, | ||
| 75 | autostart: Vec::new(), | 81 | autostart: Vec::new(), |
| 76 | auto_tile: false, | 82 | auto_tile: false, |
| 77 | } | 83 | } |
| @@ -705,6 +711,21 @@ fn register_bar_module( | |||
| 705 | Ok(()) | 711 | Ok(()) |
| 706 | })?; | 712 | })?; |
| 707 | 713 | ||
| 714 | + let builder_clone = builder.clone(); | ||
| 715 | + let set_scheme_urgent = | ||
| 716 | + lua.create_function(move |_, (fg, bg, ul): (Value, Value, Value)| { | ||
| 717 | + let foreground = parse_color_value(fg)?; | ||
| 718 | + let background = parse_color_value(bg)?; | ||
| 719 | + let underline = parse_color_value(ul)?; | ||
| 720 | + | ||
| 721 | + builder_clone.borrow_mut().scheme_urgent = ColorScheme { | ||
| 722 | + foreground, | ||
| 723 | + background, | ||
| 724 | + underline, | ||
| 725 | + }; | ||
| 726 | + Ok(()) | ||
| 727 | + })?; | ||
| 728 | + | ||
| 708 | bar_table.set("set_font", set_font)?; | 729 | bar_table.set("set_font", set_font)?; |
| 709 | bar_table.set("block", block_table)?; | 730 | bar_table.set("block", block_table)?; |
| 710 | bar_table.set("add_block", add_block)?; // Deprecated, for backwards compatibility | 731 | bar_table.set("add_block", add_block)?; // Deprecated, for backwards compatibility |
| @@ -712,6 +733,7 @@ fn register_bar_module( | |||
| 712 | bar_table.set("set_scheme_normal", set_scheme_normal)?; | 733 | bar_table.set("set_scheme_normal", set_scheme_normal)?; |
| 713 | bar_table.set("set_scheme_occupied", set_scheme_occupied)?; | 734 | bar_table.set("set_scheme_occupied", set_scheme_occupied)?; |
| 714 | bar_table.set("set_scheme_selected", set_scheme_selected)?; | 735 | bar_table.set("set_scheme_selected", set_scheme_selected)?; |
| 736 | + bar_table.set("set_scheme_urgent", set_scheme_urgent)?; | ||
| 715 | parent.set("bar", bar_table)?; | 737 | parent.set("bar", bar_table)?; |
| 716 | Ok(()) | 738 | Ok(()) |
| 717 | } | 739 | } |
+6 −0 src/lib.rs
| @@ -99,6 +99,7 @@ pub struct Config { | |||
| 99 | pub scheme_normal: ColorScheme, | 99 | pub scheme_normal: ColorScheme, |
| 100 | pub scheme_occupied: ColorScheme, | 100 | pub scheme_occupied: ColorScheme, |
| 101 | pub scheme_selected: ColorScheme, | 101 | pub scheme_selected: ColorScheme, |
| 102 | + pub scheme_urgent: ColorScheme, | ||
| 102 | 103 | ||
| 103 | pub autostart: Vec<String>, | 104 | pub autostart: Vec<String>, |
| 104 | pub auto_tile: bool, | 105 | pub auto_tile: bool, |
| @@ -345,6 +346,11 @@ impl Default for Config { | |||
| 345 | background: 0x1a1b26, | 346 | background: 0x1a1b26, |
| 346 | underline: 0xad8ee6, | 347 | underline: 0xad8ee6, |
| 347 | }, | 348 | }, |
| 349 | + scheme_urgent: ColorScheme { | ||
| 350 | + foreground: 0xff5555, | ||
| 351 | + background: 0x1a1b26, | ||
| 352 | + underline: 0xff5555, | ||
| 353 | + }, | ||
| 348 | autostart: vec![], | 354 | autostart: vec![], |
| 349 | auto_tile: false, | 355 | auto_tile: false, |
| 350 | } | 356 | } |
+9 −0 src/window_manager.rs
| @@ -670,9 +670,13 @@ impl WindowManager { | |||
| 670 | for (monitor_index, monitor) in self.monitors.iter().enumerate() { | 670 | for (monitor_index, monitor) in self.monitors.iter().enumerate() { |
| 671 | if let Some(bar) = self.bars.get_mut(monitor_index) { | 671 | if let Some(bar) = self.bars.get_mut(monitor_index) { |
| 672 | let mut occupied_tags: TagMask = 0; | 672 | let mut occupied_tags: TagMask = 0; |
| 673 | + let mut urgent_tags: TagMask = 0; | ||
| 673 | for client in self.clients.values() { | 674 | for client in self.clients.values() { |
| 674 | if client.monitor_index == monitor_index { | 675 | if client.monitor_index == monitor_index { |
| 675 | occupied_tags |= client.tags; | 676 | occupied_tags |= client.tags; |
| 677 | + if client.is_urgent { | ||
| 678 | + urgent_tags |= client.tags; | ||
| 679 | + } | ||
| 676 | } | 680 | } |
| 677 | } | 681 | } |
| 678 | 682 | ||
| @@ -684,6 +688,7 @@ impl WindowManager { | |||
| 684 | self.display, | 688 | self.display, |
| 685 | monitor.tagset[monitor.selected_tags_index], | 689 | monitor.tagset[monitor.selected_tags_index], |
| 686 | occupied_tags, | 690 | occupied_tags, |
| 691 | + urgent_tags, | ||
| 687 | draw_blocks, | 692 | draw_blocks, |
| 688 | &layout_symbol, | 693 | &layout_symbol, |
| 689 | keychord_indicator.as_deref(), | 694 | keychord_indicator.as_deref(), |
| @@ -2067,6 +2072,10 @@ impl WindowManager { | |||
| 2067 | return Ok(()); | 2072 | return Ok(()); |
| 2068 | } | 2073 | } |
| 2069 | 2074 | ||
| 2075 | + if self.clients.get(&win).is_some_and(|c| c.is_urgent) { | ||
| 2076 | + self.set_urgent(win, false)?; | ||
| 2077 | + } | ||
| 2078 | + | ||
| 2070 | let monitor_idx = self | 2079 | let monitor_idx = self |
| 2071 | .clients | 2080 | .clients |
| 2072 | .get(&win) | 2081 | .get(&win) |
+2 −0 templates/config.lua
| @@ -169,6 +169,8 @@ oxwm.bar.set_scheme_normal(colors.fg, colors.bg, "#444444") | |||
| 169 | oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan) | 169 | oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan) |
| 170 | -- Currently selected tag | 170 | -- Currently selected tag |
| 171 | oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple) | 171 | oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple) |
| 172 | +-- Urgent tags (windows requesting attention) | ||
| 173 | +oxwm.bar.set_scheme_urgent(colors.red, colors.bg, colors.red) | ||
| 172 | 174 | ||
| 173 | ------------------------------------------------------------------------------- | 175 | ------------------------------------------------------------------------------- |
| 174 | -- Keybindings | 176 | -- Keybindings |
+6 −0 templates/oxwm.lua
| @@ -309,6 +309,12 @@ function oxwm.bar.set_scheme_occupied(foreground, background, underline) end | |||
| 309 | ---@param underline string|integer Underline color | 309 | ---@param underline string|integer Underline color |
| 310 | function oxwm.bar.set_scheme_selected(foreground, background, underline) end | 310 | function oxwm.bar.set_scheme_selected(foreground, background, underline) end |
| 311 | 311 | ||
| 312 | +---Set urgent tag color scheme (tags with urgent windows) | ||
| 313 | +---@param foreground string|integer Foreground color | ||
| 314 | +---@param background string|integer Background color | ||
| 315 | +---@param underline string|integer Underline color | ||
| 316 | +function oxwm.bar.set_scheme_urgent(foreground, background, underline) end | ||
| 317 | + | ||
| 312 | ---Add an autostart command | 318 | ---Add an autostart command |
| 313 | ---@param cmd string Command to run at startup | 319 | ---@param cmd string Command to run at startup |
| 314 | function oxwm.autostart(cmd) end | 320 | function oxwm.autostart(cmd) end |