Added tabbed mode, fixed bug where nixos read only directory caused crash every launch, added sane default comments for default config file.
Browse files
+1 −1 Cargo.lock
| @@ -291,7 +291,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" | |||
| 291 | 291 | ||
| 292 | [[package]] | 292 | [[package]] |
| 293 | name = "oxwm" | 293 | name = "oxwm" |
| 294 | -version = "0.7.2" | 294 | +version = "0.7.3" |
| 295 | dependencies = [ | 295 | dependencies = [ |
| 296 | "chrono", | 296 | "chrono", |
| 297 | "dirs", | 297 | "dirs", |
+1 −1 Cargo.toml
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "oxwm" | 2 | name = "oxwm" |
| 3 | -version = "0.7.2" | 3 | +version = "0.7.3" |
| 4 | edition = "2024" | 4 | edition = "2024" |
| 5 | 5 | ||
| 6 | [lib] | 6 | [lib] |
+1 −0 default.nix
| @@ -34,6 +34,7 @@ rustPlatform.buildRustPackage (finalAttrs: { | |||
| 34 | postInstall = '' | 34 | postInstall = '' |
| 35 | install resources/oxwm.desktop -Dt $out/share/xsessions | 35 | install resources/oxwm.desktop -Dt $out/share/xsessions |
| 36 | install -Dm644 resources/oxwm.1 -t $out/share/man/man1 | 36 | install -Dm644 resources/oxwm.1 -t $out/share/man/man1 |
| 37 | + install -Dm644 templates/oxwm.lua -t $out/share/oxwm | ||
| 37 | ''; | 38 | ''; |
| 38 | 39 | ||
| 39 | passthru.providedSessions = ["oxwm"]; | 40 | passthru.providedSessions = ["oxwm"]; |
+28 −9 src/bin/main.rs
| @@ -72,8 +72,6 @@ fn load_config(custom_path: Option<PathBuf>) -> Result<(oxwm::Config, bool), Box | |||
| 72 | println!(" Please manually port your configuration to the new Lua format."); | 72 | println!(" Please manually port your configuration to the new Lua format."); |
| 73 | println!(" See the new config.lua template for examples.\n"); | 73 | println!(" See the new config.lua template for examples.\n"); |
| 74 | } | 74 | } |
| 75 | - } else { | ||
| 76 | - update_lsp_files()?; | ||
| 77 | } | 75 | } |
| 78 | 76 | ||
| 79 | lua_path | 77 | lua_path |
| @@ -116,19 +114,40 @@ fn init_config() -> Result<(), Box<dyn std::error::Error>> { | |||
| 116 | fn update_lsp_files() -> Result<(), Box<dyn std::error::Error>> { | 114 | fn update_lsp_files() -> Result<(), Box<dyn std::error::Error>> { |
| 117 | let config_directory = get_config_path(); | 115 | let config_directory = get_config_path(); |
| 118 | 116 | ||
| 119 | - let library_directory = config_directory.join("lib"); | 117 | + let system_paths = [ |
| 120 | - std::fs::create_dir_all(&library_directory)?; | 118 | + PathBuf::from("/usr/share/oxwm/oxwm.lua"), |
| 119 | + PathBuf::from("/usr/local/share/oxwm/oxwm.lua"), | ||
| 120 | + ]; | ||
| 121 | 121 | ||
| 122 | - let oxwm_lua_template = include_str!("../../templates/oxwm.lua"); | 122 | + let system_oxwm_lua = system_paths.iter().find(|path| path.exists()); |
| 123 | - let oxwm_lua_path = library_directory.join("oxwm.lua"); | ||
| 124 | - std::fs::write(&oxwm_lua_path, oxwm_lua_template)?; | ||
| 125 | 123 | ||
| 126 | - let luarc_content = r#"{ | 124 | + let luarc_content = if let Some(system_path) = system_oxwm_lua { |
| 125 | + format!( | ||
| 126 | + r#"{{ | ||
| 127 | + "workspace.library": [ | ||
| 128 | + "{}" | ||
| 129 | + ] | ||
| 130 | +}} | ||
| 131 | +"#, | ||
| 132 | + system_path.parent().unwrap().display() | ||
| 133 | + ) | ||
| 134 | + } else { | ||
| 135 | + let library_directory = config_directory.join("lib"); | ||
| 136 | + std::fs::create_dir_all(&library_directory)?; | ||
| 137 | + | ||
| 138 | + let oxwm_lua_template = include_str!("../../templates/oxwm.lua"); | ||
| 139 | + let oxwm_lua_path = library_directory.join("oxwm.lua"); | ||
| 140 | + std::fs::write(&oxwm_lua_path, oxwm_lua_template)?; | ||
| 141 | + | ||
| 142 | + r#"{ | ||
| 127 | "workspace.library": [ | 143 | "workspace.library": [ |
| 128 | "lib" | 144 | "lib" |
| 129 | ] | 145 | ] |
| 130 | } | 146 | } |
| 131 | -"#; | 147 | +"# |
| 148 | + .to_string() | ||
| 149 | + }; | ||
| 150 | + | ||
| 132 | let luarc_path = config_directory.join(".luarc.json"); | 151 | let luarc_path = config_directory.join(".luarc.json"); |
| 133 | std::fs::write(&luarc_path, luarc_content)?; | 152 | std::fs::write(&luarc_path, luarc_content)?; |
| 134 | 153 | ||
+0 −42 src/config/lua.rs
| @@ -48,45 +48,3 @@ pub fn parse_lua_config( | |||
| 48 | autostart: builder_data.autostart, | 48 | autostart: builder_data.autostart, |
| 49 | }) | 49 | }) |
| 50 | } | 50 | } |
| 51 | - | ||
| 52 | -#[cfg(test)] | ||
| 53 | -mod tests { | ||
| 54 | - use super::*; | ||
| 55 | - | ||
| 56 | - #[test] | ||
| 57 | - fn test_parse_minimal_lua_config() { | ||
| 58 | - let config_str = r#" | ||
| 59 | -oxwm.border.set_width(2) | ||
| 60 | -oxwm.border.set_focused_color(0x6dade3) | ||
| 61 | -oxwm.border.set_unfocused_color(0xbbbbbb) | ||
| 62 | -oxwm.bar.set_font("monospace:style=Bold:size=10") | ||
| 63 | - | ||
| 64 | -oxwm.gaps.set_enabled(true) | ||
| 65 | -oxwm.gaps.set_inner(5, 5) | ||
| 66 | -oxwm.gaps.set_outer(5, 5) | ||
| 67 | - | ||
| 68 | -oxwm.set_modkey("Mod4") | ||
| 69 | -oxwm.set_terminal("st") | ||
| 70 | -oxwm.set_tags({"1", "2", "3"}) | ||
| 71 | - | ||
| 72 | -oxwm.key.bind({"Mod4"}, "Return", oxwm.spawn("st")) | ||
| 73 | -oxwm.key.bind({"Mod4"}, "Q", oxwm.client.kill()) | ||
| 74 | - | ||
| 75 | -oxwm.bar.add_block("{}", "DateTime", "%H:%M", 1, 0xffffff, true) | ||
| 76 | - | ||
| 77 | -oxwm.bar.set_scheme_normal(0xffffff, 0x000000, 0x444444) | ||
| 78 | -oxwm.bar.set_scheme_occupied(0xffffff, 0x000000, 0x444444) | ||
| 79 | -oxwm.bar.set_scheme_selected(0xffffff, 0x000000, 0x444444) | ||
| 80 | -"#; | ||
| 81 | - | ||
| 82 | - let config = parse_lua_config(config_str, None).expect("Failed to parse config"); | ||
| 83 | - | ||
| 84 | - assert_eq!(config.border_width, 2); | ||
| 85 | - assert_eq!(config.border_focused, 0x6dade3); | ||
| 86 | - assert_eq!(config.terminal, "st"); | ||
| 87 | - assert_eq!(config.tags.len(), 3); | ||
| 88 | - assert_eq!(config.keybindings.len(), 2); | ||
| 89 | - assert_eq!(config.status_blocks.len(), 1); | ||
| 90 | - assert!(config.gaps_enabled); | ||
| 91 | - } | ||
| 92 | -} | ||
+7 −1 src/layout/mod.rs
| @@ -1,6 +1,7 @@ | |||
| 1 | pub mod grid; | 1 | pub mod grid; |
| 2 | pub mod monocle; | 2 | pub mod monocle; |
| 3 | pub mod normie; | 3 | pub mod normie; |
| 4 | +pub mod tabbed; | ||
| 4 | pub mod tiling; | 5 | pub mod tiling; |
| 5 | 6 | ||
| 6 | use x11rb::protocol::xproto::Window; | 7 | use x11rb::protocol::xproto::Window; |
| @@ -19,6 +20,7 @@ pub enum LayoutType { | |||
| 19 | Normie, | 20 | Normie, |
| 20 | Grid, | 21 | Grid, |
| 21 | Monocle, | 22 | Monocle, |
| 23 | + Tabbed, | ||
| 22 | } | 24 | } |
| 23 | 25 | ||
| 24 | impl LayoutType { | 26 | impl LayoutType { |
| @@ -28,6 +30,7 @@ impl LayoutType { | |||
| 28 | Self::Normie => Box::new(normie::NormieLayout), | 30 | Self::Normie => Box::new(normie::NormieLayout), |
| 29 | Self::Grid => Box::new(grid::GridLayout), | 31 | Self::Grid => Box::new(grid::GridLayout), |
| 30 | Self::Monocle => Box::new(monocle::MonocleLayout), | 32 | Self::Monocle => Box::new(monocle::MonocleLayout), |
| 33 | + Self::Tabbed => Box::new(tabbed::TabbedLayout), | ||
| 31 | } | 34 | } |
| 32 | } | 35 | } |
| 33 | 36 | ||
| @@ -36,7 +39,8 @@ impl LayoutType { | |||
| 36 | Self::Tiling => Self::Normie, | 39 | Self::Tiling => Self::Normie, |
| 37 | Self::Normie => Self::Grid, | 40 | Self::Normie => Self::Grid, |
| 38 | Self::Grid => Self::Monocle, | 41 | Self::Grid => Self::Monocle, |
| 39 | - Self::Monocle => Self::Tiling, | 42 | + Self::Monocle => Self::Tabbed, |
| 43 | + Self::Tabbed => Self::Tiling, | ||
| 40 | } | 44 | } |
| 41 | } | 45 | } |
| 42 | 46 | ||
| @@ -46,6 +50,7 @@ impl LayoutType { | |||
| 46 | Self::Normie => "normie", | 50 | Self::Normie => "normie", |
| 47 | Self::Grid => "grid", | 51 | Self::Grid => "grid", |
| 48 | Self::Monocle => "monocle", | 52 | Self::Monocle => "monocle", |
| 53 | + Self::Tabbed => "tabbed", | ||
| 49 | } | 54 | } |
| 50 | } | 55 | } |
| 51 | 56 | ||
| @@ -55,6 +60,7 @@ impl LayoutType { | |||
| 55 | "normie" | "floating" => Ok(Self::Normie), | 60 | "normie" | "floating" => Ok(Self::Normie), |
| 56 | "grid" => Ok(Self::Grid), | 61 | "grid" => Ok(Self::Grid), |
| 57 | "monocle" => Ok(Self::Monocle), | 62 | "monocle" => Ok(Self::Monocle), |
| 63 | + "tabbed" => Ok(Self::Tabbed), | ||
| 58 | _ => Err(format!("Invalid Layout Type: {}", s)), | 64 | _ => Err(format!("Invalid Layout Type: {}", s)), |
| 59 | } | 65 | } |
| 60 | } | 66 | } |
+45 −0 src/layout/tabbed.rs new file mode 100644
| @@ -0,0 +1,45 @@ | |||
| 1 | +use super::{GapConfig, Layout, WindowGeometry}; | ||
| 2 | +use x11rb::protocol::xproto::Window; | ||
| 3 | + | ||
| 4 | +pub struct TabbedLayout; | ||
| 5 | + | ||
| 6 | +pub const TAB_BAR_HEIGHT: u32 = 28; | ||
| 7 | + | ||
| 8 | +impl Layout for TabbedLayout { | ||
| 9 | + fn name(&self) -> &'static str { | ||
| 10 | + super::LayoutType::Tabbed.as_str() | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + fn symbol(&self) -> &'static str { | ||
| 14 | + "[=]" | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + fn arrange( | ||
| 18 | + &self, | ||
| 19 | + windows: &[Window], | ||
| 20 | + screen_width: u32, | ||
| 21 | + screen_height: u32, | ||
| 22 | + gaps: &GapConfig, | ||
| 23 | + ) -> Vec<WindowGeometry> { | ||
| 24 | + let window_count = windows.len(); | ||
| 25 | + if window_count == 0 { | ||
| 26 | + return Vec::new(); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + let x = gaps.outer_horizontal as i32; | ||
| 30 | + let y = (gaps.outer_vertical + TAB_BAR_HEIGHT) as i32; | ||
| 31 | + let width = screen_width.saturating_sub(2 * gaps.outer_horizontal); | ||
| 32 | + let height = screen_height | ||
| 33 | + .saturating_sub(2 * gaps.outer_vertical) | ||
| 34 | + .saturating_sub(TAB_BAR_HEIGHT); | ||
| 35 | + | ||
| 36 | + let geometry = WindowGeometry { | ||
| 37 | + x_coordinate: x, | ||
| 38 | + y_coordinate: y, | ||
| 39 | + width, | ||
| 40 | + height, | ||
| 41 | + }; | ||
| 42 | + | ||
| 43 | + vec![geometry; window_count] | ||
| 44 | + } | ||
| 45 | +} | ||
+1 −0 src/lib.rs
| @@ -5,6 +5,7 @@ pub mod keyboard; | |||
| 5 | pub mod layout; | 5 | pub mod layout; |
| 6 | pub mod monitor; | 6 | pub mod monitor; |
| 7 | pub mod overlay; | 7 | pub mod overlay; |
| 8 | +pub mod tab_bar; | ||
| 8 | pub mod window_manager; | 9 | pub mod window_manager; |
| 9 | 10 | ||
| 10 | pub mod prelude { | 11 | pub mod prelude { |
+307 −0 src/tab_bar.rs new file mode 100644
| @@ -0,0 +1,307 @@ | |||
| 1 | +use crate::bar::font::{Font, FontDraw}; | ||
| 2 | +use crate::errors::X11Error; | ||
| 3 | +use crate::layout::tabbed::TAB_BAR_HEIGHT; | ||
| 4 | +use crate::ColorScheme; | ||
| 5 | +use x11rb::connection::Connection; | ||
| 6 | +use x11rb::protocol::xproto::*; | ||
| 7 | +use x11rb::rust_connection::RustConnection; | ||
| 8 | +use x11rb::COPY_DEPTH_FROM_PARENT; | ||
| 9 | + | ||
| 10 | +pub struct TabBar { | ||
| 11 | + window: Window, | ||
| 12 | + width: u16, | ||
| 13 | + height: u16, | ||
| 14 | + x_offset: i16, | ||
| 15 | + y_offset: i16, | ||
| 16 | + graphics_context: Gcontext, | ||
| 17 | + pixmap: x11::xlib::Pixmap, | ||
| 18 | + display: *mut x11::xlib::Display, | ||
| 19 | + font_draw: FontDraw, | ||
| 20 | + scheme_normal: ColorScheme, | ||
| 21 | + scheme_selected: ColorScheme, | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +impl TabBar { | ||
| 25 | + pub fn new( | ||
| 26 | + connection: &RustConnection, | ||
| 27 | + screen: &Screen, | ||
| 28 | + screen_num: usize, | ||
| 29 | + display: *mut x11::xlib::Display, | ||
| 30 | + _font: &Font, | ||
| 31 | + x: i16, | ||
| 32 | + y: i16, | ||
| 33 | + width: u16, | ||
| 34 | + scheme_normal: ColorScheme, | ||
| 35 | + scheme_selected: ColorScheme, | ||
| 36 | + ) -> Result<Self, X11Error> { | ||
| 37 | + let window = connection.generate_id()?; | ||
| 38 | + let graphics_context = connection.generate_id()?; | ||
| 39 | + | ||
| 40 | + let height = TAB_BAR_HEIGHT as u16; | ||
| 41 | + | ||
| 42 | + connection.create_window( | ||
| 43 | + COPY_DEPTH_FROM_PARENT, | ||
| 44 | + window, | ||
| 45 | + screen.root, | ||
| 46 | + x, | ||
| 47 | + y, | ||
| 48 | + width, | ||
| 49 | + height, | ||
| 50 | + 0, | ||
| 51 | + WindowClass::INPUT_OUTPUT, | ||
| 52 | + screen.root_visual, | ||
| 53 | + &CreateWindowAux::new() | ||
| 54 | + .background_pixel(scheme_normal.background) | ||
| 55 | + .event_mask(EventMask::EXPOSURE | EventMask::BUTTON_PRESS) | ||
| 56 | + .override_redirect(1), | ||
| 57 | + )?; | ||
| 58 | + | ||
| 59 | + connection.create_gc( | ||
| 60 | + graphics_context, | ||
| 61 | + window, | ||
| 62 | + &CreateGCAux::new() | ||
| 63 | + .foreground(scheme_normal.foreground) | ||
| 64 | + .background(scheme_normal.background), | ||
| 65 | + )?; | ||
| 66 | + | ||
| 67 | + connection.map_window(window)?; | ||
| 68 | + connection.flush()?; | ||
| 69 | + | ||
| 70 | + let visual = unsafe { x11::xlib::XDefaultVisual(display, screen_num as i32) }; | ||
| 71 | + let colormap = unsafe { x11::xlib::XDefaultColormap(display, screen_num as i32) }; | ||
| 72 | + let depth = unsafe { x11::xlib::XDefaultDepth(display, screen_num as i32) }; | ||
| 73 | + | ||
| 74 | + let pixmap = unsafe { | ||
| 75 | + x11::xlib::XCreatePixmap( | ||
| 76 | + display, | ||
| 77 | + window as x11::xlib::Drawable, | ||
| 78 | + width as u32, | ||
| 79 | + height as u32, | ||
| 80 | + depth as u32, | ||
| 81 | + ) | ||
| 82 | + }; | ||
| 83 | + | ||
| 84 | + let font_draw = FontDraw::new(display, pixmap, visual, colormap)?; | ||
| 85 | + | ||
| 86 | + Ok(Self { | ||
| 87 | + window, | ||
| 88 | + width, | ||
| 89 | + height, | ||
| 90 | + x_offset: x, | ||
| 91 | + y_offset: y, | ||
| 92 | + graphics_context, | ||
| 93 | + pixmap, | ||
| 94 | + display, | ||
| 95 | + font_draw, | ||
| 96 | + scheme_normal, | ||
| 97 | + scheme_selected, | ||
| 98 | + }) | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + pub fn window(&self) -> Window { | ||
| 102 | + self.window | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + pub fn draw( | ||
| 106 | + &mut self, | ||
| 107 | + connection: &RustConnection, | ||
| 108 | + font: &Font, | ||
| 109 | + windows: &[Window], | ||
| 110 | + focused_window: Option<Window>, | ||
| 111 | + ) -> Result<(), X11Error> { | ||
| 112 | + connection.change_gc( | ||
| 113 | + self.graphics_context, | ||
| 114 | + &ChangeGCAux::new().foreground(self.scheme_normal.background), | ||
| 115 | + )?; | ||
| 116 | + connection.flush()?; | ||
| 117 | + | ||
| 118 | + unsafe { | ||
| 119 | + let gc = x11::xlib::XCreateGC(self.display, self.pixmap, 0, std::ptr::null_mut()); | ||
| 120 | + x11::xlib::XSetForeground( | ||
| 121 | + self.display, | ||
| 122 | + gc, | ||
| 123 | + self.scheme_normal.background as u64, | ||
| 124 | + ); | ||
| 125 | + x11::xlib::XFillRectangle( | ||
| 126 | + self.display, | ||
| 127 | + self.pixmap, | ||
| 128 | + gc, | ||
| 129 | + 0, | ||
| 130 | + 0, | ||
| 131 | + self.width as u32, | ||
| 132 | + self.height as u32, | ||
| 133 | + ); | ||
| 134 | + x11::xlib::XFreeGC(self.display, gc); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + if windows.is_empty() { | ||
| 138 | + self.copy_pixmap_to_window(); | ||
| 139 | + return Ok(()); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + let tab_width = self.width / windows.len() as u16; | ||
| 143 | + let mut x_position: i16 = 0; | ||
| 144 | + | ||
| 145 | + for (index, &window) in windows.iter().enumerate() { | ||
| 146 | + let is_focused = Some(window) == focused_window; | ||
| 147 | + let scheme = if is_focused { | ||
| 148 | + &self.scheme_selected | ||
| 149 | + } else { | ||
| 150 | + &self.scheme_normal | ||
| 151 | + }; | ||
| 152 | + | ||
| 153 | + let title = self.get_window_title(connection, window); | ||
| 154 | + let display_title = if title.is_empty() { | ||
| 155 | + format!("Window {}", index + 1) | ||
| 156 | + } else { | ||
| 157 | + title | ||
| 158 | + }; | ||
| 159 | + | ||
| 160 | + let text_width = font.text_width(&display_title); | ||
| 161 | + let text_x = x_position + ((tab_width.saturating_sub(text_width)) / 2) as i16; | ||
| 162 | + | ||
| 163 | + let top_padding = 6; | ||
| 164 | + let text_y = top_padding + font.ascent(); | ||
| 165 | + | ||
| 166 | + self.font_draw | ||
| 167 | + .draw_text(font, scheme.foreground, text_x, text_y, &display_title); | ||
| 168 | + | ||
| 169 | + if is_focused { | ||
| 170 | + let underline_height = 3; | ||
| 171 | + let underline_y = self.height as i16 - underline_height; | ||
| 172 | + | ||
| 173 | + unsafe { | ||
| 174 | + let gc = | ||
| 175 | + x11::xlib::XCreateGC(self.display, self.pixmap, 0, std::ptr::null_mut()); | ||
| 176 | + x11::xlib::XSetForeground(self.display, gc, scheme.underline as u64); | ||
| 177 | + x11::xlib::XFillRectangle( | ||
| 178 | + self.display, | ||
| 179 | + self.pixmap, | ||
| 180 | + gc, | ||
| 181 | + x_position as i32, | ||
| 182 | + underline_y as i32, | ||
| 183 | + tab_width as u32, | ||
| 184 | + underline_height as u32, | ||
| 185 | + ); | ||
| 186 | + x11::xlib::XFreeGC(self.display, gc); | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + x_position += tab_width as i16; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + self.copy_pixmap_to_window(); | ||
| 194 | + Ok(()) | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + fn copy_pixmap_to_window(&self) { | ||
| 198 | + unsafe { | ||
| 199 | + let gc = x11::xlib::XCreateGC(self.display, self.window as u64, 0, std::ptr::null_mut()); | ||
| 200 | + x11::xlib::XCopyArea( | ||
| 201 | + self.display, | ||
| 202 | + self.pixmap, | ||
| 203 | + self.window as u64, | ||
| 204 | + gc, | ||
| 205 | + 0, | ||
| 206 | + 0, | ||
| 207 | + self.width as u32, | ||
| 208 | + self.height as u32, | ||
| 209 | + 0, | ||
| 210 | + 0, | ||
| 211 | + ); | ||
| 212 | + x11::xlib::XFreeGC(self.display, gc); | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + fn get_window_title(&self, connection: &RustConnection, window: Window) -> String { | ||
| 217 | + connection | ||
| 218 | + .get_property(false, window, AtomEnum::WM_NAME, AtomEnum::STRING, 0, 1024) | ||
| 219 | + .ok() | ||
| 220 | + .and_then(|cookie| cookie.reply().ok()) | ||
| 221 | + .and_then(|reply| { | ||
| 222 | + if reply.value.is_empty() { | ||
| 223 | + None | ||
| 224 | + } else { | ||
| 225 | + std::str::from_utf8(&reply.value).ok().map(|s| s.to_string()) | ||
| 226 | + } | ||
| 227 | + }) | ||
| 228 | + .unwrap_or_default() | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + pub fn get_clicked_window( | ||
| 232 | + &self, | ||
| 233 | + windows: &[Window], | ||
| 234 | + click_x: i16, | ||
| 235 | + ) -> Option<Window> { | ||
| 236 | + if windows.is_empty() { | ||
| 237 | + return None; | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + let tab_width = self.width / windows.len() as u16; | ||
| 241 | + let tab_index = (click_x as u16 / tab_width) as usize; | ||
| 242 | + | ||
| 243 | + windows.get(tab_index).copied() | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + pub fn reposition( | ||
| 247 | + &mut self, | ||
| 248 | + connection: &RustConnection, | ||
| 249 | + x: i16, | ||
| 250 | + y: i16, | ||
| 251 | + width: u16, | ||
| 252 | + ) -> Result<(), X11Error> { | ||
| 253 | + self.x_offset = x; | ||
| 254 | + self.y_offset = y; | ||
| 255 | + self.width = width; | ||
| 256 | + | ||
| 257 | + connection.configure_window( | ||
| 258 | + self.window, | ||
| 259 | + &ConfigureWindowAux::new() | ||
| 260 | + .x(x as i32) | ||
| 261 | + .y(y as i32) | ||
| 262 | + .width(width as u32), | ||
| 263 | + )?; | ||
| 264 | + | ||
| 265 | + unsafe { | ||
| 266 | + x11::xlib::XFreePixmap(self.display, self.pixmap); | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + let depth = unsafe { x11::xlib::XDefaultDepth(self.display, 0) }; | ||
| 270 | + self.pixmap = unsafe { | ||
| 271 | + x11::xlib::XCreatePixmap( | ||
| 272 | + self.display, | ||
| 273 | + self.window as x11::xlib::Drawable, | ||
| 274 | + width as u32, | ||
| 275 | + self.height as u32, | ||
| 276 | + depth as u32, | ||
| 277 | + ) | ||
| 278 | + }; | ||
| 279 | + | ||
| 280 | + let visual = unsafe { x11::xlib::XDefaultVisual(self.display, 0) }; | ||
| 281 | + let colormap = unsafe { x11::xlib::XDefaultColormap(self.display, 0) }; | ||
| 282 | + self.font_draw = FontDraw::new(self.display, self.pixmap, visual, colormap)?; | ||
| 283 | + | ||
| 284 | + connection.flush()?; | ||
| 285 | + Ok(()) | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + pub fn hide(&self, connection: &RustConnection) -> Result<(), X11Error> { | ||
| 289 | + connection.unmap_window(self.window)?; | ||
| 290 | + connection.flush()?; | ||
| 291 | + Ok(()) | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + pub fn show(&self, connection: &RustConnection) -> Result<(), X11Error> { | ||
| 295 | + connection.map_window(self.window)?; | ||
| 296 | + connection.flush()?; | ||
| 297 | + Ok(()) | ||
| 298 | + } | ||
| 299 | +} | ||
| 300 | + | ||
| 301 | +impl Drop for TabBar { | ||
| 302 | + fn drop(&mut self) { | ||
| 303 | + unsafe { | ||
| 304 | + x11::xlib::XFreePixmap(self.display, self.pixmap); | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | +} | ||
+222 −6 src/window_manager.rs
| @@ -107,6 +107,7 @@ pub struct WindowManager { | |||
| 107 | fullscreen_windows: HashSet<Window>, | 107 | fullscreen_windows: HashSet<Window>, |
| 108 | floating_geometry_before_fullscreen: std::collections::HashMap<Window, (i16, i16, u16, u16, u16)>, | 108 | floating_geometry_before_fullscreen: std::collections::HashMap<Window, (i16, i16, u16, u16, u16)>, |
| 109 | bars: Vec<Bar>, | 109 | bars: Vec<Bar>, |
| 110 | + tab_bars: Vec<crate::tab_bar::TabBar>, | ||
| 110 | show_bar: bool, | 111 | show_bar: bool, |
| 111 | last_layout: Option<&'static str>, | 112 | last_layout: Option<&'static str>, |
| 112 | monitors: Vec<Monitor>, | 113 | monitors: Vec<Monitor>, |
| @@ -202,6 +203,24 @@ impl WindowManager { | |||
| 202 | bars.push(bar); | 203 | bars.push(bar); |
| 203 | } | 204 | } |
| 204 | 205 | ||
| 206 | + let bar_height = font.height() as f32 * 1.4; | ||
| 207 | + let mut tab_bars = Vec::new(); | ||
| 208 | + for monitor in monitors.iter() { | ||
| 209 | + let tab_bar = crate::tab_bar::TabBar::new( | ||
| 210 | + &connection, | ||
| 211 | + &screen, | ||
| 212 | + screen_number, | ||
| 213 | + display, | ||
| 214 | + &font, | ||
| 215 | + (monitor.x + config.gap_outer_horizontal as i32) as i16, | ||
| 216 | + (monitor.y as f32 + bar_height + config.gap_outer_vertical as f32) as i16, | ||
| 217 | + monitor.width.saturating_sub(2 * config.gap_outer_horizontal) as u16, | ||
| 218 | + config.scheme_occupied, | ||
| 219 | + config.scheme_selected, | ||
| 220 | + )?; | ||
| 221 | + tab_bars.push(tab_bar); | ||
| 222 | + } | ||
| 223 | + | ||
| 205 | let gaps_enabled = config.gaps_enabled; | 224 | let gaps_enabled = config.gaps_enabled; |
| 206 | 225 | ||
| 207 | let atoms = AtomCache::new(&connection)?; | 226 | let atoms = AtomCache::new(&connection)?; |
| @@ -234,6 +253,7 @@ impl WindowManager { | |||
| 234 | fullscreen_windows: HashSet::new(), | 253 | fullscreen_windows: HashSet::new(), |
| 235 | floating_geometry_before_fullscreen: std::collections::HashMap::new(), | 254 | floating_geometry_before_fullscreen: std::collections::HashMap::new(), |
| 236 | bars, | 255 | bars, |
| 256 | + tab_bars, | ||
| 237 | show_bar: true, | 257 | show_bar: true, |
| 238 | last_layout: None, | 258 | last_layout: None, |
| 239 | monitors, | 259 | monitors, |
| @@ -248,6 +268,10 @@ impl WindowManager { | |||
| 248 | keybind_overlay, | 268 | keybind_overlay, |
| 249 | }; | 269 | }; |
| 250 | 270 | ||
| 271 | + for tab_bar in &window_manager.tab_bars { | ||
| 272 | + tab_bar.hide(&window_manager.connection)?; | ||
| 273 | + } | ||
| 274 | + | ||
| 251 | window_manager.scan_existing_windows()?; | 275 | window_manager.scan_existing_windows()?; |
| 252 | window_manager.update_bar()?; | 276 | window_manager.update_bar()?; |
| 253 | window_manager.run_autostart_commands()?; | 277 | window_manager.run_autostart_commands()?; |
| @@ -904,6 +928,45 @@ impl WindowManager { | |||
| 904 | Ok(()) | 928 | Ok(()) |
| 905 | } | 929 | } |
| 906 | 930 | ||
| 931 | + fn update_tab_bars(&mut self) -> WmResult<()> { | ||
| 932 | + for (monitor_index, monitor) in self.monitors.iter().enumerate() { | ||
| 933 | + if let Some(tab_bar) = self.tab_bars.get_mut(monitor_index) { | ||
| 934 | + let visible_windows: Vec<Window> = self | ||
| 935 | + .windows | ||
| 936 | + .iter() | ||
| 937 | + .filter(|&&window| { | ||
| 938 | + let window_monitor_index = self.window_monitor.get(&window).copied().unwrap_or(0); | ||
| 939 | + if window_monitor_index != monitor_index { | ||
| 940 | + return false; | ||
| 941 | + } | ||
| 942 | + if self.floating_windows.contains(&window) { | ||
| 943 | + return false; | ||
| 944 | + } | ||
| 945 | + if self.fullscreen_windows.contains(&window) { | ||
| 946 | + return false; | ||
| 947 | + } | ||
| 948 | + if let Some(&tags) = self.window_tags.get(&window) { | ||
| 949 | + (tags & monitor.selected_tags) != 0 | ||
| 950 | + } else { | ||
| 951 | + false | ||
| 952 | + } | ||
| 953 | + }) | ||
| 954 | + .copied() | ||
| 955 | + .collect(); | ||
| 956 | + | ||
| 957 | + let focused_window = monitor.focused_window; | ||
| 958 | + | ||
| 959 | + tab_bar.draw( | ||
| 960 | + &self.connection, | ||
| 961 | + &self.font, | ||
| 962 | + &visible_windows, | ||
| 963 | + focused_window, | ||
| 964 | + )?; | ||
| 965 | + } | ||
| 966 | + } | ||
| 967 | + Ok(()) | ||
| 968 | + } | ||
| 969 | + | ||
| 907 | fn handle_key_action(&mut self, action: KeyAction, arg: &Arg) -> WmResult<()> { | 970 | fn handle_key_action(&mut self, action: KeyAction, arg: &Arg) -> WmResult<()> { |
| 908 | match action { | 971 | match action { |
| 909 | KeyAction::Spawn => handlers::handle_spawn_action(action, arg)?, | 972 | KeyAction::Spawn => handlers::handle_spawn_action(action, arg)?, |
| @@ -1223,7 +1286,20 @@ impl WindowManager { | |||
| 1223 | visible[0] | 1286 | visible[0] |
| 1224 | }; | 1287 | }; |
| 1225 | 1288 | ||
| 1289 | + let is_tabbed = self.layout.name() == "tabbed"; | ||
| 1290 | + if is_tabbed { | ||
| 1291 | + self.connection.configure_window( | ||
| 1292 | + next_window, | ||
| 1293 | + &ConfigureWindowAux::new().stack_mode(StackMode::ABOVE), | ||
| 1294 | + )?; | ||
| 1295 | + } | ||
| 1296 | + | ||
| 1226 | self.set_focus(next_window)?; | 1297 | self.set_focus(next_window)?; |
| 1298 | + | ||
| 1299 | + if is_tabbed { | ||
| 1300 | + self.update_tab_bars()?; | ||
| 1301 | + } | ||
| 1302 | + | ||
| 1227 | Ok(()) | 1303 | Ok(()) |
| 1228 | } | 1304 | } |
| 1229 | 1305 | ||
| @@ -1693,6 +1769,11 @@ impl WindowManager { | |||
| 1693 | 1769 | ||
| 1694 | self.update_focus_visuals(old_focused, window)?; | 1770 | self.update_focus_visuals(old_focused, window)?; |
| 1695 | self.previous_focused = Some(window); | 1771 | self.previous_focused = Some(window); |
| 1772 | + | ||
| 1773 | + if self.layout.name() == "tabbed" { | ||
| 1774 | + self.update_tab_bars()?; | ||
| 1775 | + } | ||
| 1776 | + | ||
| 1696 | Ok(()) | 1777 | Ok(()) |
| 1697 | } | 1778 | } |
| 1698 | 1779 | ||
| @@ -2001,6 +2082,10 @@ impl WindowManager { | |||
| 2001 | self.apply_layout()?; | 2082 | self.apply_layout()?; |
| 2002 | self.update_bar()?; | 2083 | self.update_bar()?; |
| 2003 | self.set_focus(event.window)?; | 2084 | self.set_focus(event.window)?; |
| 2085 | + | ||
| 2086 | + if self.layout.name() == "tabbed" { | ||
| 2087 | + self.update_tab_bars()?; | ||
| 2088 | + } | ||
| 2004 | } | 2089 | } |
| 2005 | Event::UnmapNotify(event) => { | 2090 | Event::UnmapNotify(event) => { |
| 2006 | if self.windows.contains(&event.window) && self.is_window_visible(event.window) { | 2091 | if self.windows.contains(&event.window) && self.is_window_visible(event.window) { |
| @@ -2123,13 +2208,58 @@ impl WindowManager { | |||
| 2123 | } | 2208 | } |
| 2124 | self.view_tag(tag_index)?; | 2209 | self.view_tag(tag_index)?; |
| 2125 | } | 2210 | } |
| 2126 | - } else if event.child != x11rb::NONE { | 2211 | + } else { |
| 2127 | - self.set_focus(event.child)?; | 2212 | + let is_tab_bar_click = self |
| 2213 | + .tab_bars | ||
| 2214 | + .iter() | ||
| 2215 | + .enumerate() | ||
| 2216 | + .find(|(_, tab_bar)| tab_bar.window() == event.event); | ||
| 2217 | + | ||
| 2218 | + if let Some((monitor_index, tab_bar)) = is_tab_bar_click { | ||
| 2219 | + if monitor_index != self.selected_monitor { | ||
| 2220 | + self.selected_monitor = monitor_index; | ||
| 2221 | + } | ||
| 2128 | 2222 | ||
| 2129 | - if event.detail == ButtonIndex::M1.into() { | 2223 | + let visible_windows: Vec<Window> = self |
| 2130 | - self.move_mouse(event.child)?; | 2224 | + .windows |
| 2131 | - } else if event.detail == ButtonIndex::M3.into() { | 2225 | + .iter() |
| 2132 | - self.resize_mouse(event.child)?; | 2226 | + .filter(|&&window| { |
| 2227 | + let window_monitor_index = self.window_monitor.get(&window).copied().unwrap_or(0); | ||
| 2228 | + if window_monitor_index != monitor_index { | ||
| 2229 | + return false; | ||
| 2230 | + } | ||
| 2231 | + if self.floating_windows.contains(&window) { | ||
| 2232 | + return false; | ||
| 2233 | + } | ||
| 2234 | + if self.fullscreen_windows.contains(&window) { | ||
| 2235 | + return false; | ||
| 2236 | + } | ||
| 2237 | + let monitor_tags = self.monitors.get(monitor_index).map(|m| m.selected_tags).unwrap_or(0); | ||
| 2238 | + if let Some(&tags) = self.window_tags.get(&window) { | ||
| 2239 | + (tags & monitor_tags) != 0 | ||
| 2240 | + } else { | ||
| 2241 | + false | ||
| 2242 | + } | ||
| 2243 | + }) | ||
| 2244 | + .copied() | ||
| 2245 | + .collect(); | ||
| 2246 | + | ||
| 2247 | + if let Some(clicked_window) = tab_bar.get_clicked_window(&visible_windows, event.event_x) { | ||
| 2248 | + self.connection.configure_window( | ||
| 2249 | + clicked_window, | ||
| 2250 | + &ConfigureWindowAux::new().stack_mode(StackMode::ABOVE), | ||
| 2251 | + )?; | ||
| 2252 | + self.set_focus(clicked_window)?; | ||
| 2253 | + self.update_tab_bars()?; | ||
| 2254 | + } | ||
| 2255 | + } else if event.child != x11rb::NONE { | ||
| 2256 | + self.set_focus(event.child)?; | ||
| 2257 | + | ||
| 2258 | + if event.detail == ButtonIndex::M1.into() { | ||
| 2259 | + self.move_mouse(event.child)?; | ||
| 2260 | + } else if event.detail == ButtonIndex::M3.into() { | ||
| 2261 | + self.resize_mouse(event.child)?; | ||
| 2262 | + } | ||
| 2133 | } | 2263 | } |
| 2134 | } | 2264 | } |
| 2135 | } | 2265 | } |
| @@ -2141,6 +2271,12 @@ impl WindowManager { | |||
| 2141 | break; | 2271 | break; |
| 2142 | } | 2272 | } |
| 2143 | } | 2273 | } |
| 2274 | + for _tab_bar in &self.tab_bars { | ||
| 2275 | + if event.window == _tab_bar.window() { | ||
| 2276 | + self.update_tab_bars()?; | ||
| 2277 | + break; | ||
| 2278 | + } | ||
| 2279 | + } | ||
| 2144 | } | 2280 | } |
| 2145 | Event::ClientMessage(event) => { | 2281 | Event::ClientMessage(event) => { |
| 2146 | if event.type_ == self.atoms.net_wm_state { | 2282 | if event.type_ == self.atoms.net_wm_state { |
| @@ -2260,6 +2396,86 @@ impl WindowManager { | |||
| 2260 | } | 2396 | } |
| 2261 | 2397 | ||
| 2262 | self.connection.flush()?; | 2398 | self.connection.flush()?; |
| 2399 | + | ||
| 2400 | + let is_tabbed = self.layout.name() == LayoutType::Tabbed.as_str(); | ||
| 2401 | + | ||
| 2402 | + if is_tabbed { | ||
| 2403 | + let outer_horizontal = if self.gaps_enabled { | ||
| 2404 | + self.config.gap_outer_horizontal | ||
| 2405 | + } else { | ||
| 2406 | + 0 | ||
| 2407 | + }; | ||
| 2408 | + let outer_vertical = if self.gaps_enabled { | ||
| 2409 | + self.config.gap_outer_vertical | ||
| 2410 | + } else { | ||
| 2411 | + 0 | ||
| 2412 | + }; | ||
| 2413 | + | ||
| 2414 | + for monitor_index in 0..self.tab_bars.len() { | ||
| 2415 | + if let Some(monitor) = self.monitors.get(monitor_index) { | ||
| 2416 | + let bar_height = if self.show_bar { | ||
| 2417 | + self.bars | ||
| 2418 | + .get(monitor_index) | ||
| 2419 | + .map(|bar| bar.height() as f32) | ||
| 2420 | + .unwrap_or(0.0) | ||
| 2421 | + } else { | ||
| 2422 | + 0.0 | ||
| 2423 | + }; | ||
| 2424 | + | ||
| 2425 | + let tab_bar_x = (monitor.x + outer_horizontal as i32) as i16; | ||
| 2426 | + let tab_bar_y = (monitor.y as f32 + bar_height + outer_vertical as f32) as i16; | ||
| 2427 | + let tab_bar_width = monitor.width.saturating_sub(2 * outer_horizontal) as u16; | ||
| 2428 | + | ||
| 2429 | + if let Err(e) = self.tab_bars[monitor_index].reposition( | ||
| 2430 | + &self.connection, | ||
| 2431 | + tab_bar_x, | ||
| 2432 | + tab_bar_y, | ||
| 2433 | + tab_bar_width, | ||
| 2434 | + ) { | ||
| 2435 | + eprintln!("Failed to reposition tab bar: {:?}", e); | ||
| 2436 | + } | ||
| 2437 | + } | ||
| 2438 | + } | ||
| 2439 | + } | ||
| 2440 | + | ||
| 2441 | + for monitor_index in 0..self.tab_bars.len() { | ||
| 2442 | + let has_visible_windows = self | ||
| 2443 | + .windows | ||
| 2444 | + .iter() | ||
| 2445 | + .any(|&window| { | ||
| 2446 | + let window_monitor_index = self.window_monitor.get(&window).copied().unwrap_or(0); | ||
| 2447 | + if window_monitor_index != monitor_index { | ||
| 2448 | + return false; | ||
| 2449 | + } | ||
| 2450 | + if self.floating_windows.contains(&window) { | ||
| 2451 | + return false; | ||
| 2452 | + } | ||
| 2453 | + if self.fullscreen_windows.contains(&window) { | ||
| 2454 | + return false; | ||
| 2455 | + } | ||
| 2456 | + if let Some(monitor) = self.monitors.get(monitor_index) { | ||
| 2457 | + if let Some(&tags) = self.window_tags.get(&window) { | ||
| 2458 | + return (tags & monitor.selected_tags) != 0; | ||
| 2459 | + } | ||
| 2460 | + } | ||
| 2461 | + false | ||
| 2462 | + }); | ||
| 2463 | + | ||
| 2464 | + if is_tabbed && has_visible_windows { | ||
| 2465 | + if let Err(e) = self.tab_bars[monitor_index].show(&self.connection) { | ||
| 2466 | + eprintln!("Failed to show tab bar: {:?}", e); | ||
| 2467 | + } | ||
| 2468 | + } else { | ||
| 2469 | + if let Err(e) = self.tab_bars[monitor_index].hide(&self.connection) { | ||
| 2470 | + eprintln!("Failed to hide tab bar: {:?}", e); | ||
| 2471 | + } | ||
| 2472 | + } | ||
| 2473 | + } | ||
| 2474 | + | ||
| 2475 | + if is_tabbed { | ||
| 2476 | + self.update_tab_bars()?; | ||
| 2477 | + } | ||
| 2478 | + | ||
| 2263 | Ok(()) | 2479 | Ok(()) |
| 2264 | } | 2480 | } |
| 2265 | 2481 | ||
+57 −3 templates/config.lua
| @@ -40,10 +40,60 @@ local colors = { | |||
| 40 | 40 | ||
| 41 | -- Workspace tags - can be numbers, names, or icons (requires a Nerd Font) | 41 | -- Workspace tags - can be numbers, names, or icons (requires a Nerd Font) |
| 42 | local tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9" } | 42 | local tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9" } |
| 43 | +-- local tags = { "", "", "", "", "", "", "", "", "" } -- Example of nerd font icon tags | ||
| 43 | 44 | ||
| 44 | -- Font for the status bar (use "fc-list" to see available fonts) | 45 | -- Font for the status bar (use "fc-list" to see available fonts) |
| 45 | local bar_font = "monospace:style=Bold:size=10" | 46 | local bar_font = "monospace:style=Bold:size=10" |
| 46 | 47 | ||
| 48 | +-- Define your blocks | ||
| 49 | +-- Similar to widgets in qtile, or dwmblocks | ||
| 50 | +local blocks = { | ||
| 51 | + oxwm.bar.block.ram({ | ||
| 52 | + format = "Ram: {used}/{total} GB", | ||
| 53 | + interval = 5, | ||
| 54 | + color = colors.light_blue, | ||
| 55 | + underline = true, | ||
| 56 | + }), | ||
| 57 | + oxwm.bar.block.static({ | ||
| 58 | + format = "{}", | ||
| 59 | + text = " │ ", | ||
| 60 | + interval = 999999999, | ||
| 61 | + color = colors.lavender, | ||
| 62 | + underline = false, | ||
| 63 | + }), | ||
| 64 | + oxwm.bar.block.shell({ | ||
| 65 | + format = "Kernel: {}", | ||
| 66 | + command = "uname -r", | ||
| 67 | + interval = 999999999, | ||
| 68 | + color = colors.red, | ||
| 69 | + underline = true, | ||
| 70 | + }), | ||
| 71 | + oxwm.bar.block.static({ | ||
| 72 | + format = "{}", | ||
| 73 | + text = " │ ", | ||
| 74 | + interval = 999999999, | ||
| 75 | + color = colors.lavender, | ||
| 76 | + underline = false, | ||
| 77 | + }), | ||
| 78 | + oxwm.bar.block.datetime({ | ||
| 79 | + format = "{}", | ||
| 80 | + date_format = "%a, %b %d - %-I:%M %P", | ||
| 81 | + interval = 1, | ||
| 82 | + color = colors.cyan, | ||
| 83 | + underline = true, | ||
| 84 | + }), | ||
| 85 | + -- Uncomment to add battery status (useful for laptops) | ||
| 86 | + -- oxwm.bar.block.battery({ | ||
| 87 | + -- format = "Bat: {}%", | ||
| 88 | + -- charging = "⚡ Bat: {}%", | ||
| 89 | + -- discharging = "- Bat: {}%", | ||
| 90 | + -- full = "✓ Bat: {}%", | ||
| 91 | + -- interval = 30, | ||
| 92 | + -- color = colors.green, | ||
| 93 | + -- underline = true, | ||
| 94 | + -- }), | ||
| 95 | +}; | ||
| 96 | + | ||
| 47 | ------------------------------------------------------------------------------- | 97 | ------------------------------------------------------------------------------- |
| 48 | -- Basic Settings | 98 | -- Basic Settings |
| 49 | ------------------------------------------------------------------------------- | 99 | ------------------------------------------------------------------------------- |
| @@ -55,9 +105,10 @@ oxwm.set_tags(tags) | |||
| 55 | -- Layouts | 105 | -- Layouts |
| 56 | ------------------------------------------------------------------------------- | 106 | ------------------------------------------------------------------------------- |
| 57 | -- Set custom symbols for layouts (displayed in the status bar) | 107 | -- Set custom symbols for layouts (displayed in the status bar) |
| 58 | --- Available layouts: "tiling" (master-stack), "normie" (floating) | 108 | +-- Available layouts: "tiling", "normie" (floating), "grid", "monocle", "tabbed" |
| 59 | oxwm.set_layout_symbol("tiling", "[T]") | 109 | oxwm.set_layout_symbol("tiling", "[T]") |
| 60 | oxwm.set_layout_symbol("normie", "[F]") | 110 | oxwm.set_layout_symbol("normie", "[F]") |
| 111 | +oxwm.set_layout_symbol("tabbed", "[=]") | ||
| 61 | 112 | ||
| 62 | ------------------------------------------------------------------------------- | 113 | ------------------------------------------------------------------------------- |
| 63 | -- Appearance | 114 | -- Appearance |
| @@ -78,6 +129,9 @@ oxwm.gaps.set_outer(5, 5) -- Outer gaps (horizontal, vertical) in pixels | |||
| 78 | -- Font configuration | 129 | -- Font configuration |
| 79 | oxwm.bar.set_font(bar_font) | 130 | oxwm.bar.set_font(bar_font) |
| 80 | 131 | ||
| 132 | +-- Set your blocks here (defined above) | ||
| 133 | +oxwm.bar.set_blocks(blocks) | ||
| 134 | + | ||
| 81 | -- Bar color schemes (for workspace tag display) | 135 | -- Bar color schemes (for workspace tag display) |
| 82 | -- Parameters: foreground, background, border | 136 | -- Parameters: foreground, background, border |
| 83 | oxwm.bar.set_scheme_normal(colors.fg, colors.bg, "#444444") -- Unoccupied tags | 137 | oxwm.bar.set_scheme_normal(colors.fg, colors.bg, "#444444") -- Unoccupied tags |
| @@ -96,7 +150,7 @@ oxwm.bar.set_scheme_selected(colors.cyan, colors.bg, colors.purple) -- Currently | |||
| 96 | -- Common keys: Return, Space, Tab, Escape, Backspace, Delete, Left, Right, Up, Down | 150 | -- Common keys: Return, Space, Tab, Escape, Backspace, Delete, Left, Right, Up, Down |
| 97 | 151 | ||
| 98 | -- Basic window management | 152 | -- Basic window management |
| 99 | -oxwm.key.bind({ modkey }, "Return", oxwm.spawn(terminal)) -- Spawn terminal | 153 | +oxwm.key.bind({ modkey }, "Return", oxwm.spawn_terminal()) -- Spawn terminal |
| 100 | oxwm.key.bind({ modkey }, "D", oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })) -- Application launcher | 154 | oxwm.key.bind({ modkey }, "D", oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })) -- Application launcher |
| 101 | oxwm.key.bind({ modkey }, "S", oxwm.spawn({ "sh", "-c", "maim -s | xclip -selection clipboard -t image/png" })) -- Screenshot selection | 155 | oxwm.key.bind({ modkey }, "S", oxwm.spawn({ "sh", "-c", "maim -s | xclip -selection clipboard -t image/png" })) -- Screenshot selection |
| 102 | oxwm.key.bind({ modkey }, "Q", oxwm.client.kill()) -- Close focused window | 156 | oxwm.key.bind({ modkey }, "Q", oxwm.client.kill()) -- Close focused window |
| @@ -168,7 +222,7 @@ oxwm.key.bind({ modkey, "Shift" }, "L", oxwm.client.swap_direction("right")) -- | |||
| 168 | oxwm.key.chord({ | 222 | oxwm.key.chord({ |
| 169 | { { modkey }, "Space" }, | 223 | { { modkey }, "Space" }, |
| 170 | { {}, "T" } | 224 | { {}, "T" } |
| 171 | -}, oxwm.spawn(terminal)) | 225 | +}, oxwm.spawn_terminal()) |
| 172 | 226 | ||
| 173 | ------------------------------------------------------------------------------- | 227 | ------------------------------------------------------------------------------- |
| 174 | -- Status Bar Blocks | 228 | -- Status Bar Blocks |
+3 −3 templates/oxwm.lua
| @@ -38,8 +38,8 @@ function oxwm.set_modkey(modkey) end | |||
| 38 | function oxwm.set_tags(tags) end | 38 | function oxwm.set_tags(tags) end |
| 39 | 39 | ||
| 40 | ---Set layout symbol override | 40 | ---Set layout symbol override |
| 41 | ----@param name string Layout name (e.g., "tiling", "normie") | 41 | +---@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle") |
| 42 | ----@param symbol string Symbol to display (e.g., "[T]", "[F]") | 42 | +---@param symbol string Symbol to display (e.g., "[T]", "[F]", "[=]") |
| 43 | function oxwm.set_layout_symbol(name, symbol) end | 43 | function oxwm.set_layout_symbol(name, symbol) end |
| 44 | 44 | ||
| 45 | ---Quit the window manager | 45 | ---Quit the window manager |
| @@ -171,7 +171,7 @@ oxwm.layout = {} | |||
| 171 | function oxwm.layout.cycle() end | 171 | function oxwm.layout.cycle() end |
| 172 | 172 | ||
| 173 | ---Set specific layout | 173 | ---Set specific layout |
| 174 | ----@param name string Layout name (e.g., "tiling", "normie") | 174 | +---@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle") |
| 175 | ---@return table Action table for keybinding | 175 | ---@return table Action table for keybinding |
| 176 | function oxwm.layout.set(name) end | 176 | function oxwm.layout.set(name) end |
| 177 | 177 | ||