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 | 56 | oxwm.bar.set_scheme_normal(colors.fg, colors.bg, 0x444444) |
| 57 | 57 | oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan) |
| 58 | 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 | 61 | oxwm.key.chord({ |
| 61 | 62 | { { modkey }, "Space" }, |
+8 −1 src/bar/bar.rs
| @@ -30,6 +30,7 @@ pub struct Bar { | ||
| 30 | 30 | scheme_normal: crate::ColorScheme, |
| 31 | 31 | scheme_occupied: crate::ColorScheme, |
| 32 | 32 | scheme_selected: crate::ColorScheme, |
| 33 | + scheme_urgent: crate::ColorScheme, | |
| 33 | 34 | } |
| 34 | 35 | |
| 35 | 36 | impl Bar { |
| @@ -136,6 +137,7 @@ impl Bar { | ||
| 136 | 137 | scheme_normal: config.scheme_normal, |
| 137 | 138 | scheme_occupied: config.scheme_occupied, |
| 138 | 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 | 185 | display: *mut x11::xlib::Display, |
| 184 | 186 | current_tags: u32, |
| 185 | 187 | occupied_tags: u32, |
| 188 | + urgent_tags: u32, | |
| 186 | 189 | draw_blocks: bool, |
| 187 | 190 | layout_symbol: &str, |
| 188 | 191 | keychord_indicator: Option<&str>, |
| @@ -218,11 +221,14 @@ impl Bar { | ||
| 218 | 221 | let tag_mask = 1 << tag_index; |
| 219 | 222 | let is_selected = (current_tags & tag_mask) != 0; |
| 220 | 223 | let is_occupied = (occupied_tags & tag_mask) != 0; |
| 224 | + let is_urgent = (urgent_tags & tag_mask) != 0; | |
| 221 | 225 | |
| 222 | 226 | let tag_width = self.tag_widths[tag_index]; |
| 223 | 227 | |
| 224 | 228 | let scheme = if is_selected { |
| 225 | 229 | &self.scheme_selected |
| 230 | + } else if is_urgent { | |
| 231 | + &self.scheme_urgent | |
| 226 | 232 | } else if is_occupied { |
| 227 | 233 | &self.scheme_occupied |
| 228 | 234 | } else { |
| @@ -238,7 +244,7 @@ impl Bar { | ||
| 238 | 244 | self.font_draw |
| 239 | 245 | .draw_text(font, scheme.foreground, text_x, text_y, tag); |
| 240 | 246 | |
| 241 | - if is_selected { | |
| 247 | + if is_selected || is_urgent { | |
| 242 | 248 | let font_height = font.height(); |
| 243 | 249 | let underline_height = font_height / 8; |
| 244 | 250 | let bottom_gap = 3; |
| @@ -406,6 +412,7 @@ impl Bar { | ||
| 406 | 412 | self.scheme_normal = config.scheme_normal; |
| 407 | 413 | self.scheme_occupied = config.scheme_occupied; |
| 408 | 414 | self.scheme_selected = config.scheme_selected; |
| 415 | + self.scheme_urgent = config.scheme_urgent; | |
| 409 | 416 | |
| 410 | 417 | self.status_text.clear(); |
| 411 | 418 | self.needs_redraw = true; |
+1 −0 src/config/lua.rs
| @@ -48,6 +48,7 @@ pub fn parse_lua_config( | ||
| 48 | 48 | scheme_normal: builder_data.scheme_normal, |
| 49 | 49 | scheme_occupied: builder_data.scheme_occupied, |
| 50 | 50 | scheme_selected: builder_data.scheme_selected, |
| 51 | + scheme_urgent: builder_data.scheme_urgent, | |
| 51 | 52 | autostart: builder_data.autostart, |
| 52 | 53 | auto_tile: builder_data.auto_tile, |
| 53 | 54 | path: None, |
+22 −0 src/config/lua_api.rs
| @@ -32,6 +32,7 @@ pub struct ConfigBuilder { | ||
| 32 | 32 | pub scheme_normal: ColorScheme, |
| 33 | 33 | pub scheme_occupied: ColorScheme, |
| 34 | 34 | pub scheme_selected: ColorScheme, |
| 35 | + pub scheme_urgent: ColorScheme, | |
| 35 | 36 | pub autostart: Vec<String>, |
| 36 | 37 | pub auto_tile: bool, |
| 37 | 38 | } |
| @@ -72,6 +73,11 @@ impl Default for ConfigBuilder { | ||
| 72 | 73 | background: 0x000000, |
| 73 | 74 | underline: 0x444444, |
| 74 | 75 | }, |
| 76 | + scheme_urgent: ColorScheme { | |
| 77 | + foreground: 0xff5555, | |
| 78 | + background: 0x000000, | |
| 79 | + underline: 0xff5555, | |
| 80 | + }, | |
| 75 | 81 | autostart: Vec::new(), |
| 76 | 82 | auto_tile: false, |
| 77 | 83 | } |
| @@ -705,6 +711,21 @@ fn register_bar_module( | ||
| 705 | 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 | 729 | bar_table.set("set_font", set_font)?; |
| 709 | 730 | bar_table.set("block", block_table)?; |
| 710 | 731 | bar_table.set("add_block", add_block)?; // Deprecated, for backwards compatibility |
| @@ -712,6 +733,7 @@ fn register_bar_module( | ||
| 712 | 733 | bar_table.set("set_scheme_normal", set_scheme_normal)?; |
| 713 | 734 | bar_table.set("set_scheme_occupied", set_scheme_occupied)?; |
| 714 | 735 | bar_table.set("set_scheme_selected", set_scheme_selected)?; |
| 736 | + bar_table.set("set_scheme_urgent", set_scheme_urgent)?; | |
| 715 | 737 | parent.set("bar", bar_table)?; |
| 716 | 738 | Ok(()) |
| 717 | 739 | } |
+6 −0 src/lib.rs
| @@ -99,6 +99,7 @@ pub struct Config { | ||
| 99 | 99 | pub scheme_normal: ColorScheme, |
| 100 | 100 | pub scheme_occupied: ColorScheme, |
| 101 | 101 | pub scheme_selected: ColorScheme, |
| 102 | + pub scheme_urgent: ColorScheme, | |
| 102 | 103 | |
| 103 | 104 | pub autostart: Vec<String>, |
| 104 | 105 | pub auto_tile: bool, |
| @@ -345,6 +346,11 @@ impl Default for Config { | ||
| 345 | 346 | background: 0x1a1b26, |
| 346 | 347 | underline: 0xad8ee6, |
| 347 | 348 | }, |
| 349 | + scheme_urgent: ColorScheme { | |
| 350 | + foreground: 0xff5555, | |
| 351 | + background: 0x1a1b26, | |
| 352 | + underline: 0xff5555, | |
| 353 | + }, | |
| 348 | 354 | autostart: vec![], |
| 349 | 355 | auto_tile: false, |
| 350 | 356 | } |
+9 −0 src/window_manager.rs
| @@ -670,9 +670,13 @@ impl WindowManager { | ||
| 670 | 670 | for (monitor_index, monitor) in self.monitors.iter().enumerate() { |
| 671 | 671 | if let Some(bar) = self.bars.get_mut(monitor_index) { |
| 672 | 672 | let mut occupied_tags: TagMask = 0; |
| 673 | + let mut urgent_tags: TagMask = 0; | |
| 673 | 674 | for client in self.clients.values() { |
| 674 | 675 | if client.monitor_index == monitor_index { |
| 675 | 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 | 688 | self.display, |
| 685 | 689 | monitor.tagset[monitor.selected_tags_index], |
| 686 | 690 | occupied_tags, |
| 691 | + urgent_tags, | |
| 687 | 692 | draw_blocks, |
| 688 | 693 | &layout_symbol, |
| 689 | 694 | keychord_indicator.as_deref(), |
| @@ -2067,6 +2072,10 @@ impl WindowManager { | ||
| 2067 | 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 | 2079 | let monitor_idx = self |
| 2071 | 2080 | .clients |
| 2072 | 2081 | .get(&win) |
+2 −0 templates/config.lua
| @@ -169,6 +169,8 @@ oxwm.bar.set_scheme_normal(colors.fg, colors.bg, "#444444") | ||
| 169 | 169 | oxwm.bar.set_scheme_occupied(colors.cyan, colors.bg, colors.cyan) |
| 170 | 170 | -- Currently selected tag |
| 171 | 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 | 176 | -- Keybindings |
+6 −0 templates/oxwm.lua
| @@ -309,6 +309,12 @@ function oxwm.bar.set_scheme_occupied(foreground, background, underline) end | ||
| 309 | 309 | ---@param underline string|integer Underline color |
| 310 | 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 | 318 | ---Add an autostart command |
| 313 | 319 | ---@param cmd string Command to run at startup |
| 314 | 320 | function oxwm.autostart(cmd) end |