tony / oxwm

Added ability to have 12 tags for Just a guy linux. Browse files
tonybanters committed 2026-06-03 parent f8c0000 commit a6b211745edd40ab188cacfd1655d8edfe022982
Showing 8 changed files with 55 additions and 21 deletions. UnifiedSplit
+14 −2 resources/test-config.lua
@@ -33,9 +33,9 @@ local modkey = "Mod1"
33 33
34 34 oxwm.set_terminal("st")
35 35 oxwm.set_modkey(modkey)
36 -oxwm.set_tags({ "1", "2", "3", "4", "5", "6", "7", "8", "9" })
36 +oxwm.set_tags({ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" })
37 37 oxwm.auto_tile(true);
38 -oxwm.bar.set_hide_vacant_tags(true);
38 +oxwm.bar.set_hide_vacant_tags(false);
39 39
40 40 oxwm.set_layout_symbol("tiling", "[T]")
41 41 oxwm.set_layout_symbol("normie", "[F]")
@@ -116,6 +116,9 @@ oxwm.key.bind({ modkey }, "6", oxwm.tag.view(5))
116 116 oxwm.key.bind({ modkey }, "7", oxwm.tag.view(6))
117 117 oxwm.key.bind({ modkey }, "8", oxwm.tag.view(7))
118 118 oxwm.key.bind({ modkey }, "9", oxwm.tag.view(8))
119 +oxwm.key.bind({ modkey }, "0", oxwm.tag.view(9))
120 +oxwm.key.bind({ modkey }, "minus", oxwm.tag.view(10))
121 +oxwm.key.bind({ modkey }, "equal", oxwm.tag.view(11))
119 122
120 123 -- Move window to tag
121 124 oxwm.key.bind({ modkey, "Shift" }, "1", oxwm.tag.move_to(0))
@@ -127,6 +130,9 @@ oxwm.key.bind({ modkey, "Shift" }, "6", oxwm.tag.move_to(5))
127 130 oxwm.key.bind({ modkey, "Shift" }, "7", oxwm.tag.move_to(6))
128 131 oxwm.key.bind({ modkey, "Shift" }, "8", oxwm.tag.move_to(7))
129 132 oxwm.key.bind({ modkey, "Shift" }, "9", oxwm.tag.move_to(8))
133 +oxwm.key.bind({ modkey, "Shift" }, "0", oxwm.tag.move_to(9))
134 +oxwm.key.bind({ modkey, "Shift" }, "minus", oxwm.tag.move_to(10))
135 +oxwm.key.bind({ modkey, "Shift" }, "equal", oxwm.tag.move_to(11))
130 136
131 137 -- Toggle view (view multiple tags at once) - dwm-style multi-tag viewing
132 138 -- Example: Mod+Ctrl+2 while on tag 1 will show BOTH tags 1 and 2
@@ -139,6 +145,9 @@ oxwm.key.bind({ modkey, "Control" }, "6", oxwm.tag.toggleview(5))
139 145 oxwm.key.bind({ modkey, "Control" }, "7", oxwm.tag.toggleview(6))
140 146 oxwm.key.bind({ modkey, "Control" }, "8", oxwm.tag.toggleview(7))
141 147 oxwm.key.bind({ modkey, "Control" }, "9", oxwm.tag.toggleview(8))
148 +oxwm.key.bind({ modkey, "Control" }, "0", oxwm.tag.toggleview(9))
149 +oxwm.key.bind({ modkey, "Control" }, "minus", oxwm.tag.toggleview(10))
150 +oxwm.key.bind({ modkey, "Control" }, "equal", oxwm.tag.toggleview(11))
142 151
143 152 -- Toggle tag (window on multiple tags) - dwm-style sticky windows
144 153 -- Example: Mod+Ctrl+Shift+2 puts focused window on BOTH current tag and tag 2
@@ -151,6 +160,9 @@ oxwm.key.bind({ modkey, "Control", "Shift" }, "6", oxwm.tag.toggletag(5))
151 160 oxwm.key.bind({ modkey, "Control", "Shift" }, "7", oxwm.tag.toggletag(6))
152 161 oxwm.key.bind({ modkey, "Control", "Shift" }, "8", oxwm.tag.toggletag(7))
153 162 oxwm.key.bind({ modkey, "Control", "Shift" }, "9", oxwm.tag.toggletag(8))
163 +oxwm.key.bind({ modkey, "Control", "Shift" }, "0", oxwm.tag.toggletag(9))
164 +oxwm.key.bind({ modkey, "Control", "Shift" }, "minus", oxwm.tag.toggletag(10))
165 +oxwm.key.bind({ modkey, "Control", "Shift" }, "equal", oxwm.tag.toggletag(11))
154 166
155 167 oxwm.key.bind({ modkey }, "Tab", oxwm.tag.view_next())
156 168 oxwm.key.bind({ modkey, "Shift" }, "Tab", oxwm.tag.view_previous())
+2 −2 src/bar/bar.zig
@@ -200,7 +200,7 @@ pub const Bar = struct {
200 200 const monitor = self.monitor;
201 201 const current_tags = monitor.tagset[monitor.sel_tags];
202 202
203 - for (config.tags, 0..) |tag, index| {
203 + for (config.tags[0..config.tag_count], 0..) |tag, index| {
204 204 const tag_mask: u32 = @as(u32, 1) << @intCast(index);
205 205 const is_selected = (current_tags & tag_mask) != 0;
206 206 const is_occupied = hasClientsOnTag(monitor, tag_mask);
@@ -274,7 +274,7 @@ pub const Bar = struct {
274 274 const monitor = self.monitor;
275 275 const current_tags = monitor.tagset[monitor.sel_tags];
276 276
277 - for (config.tags, 0..) |tag, index| {
277 + for (config.tags[0..config.tag_count], 0..) |tag, index| {
278 278 const tag_mask = @as(u32, 1) << @intCast(index);
279 279 const is_selected = (current_tags & tag_mask) != 0;
280 280 const is_occupied = hasClientsOnTag(monitor, tag_mask);
+3 −2 src/config/config.zig
@@ -184,9 +184,10 @@ pub const Config = struct {
184 184 terminal: []const u8 = "st",
185 185 font: []const u8 = "monospace:size=10",
186 186 bar_position: []const u8 = "top",
187 - tags: [9][]const u8 = .{ "1", "2", "3", "4", "5", "6", "7", "8", "9" },
187 + tags: [12][]const u8 = .{ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" },
188 + tag_count: u32 = 9,
188 189 layout: []const u8 = "tiling",
189 - tag_layouts: [9]?[]const u8 = .{null} ** 9,
190 + tag_layouts: [12]?[]const u8 = .{null} ** 12,
190 191
191 192 border_width: i32 = 2,
192 193 border_focused: u32 = 0x6dade3,
+4 −2 src/config/lua.zig
@@ -1124,7 +1124,7 @@ fn luaSetTags(state: ?*c.lua_State) callconv(.c) c_int {
1124 1124
1125 1125 const len = c.lua_rawlen(s, 1);
1126 1126 var i: usize = 0;
1127 - while (i < len and i < 9) : (i += 1) {
1127 + while (i < len and i < 12) : (i += 1) {
1128 1128 _ = c.lua_rawgeti(s, 1, @intCast(i + 1));
1129 1129 if (dupeLuaString(s, -1)) |tag_str| {
1130 1130 cfg.tags[i] = tag_str;
@@ -1132,6 +1132,8 @@ fn luaSetTags(state: ?*c.lua_State) callconv(.c) c_int {
1132 1132 c.lua_settop(s, -2);
1133 1133 }
1134 1134
1135 + if (i > 0) cfg.tag_count = @intCast(i);
1136 +
1135 1137 return 0;
1136 1138 }
1137 1139
@@ -1180,7 +1182,7 @@ fn luaSetTagLayout(state: ?*c.lua_State) callconv(.c) c_int {
1180 1182 const cfg = config orelse return 0;
1181 1183 const s = state orelse return 0;
1182 1184 const tag_index = c.lua_tointegerx(s, 1, null);
1183 - if (tag_index < 1 or tag_index > 9) return 0;
1185 + if (tag_index < 1 or tag_index > 12) return 0;
1184 1186 const name = getStringArg(s, 2) orelse return 0;
1185 1187 if (config_mod.Layouts.fromString(name) == null) {
1186 1188 std.debug.print("set_tag_layout: unknown layout '{s}'\n", .{name});
+5 −5 src/monitor.zig
@@ -12,11 +12,11 @@ pub const Layout = struct {
12 12 pub const Pertag = struct {
13 13 curtag: u32 = 1,
14 14 prevtag: u32 = 1,
15 - nmasters: [10]i32 = [_]i32{1} ** 10,
16 - mfacts: [10]f32 = [_]f32{0.55} ** 10,
17 - sellts: [10]u32 = [_]u32{0} ** 10,
18 - ltidxs: [10][6]?*const Layout = [_][6]?*const Layout{.{ null, null, null, null, null, null }} ** 10,
19 - showbars: [10]bool = [_]bool{true} ** 10,
15 + nmasters: [13]i32 = [_]i32{1} ** 13,
16 + mfacts: [13]f32 = [_]f32{0.55} ** 13,
17 + sellts: [13]u32 = [_]u32{0} ** 13,
18 + ltidxs: [13][6]?*const Layout = [_][6]?*const Layout{.{ null, null, null, null, null, null }} ** 13,
19 + showbars: [13]bool = [_]bool{true} ** 13,
20 20 };
21 21
22 22 pub const Monitor = struct {
+8 −6 src/wm/actions.zig
@@ -149,7 +149,7 @@ pub fn toggleView(tag_mask: u32, wm: *WindowManager) void {
149 149 if ((new_tags & (@as(u32, 1) << @intCast(monitor.pertag.curtag -| 1))) == 0) {
150 150 monitor.pertag.prevtag = monitor.pertag.curtag;
151 151 var i: u32 = 0;
152 - while (i < 9) : (i += 1) {
152 + while (i < wm.config.tag_count) : (i += 1) {
153 153 if ((new_tags & (@as(u32, 1) << @intCast(i))) != 0) break;
154 154 }
155 155 monitor.pertag.curtag = i + 1;
@@ -250,11 +250,12 @@ pub fn toggleFullscreen(wm: *WindowManager) void {
250 250 pub fn viewAdjacentTag(direction: i32, wm: *WindowManager) void {
251 251 const monitor = wm.selected_monitor orelse return;
252 252 const current_tag = monitor.pertag.curtag;
253 + const max_tag: i32 = @intCast(wm.config.tag_count);
253 254 var new_tag: i32 = @intCast(current_tag);
254 255
255 256 new_tag += direction;
256 - if (new_tag < 1) new_tag = 9;
257 - if (new_tag > 9) new_tag = 1;
257 + if (new_tag < 1) new_tag = max_tag;
258 + if (new_tag > max_tag) new_tag = 1;
258 259
259 260 const tag_mask: u32 = @as(u32, 1) << @intCast(new_tag - 1);
260 261 core.view(tag_mask, wm);
@@ -263,13 +264,14 @@ pub fn viewAdjacentTag(direction: i32, wm: *WindowManager) void {
263 264 pub fn viewAdjacentNonemptyTag(direction: i32, wm: *WindowManager) void {
264 265 const monitor = wm.selected_monitor orelse return;
265 266 const current_tag = monitor.pertag.curtag;
267 + const max_tag: i32 = @intCast(wm.config.tag_count);
266 268 var new_tag: i32 = @intCast(current_tag);
267 269
268 270 var attempts: i32 = 0;
269 - while (attempts < 9) : (attempts += 1) {
271 + while (attempts < max_tag) : (attempts += 1) {
270 272 new_tag += direction;
271 - if (new_tag < 1) new_tag = 9;
272 - if (new_tag > 9) new_tag = 1;
273 + if (new_tag < 1) new_tag = max_tag;
274 + if (new_tag > max_tag) new_tag = 1;
273 275
274 276 const tag_mask: u32 = @as(u32, 1) << @intCast(new_tag - 1);
275 277 if (core.hasClientsOnTag(monitor, tag_mask)) {
+1 −1 src/wm/core.zig
@@ -745,7 +745,7 @@ pub fn view(tag_mask: u32, wm: *WindowManager) void {
745 745 monitor.pertag.curtag = 0;
746 746 } else {
747 747 var i: u32 = 0;
748 - while (i < 9) : (i += 1) {
748 + while (i < wm.config.tag_count) : (i += 1) {
749 749 if ((tag_mask & (@as(u32, 1) << @intCast(i))) != 0) break;
750 750 }
751 751 monitor.pertag.curtag = i + 1;
+18 −1 templates/config.lua
@@ -42,7 +42,11 @@ local colors = {
42 42 }
43 43
44 44 -- Workspace tags - can be numbers, names, or icons (requires a Nerd Font)
45 +-- The number of tags is deduced from the size of this table (up to a max of 12).
46 +-- The default is 9. To use more, add entries here and uncomment the matching
47 +-- keybinds for tags 10-12 further down in this file.
45 48 local tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }
49 +-- local tags = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" } -- Example of 12 tags
46 50 -- local tags = { "", "󰊯", "", "", "󰙯", "󱇤", "", "󱘶", "󰧮" } -- Example of nerd font icon tags
47 51
48 52 -- Font for the status bar (use "fc-list" to see available fonts)
@@ -142,7 +146,7 @@ oxwm.border.set_unfocused_color(colors.grey)
142 146 oxwm.set_floating_position("center")
143 147
144 148 -- Smart Enabled = No border if 1 window
145 -oxwm.gaps.set_smart(enabled)
149 +oxwm.gaps.set_smart(true)
146 150 -- Inner gaps (horizontal, vertical) in pixels
147 151 oxwm.gaps.set_inner(5, 5)
148 152 -- Outer gaps (horizontal, vertical) in pixels
@@ -283,6 +287,10 @@ oxwm.key.bind({ modkey }, "6", oxwm.tag.view(5))
283 287 oxwm.key.bind({ modkey }, "7", oxwm.tag.view(6))
284 288 oxwm.key.bind({ modkey }, "8", oxwm.tag.view(7))
285 289 oxwm.key.bind({ modkey }, "9", oxwm.tag.view(8))
290 +-- Tags 10-12 (opt-in): set 12 tags above, then pick keys you like and uncomment.
291 +-- oxwm.key.bind({ modkey }, "0", oxwm.tag.view(9))
292 +-- oxwm.key.bind({ modkey }, "minus", oxwm.tag.view(10))
293 +-- oxwm.key.bind({ modkey }, "equal", oxwm.tag.view(11))
286 294
287 295 -- Move focused window to workspace N
288 296 oxwm.key.bind({ modkey, "Shift" }, "1", oxwm.tag.move_to(0))
@@ -294,6 +302,9 @@ oxwm.key.bind({ modkey, "Shift" }, "6", oxwm.tag.move_to(5))
294 302 oxwm.key.bind({ modkey, "Shift" }, "7", oxwm.tag.move_to(6))
295 303 oxwm.key.bind({ modkey, "Shift" }, "8", oxwm.tag.move_to(7))
296 304 oxwm.key.bind({ modkey, "Shift" }, "9", oxwm.tag.move_to(8))
305 +-- oxwm.key.bind({ modkey, "Shift" }, "0", oxwm.tag.move_to(9))
306 +-- oxwm.key.bind({ modkey, "Shift" }, "minus", oxwm.tag.move_to(10))
307 +-- oxwm.key.bind({ modkey, "Shift" }, "equal", oxwm.tag.move_to(11))
297 308
298 309 -- Combo view (view multiple tags at once) {argos_nothing}
299 310 -- Example: Mod+Ctrl+2 while on tag 1 will show BOTH tags 1 and 2
@@ -306,6 +317,9 @@ oxwm.key.bind({ modkey, "Control" }, "6", oxwm.tag.toggleview(5))
306 317 oxwm.key.bind({ modkey, "Control" }, "7", oxwm.tag.toggleview(6))
307 318 oxwm.key.bind({ modkey, "Control" }, "8", oxwm.tag.toggleview(7))
308 319 oxwm.key.bind({ modkey, "Control" }, "9", oxwm.tag.toggleview(8))
320 +-- oxwm.key.bind({ modkey, "Control" }, "0", oxwm.tag.toggleview(9))
321 +-- oxwm.key.bind({ modkey, "Control" }, "minus", oxwm.tag.toggleview(10))
322 +-- oxwm.key.bind({ modkey, "Control" }, "equal", oxwm.tag.toggleview(11))
309 323
310 324 -- Multi tag (window on multiple tags)
311 325 -- Example: Mod+Ctrl+Shift+2 puts focused window on BOTH current tag and tag 2
@@ -318,6 +332,9 @@ oxwm.key.bind({ modkey, "Control", "Shift" }, "6", oxwm.tag.toggletag(5))
318 332 oxwm.key.bind({ modkey, "Control", "Shift" }, "7", oxwm.tag.toggletag(6))
319 333 oxwm.key.bind({ modkey, "Control", "Shift" }, "8", oxwm.tag.toggletag(7))
320 334 oxwm.key.bind({ modkey, "Control", "Shift" }, "9", oxwm.tag.toggletag(8))
335 +-- oxwm.key.bind({ modkey, "Control", "Shift" }, "0", oxwm.tag.toggletag(9))
336 +-- oxwm.key.bind({ modkey, "Control", "Shift" }, "minus", oxwm.tag.toggletag(10))
337 +-- oxwm.key.bind({ modkey, "Control", "Shift" }, "equal", oxwm.tag.toggletag(11))
321 338
322 339 -------------------------------------------------------------------------------
323 340 -- Advanced: Keychords