Merge pull request #168 from Iziram/master
Browse files
Features : Quality of life
+32 −9 src/bar/bar.zig
| @@ -9,13 +9,13 @@ const Monitor = monitor_mod.Monitor; | |||
| 9 | const Block = blocks_mod.Block; | 9 | const Block = blocks_mod.Block; |
| 10 | 10 | ||
| 11 | fn getLayoutSymbol(layout_index: u32, config: config_mod.Config) []const u8 { | 11 | fn getLayoutSymbol(layout_index: u32, config: config_mod.Config) []const u8 { |
| 12 | - return switch (layout_index) { | 12 | + const layout = std.meta.intToEnum(config_mod.Layouts, layout_index) catch return "[?]"; |
| 13 | - 0 => config.layout_tile_symbol, | 13 | + return switch (layout) { |
| 14 | - 1 => config.layout_monocle_symbol, | 14 | + .tiling => config.layout_tile_symbol, |
| 15 | - 2 => config.layout_floating_symbol, | 15 | + .monocle => config.layout_monocle_symbol, |
| 16 | - 3 => config.layout_scrolling_symbol, | 16 | + .floating => config.layout_floating_symbol, |
| 17 | - 4 => "[#]", | 17 | + .scrolling => config.layout_scrolling_symbol, |
| 18 | - else => "[?]", | 18 | + .grid => config.layout_grid_symbol, |
| 19 | }; | 19 | }; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| @@ -73,11 +73,23 @@ pub const Bar = struct { | |||
| 73 | const font_height = font.*.ascent + font.*.descent; | 73 | const font_height = font.*.ascent + font.*.descent; |
| 74 | const bar_height: i32 = @intCast(@as(i32, font_height) + 8); | 74 | const bar_height: i32 = @intCast(@as(i32, font_height) + 8); |
| 75 | 75 | ||
| 76 | + var bar_y: i32 = 0; | ||
| 77 | + | ||
| 78 | + if (std.mem.eql(u8, config.bar_position, "top")) { | ||
| 79 | + bar_y = monitor.mon_y; | ||
| 80 | + monitor.win_y = monitor.mon_y + bar_height; | ||
| 81 | + } else if (std.mem.eql(u8, config.bar_position, "bottom")) { | ||
| 82 | + bar_y = monitor.mon_y + monitor.mon_h - bar_height; | ||
| 83 | + monitor.win_y = monitor.mon_y; | ||
| 84 | + } else { | ||
| 85 | + return null; | ||
| 86 | + } | ||
| 87 | + | ||
| 76 | const window = xlib.c.XCreateSimpleWindow( | 88 | const window = xlib.c.XCreateSimpleWindow( |
| 77 | display, | 89 | display, |
| 78 | root, | 90 | root, |
| 79 | monitor.mon_x, | 91 | monitor.mon_x, |
| 80 | - monitor.mon_y, | 92 | + bar_y, |
| 81 | @intCast(monitor.mon_w), | 93 | @intCast(monitor.mon_w), |
| 82 | @intCast(bar_height), | 94 | @intCast(bar_height), |
| 83 | 0, | 95 | 0, |
| @@ -125,7 +137,6 @@ pub const Bar = struct { | |||
| 125 | }; | 137 | }; |
| 126 | 138 | ||
| 127 | monitor.bar_win = window; | 139 | monitor.bar_win = window; |
| 128 | - monitor.win_y = monitor.mon_y + bar_height; | ||
| 129 | monitor.win_h = monitor.mon_h - bar_height; | 140 | monitor.win_h = monitor.mon_h - bar_height; |
| 130 | 141 | ||
| 131 | return bar; | 142 | return bar; |
| @@ -206,6 +217,8 @@ pub const Bar = struct { | |||
| 206 | const content = block.getContent(); | 217 | const content = block.getContent(); |
| 207 | const content_width = self.textWidth(display, content); | 218 | const content_width = self.textWidth(display, content); |
| 208 | block_x -= content_width; | 219 | block_x -= content_width; |
| 220 | + block.x_start = block_x; | ||
| 221 | + block.x_end = block_x + content_width; | ||
| 209 | self.drawText(display, block_x, @divTrunc(self.height + self.font_height, 2) - 4, content, block.color()); | 222 | self.drawText(display, block_x, @divTrunc(self.height + self.font_height, 2) - 4, content, block.color()); |
| 210 | if (block.underline) { | 223 | if (block.underline) { |
| 211 | self.fillRect(display, block_x, self.height - 2, content_width, 2, block.color()); | 224 | self.fillRect(display, block_x, self.height - 2, content_width, 2, block.color()); |
| @@ -245,6 +258,16 @@ pub const Bar = struct { | |||
| 245 | return null; | 258 | return null; |
| 246 | } | 259 | } |
| 247 | 260 | ||
| 261 | + /// Returns the click action of the block the user clicked on, or null. | ||
| 262 | + pub fn handleBlockClick(self: *Bar, click_x: i32) ?config_mod.ClickAction { | ||
| 263 | + for (self.blocks.items) |*block| { | ||
| 264 | + if (block.click != null and click_x >= block.x_start and click_x < block.x_end) { | ||
| 265 | + return block.click; | ||
| 266 | + } | ||
| 267 | + } | ||
| 268 | + return null; | ||
| 269 | + } | ||
| 270 | + | ||
| 248 | /// Updates all blocks and marks the bar dirty if any block changed. | 271 | /// Updates all blocks and marks the bar dirty if any block changed. |
| 249 | pub fn updateBlocks(self: *Bar) void { | 272 | pub fn updateBlocks(self: *Bar) void { |
| 250 | var changed = false; | 273 | var changed = false; |
+4 −0 src/bar/blocks/blocks.zig
| @@ -1,4 +1,5 @@ | |||
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | +const config_mod = @import("../../config/config.zig"); | ||
| 2 | 3 | ||
| 3 | pub const Static = @import("static.zig").Static; | 4 | pub const Static = @import("static.zig").Static; |
| 4 | pub const DateTime = @import("datetime.zig").DateTime; | 5 | pub const DateTime = @import("datetime.zig").DateTime; |
| @@ -13,6 +14,9 @@ pub const Block = struct { | |||
| 13 | cached_content: [256]u8, | 14 | cached_content: [256]u8, |
| 14 | cached_len: usize, | 15 | cached_len: usize, |
| 15 | underline: bool, | 16 | underline: bool, |
| 17 | + click: ?config_mod.ClickAction = null, | ||
| 18 | + x_start: i32 = 0, | ||
| 19 | + x_end: i32 = 0, | ||
| 16 | 20 | ||
| 17 | pub const Data = union(enum) { | 21 | pub const Data = union(enum) { |
| 18 | static: Static, | 22 | static: Static, |
+70 −0 src/config/config.zig
| @@ -18,6 +18,7 @@ pub const Action = enum { | |||
| 18 | toggle_floating, | 18 | toggle_floating, |
| 19 | toggle_fullscreen, | 19 | toggle_fullscreen, |
| 20 | toggle_gaps, | 20 | toggle_gaps, |
| 21 | + toggle_bar, | ||
| 21 | cycle_layout, | 22 | cycle_layout, |
| 22 | set_layout, | 23 | set_layout, |
| 23 | set_layout_tiling, | 24 | set_layout_tiling, |
| @@ -80,6 +81,23 @@ pub const MouseAction = enum { | |||
| 80 | toggle_floating, | 81 | toggle_floating, |
| 81 | }; | 82 | }; |
| 82 | 83 | ||
| 84 | +pub const Layouts = enum(u32) { | ||
| 85 | + tiling, | ||
| 86 | + monocle, | ||
| 87 | + floating, | ||
| 88 | + scrolling, | ||
| 89 | + grid, | ||
| 90 | + | ||
| 91 | + pub fn fromString(name: []const u8) ?Layouts { | ||
| 92 | + if (std.meta.stringToEnum(Layouts, name)) |v| return v; | ||
| 93 | + if (std.mem.eql(u8, name, "tile")) return .tiling; | ||
| 94 | + if (std.mem.eql(u8, name, "normie")) return .floating; | ||
| 95 | + if (std.mem.eql(u8, name, "float")) return .floating; | ||
| 96 | + if (std.mem.eql(u8, name, "scroll")) return .scrolling; | ||
| 97 | + return null; | ||
| 98 | + } | ||
| 99 | +}; | ||
| 100 | + | ||
| 83 | pub const MouseButton = struct { | 101 | pub const MouseButton = struct { |
| 84 | click: ClickTarget, | 102 | click: ClickTarget, |
| 85 | mod_mask: u32, | 103 | mod_mask: u32, |
| @@ -87,6 +105,52 @@ pub const MouseButton = struct { | |||
| 87 | action: MouseAction, | 105 | action: MouseAction, |
| 88 | }; | 106 | }; |
| 89 | 107 | ||
| 108 | +pub const FloatingPosition = enum { | ||
| 109 | + top_left, | ||
| 110 | + top_center, | ||
| 111 | + top_right, | ||
| 112 | + center_left, | ||
| 113 | + center, | ||
| 114 | + center_right, | ||
| 115 | + bottom_left, | ||
| 116 | + bottom_center, | ||
| 117 | + bottom_right, | ||
| 118 | + | ||
| 119 | + pub fn fromString(name: []const u8) ?FloatingPosition { | ||
| 120 | + const map = .{ | ||
| 121 | + .{ "top-left", .top_left }, | ||
| 122 | + .{ "top_left", .top_left }, | ||
| 123 | + .{ "top-center", .top_center }, | ||
| 124 | + .{ "top_center", .top_center }, | ||
| 125 | + .{ "top-middle", .top_center }, | ||
| 126 | + .{ "top-right", .top_right }, | ||
| 127 | + .{ "top_right", .top_right }, | ||
| 128 | + .{ "center-left", .center_left }, | ||
| 129 | + .{ "center_left", .center_left }, | ||
| 130 | + .{ "center", .center }, | ||
| 131 | + .{ "center-right", .center_right }, | ||
| 132 | + .{ "center_right", .center_right }, | ||
| 133 | + .{ "bottom-left", .bottom_left }, | ||
| 134 | + .{ "bottom_left", .bottom_left }, | ||
| 135 | + .{ "bottom-center", .bottom_center }, | ||
| 136 | + .{ "bottom_center", .bottom_center }, | ||
| 137 | + .{ "bottom-middle", .bottom_center }, | ||
| 138 | + .{ "bottom-right", .bottom_right }, | ||
| 139 | + .{ "bottom_right", .bottom_right }, | ||
| 140 | + }; | ||
| 141 | + inline for (map) |entry| { | ||
| 142 | + if (std.mem.eql(u8, name, entry[0])) return entry[1]; | ||
| 143 | + } | ||
| 144 | + return null; | ||
| 145 | + } | ||
| 146 | +}; | ||
| 147 | + | ||
| 148 | +pub const ClickAction = struct { | ||
| 149 | + command: []const u8, | ||
| 150 | + floating: bool = false, | ||
| 151 | + bypass_rules: bool = false, | ||
| 152 | +}; | ||
| 153 | + | ||
| 90 | pub const Block = struct { | 154 | pub const Block = struct { |
| 91 | block_type: BlockType, | 155 | block_type: BlockType, |
| 92 | format: []const u8, | 156 | format: []const u8, |
| @@ -100,6 +164,7 @@ pub const Block = struct { | |||
| 100 | format_full: ?[]const u8 = null, | 164 | format_full: ?[]const u8 = null, |
| 101 | battery_name: ?[]const u8 = null, | 165 | battery_name: ?[]const u8 = null, |
| 102 | thermal_zone: ?[]const u8 = null, | 166 | thermal_zone: ?[]const u8 = null, |
| 167 | + click: ?ClickAction = null, | ||
| 103 | }; | 168 | }; |
| 104 | 169 | ||
| 105 | pub const ColorScheme = struct { | 170 | pub const ColorScheme = struct { |
| @@ -114,7 +179,10 @@ pub const Config = struct { | |||
| 114 | 179 | ||
| 115 | terminal: []const u8 = "st", | 180 | terminal: []const u8 = "st", |
| 116 | font: []const u8 = "monospace:size=10", | 181 | font: []const u8 = "monospace:size=10", |
| 182 | + bar_position: []const u8 = "top", | ||
| 117 | tags: [9][]const u8 = .{ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, | 183 | tags: [9][]const u8 = .{ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, |
| 184 | + layout: []const u8 = "tiling", | ||
| 185 | + tag_layouts: [9]?[]const u8 = .{null} ** 9, | ||
| 118 | 186 | ||
| 119 | border_width: i32 = 2, | 187 | border_width: i32 = 2, |
| 120 | border_focused: u32 = 0x6dade3, | 188 | border_focused: u32 = 0x6dade3, |
| @@ -131,12 +199,14 @@ pub const Config = struct { | |||
| 131 | auto_tile: bool = false, | 199 | auto_tile: bool = false, |
| 132 | tag_back_and_forth: bool = false, | 200 | tag_back_and_forth: bool = false, |
| 133 | hide_vacant_tags: bool = false, | 201 | hide_vacant_tags: bool = false, |
| 202 | + floating_position: FloatingPosition = .center, | ||
| 134 | tiled_resize_mode: bool = false, | 203 | tiled_resize_mode: bool = false, |
| 135 | 204 | ||
| 136 | layout_tile_symbol: []const u8 = "[]=", | 205 | layout_tile_symbol: []const u8 = "[]=", |
| 137 | layout_monocle_symbol: []const u8 = "[M]", | 206 | layout_monocle_symbol: []const u8 = "[M]", |
| 138 | layout_floating_symbol: []const u8 = "><>", | 207 | layout_floating_symbol: []const u8 = "><>", |
| 139 | layout_scrolling_symbol: []const u8 = "[S]", | 208 | layout_scrolling_symbol: []const u8 = "[S]", |
| 209 | + layout_grid_symbol: []const u8 = "[#]", | ||
| 140 | 210 | ||
| 141 | scheme_normal: ColorScheme = .{ .foreground = 0xbbbbbb, .background = 0x1a1b26, .border = 0x444444 }, | 211 | scheme_normal: ColorScheme = .{ .foreground = 0xbbbbbb, .background = 0x1a1b26, .border = 0x444444 }, |
| 142 | scheme_selected: ColorScheme = .{ .foreground = 0x0db9d7, .background = 0x1a1b26, .border = 0xad8ee6 }, | 212 | scheme_selected: ColorScheme = .{ .foreground = 0x0db9d7, .background = 0x1a1b26, .border = 0xad8ee6 }, |
+115 −17 src/config/lua.zig
| @@ -274,6 +274,9 @@ fn registerBarModule(state: *c.lua_State) void { | |||
| 274 | c.lua_pushcfunction(state, luaBarSetHideVacantTags); | 274 | c.lua_pushcfunction(state, luaBarSetHideVacantTags); |
| 275 | c.lua_setfield(state, -2, "set_hide_vacant_tags"); | 275 | c.lua_setfield(state, -2, "set_hide_vacant_tags"); |
| 276 | 276 | ||
| 277 | + c.lua_pushcfunction(state, luaBarSetPosition); | ||
| 278 | + c.lua_setfield(state, -2, "set_position"); | ||
| 279 | + | ||
| 277 | c.lua_createtable(state, 0, 6); | 280 | c.lua_createtable(state, 0, 6); |
| 278 | 281 | ||
| 279 | c.lua_pushcfunction(state, luaBarBlockRam); | 282 | c.lua_pushcfunction(state, luaBarBlockRam); |
| @@ -300,6 +303,9 @@ fn registerMiscFunctions(state: *c.lua_State) void { | |||
| 300 | c.lua_pushcfunction(state, luaSetTerminal); | 303 | c.lua_pushcfunction(state, luaSetTerminal); |
| 301 | c.lua_setfield(state, -2, "set_terminal"); | 304 | c.lua_setfield(state, -2, "set_terminal"); |
| 302 | 305 | ||
| 306 | + c.lua_pushcfunction(state, luaSetLayout); | ||
| 307 | + c.lua_setfield(state, -2, "set_layout"); | ||
| 308 | + | ||
| 303 | c.lua_pushcfunction(state, luaSetModkey); | 309 | c.lua_pushcfunction(state, luaSetModkey); |
| 304 | c.lua_setfield(state, -2, "set_modkey"); | 310 | c.lua_setfield(state, -2, "set_modkey"); |
| 305 | 311 | ||
| @@ -327,6 +333,9 @@ fn registerMiscFunctions(state: *c.lua_State) void { | |||
| 327 | c.lua_pushcfunction(state, luaToggleGaps); | 333 | c.lua_pushcfunction(state, luaToggleGaps); |
| 328 | c.lua_setfield(state, -2, "toggle_gaps"); | 334 | c.lua_setfield(state, -2, "toggle_gaps"); |
| 329 | 335 | ||
| 336 | + c.lua_pushcfunction(state, luaToggleBar); | ||
| 337 | + c.lua_setfield(state, -2, "toggle_bar"); | ||
| 338 | + | ||
| 330 | c.lua_pushcfunction(state, luaShowKeybinds); | 339 | c.lua_pushcfunction(state, luaShowKeybinds); |
| 331 | c.lua_setfield(state, -2, "show_keybinds"); | 340 | c.lua_setfield(state, -2, "show_keybinds"); |
| 332 | 341 | ||
| @@ -335,6 +344,12 @@ fn registerMiscFunctions(state: *c.lua_State) void { | |||
| 335 | 344 | ||
| 336 | c.lua_pushcfunction(state, luaIncNumMaster); | 345 | c.lua_pushcfunction(state, luaIncNumMaster); |
| 337 | c.lua_setfield(state, -2, "inc_num_master"); | 346 | c.lua_setfield(state, -2, "inc_num_master"); |
| 347 | + | ||
| 348 | + c.lua_pushcfunction(state, luaSetTagLayout); | ||
| 349 | + c.lua_setfield(state, -2, "set_tag_layout"); | ||
| 350 | + | ||
| 351 | + c.lua_pushcfunction(state, luaSetFloatingPosition); | ||
| 352 | + c.lua_setfield(state, -2, "set_floating_position"); | ||
| 338 | } | 353 | } |
| 339 | 354 | ||
| 340 | fn createActionTable(state: *c.lua_State, action_name: [*:0]const u8) void { | 355 | fn createActionTable(state: *c.lua_State, action_name: [*:0]const u8) void { |
| @@ -755,6 +770,15 @@ fn luaBarSetFont(state: ?*c.lua_State) callconv(.c) c_int { | |||
| 755 | return 0; | 770 | return 0; |
| 756 | } | 771 | } |
| 757 | 772 | ||
| 773 | +fn luaBarSetPosition(state: ?*c.lua_State) callconv(.c) c_int { | ||
| 774 | + const cfg = config orelse return 0; | ||
| 775 | + const s = state orelse return 0; | ||
| 776 | + if (dupeLuaString(s, 1)) |position| { | ||
| 777 | + cfg.bar_position = position; | ||
| 778 | + } | ||
| 779 | + return 0; | ||
| 780 | +} | ||
| 781 | + | ||
| 758 | fn luaBarSetBlocks(state: ?*c.lua_State) callconv(.c) c_int { | 782 | fn luaBarSetBlocks(state: ?*c.lua_State) callconv(.c) c_int { |
| 759 | const cfg = config orelse return 0; | 783 | const cfg = config orelse return 0; |
| 760 | const s = state orelse return 0; | 784 | const s = state orelse return 0; |
| @@ -805,12 +829,17 @@ fn parseBlockConfig(state: *c.lua_State, idx: c_int) ?Block { | |||
| 805 | const underline = c.lua_toboolean(state, -1) != 0; | 829 | const underline = c.lua_toboolean(state, -1) != 0; |
| 806 | c.lua_settop(state, -2); | 830 | c.lua_settop(state, -2); |
| 807 | 831 | ||
| 832 | + _ = c.lua_getfield(state, idx, "click"); | ||
| 833 | + const click = parseClickAction(state, -1); | ||
| 834 | + c.lua_settop(state, -2); | ||
| 835 | + | ||
| 808 | var block = Block{ | 836 | var block = Block{ |
| 809 | .block_type = .static, | 837 | .block_type = .static, |
| 810 | .format = format, | 838 | .format = format, |
| 811 | .interval = interval, | 839 | .interval = interval, |
| 812 | .color = color, | 840 | .color = color, |
| 813 | .underline = underline, | 841 | .underline = underline, |
| 842 | + .click = click, | ||
| 814 | }; | 843 | }; |
| 815 | 844 | ||
| 816 | if (std.mem.eql(u8, block_type_str, "Ram")) { | 845 | if (std.mem.eql(u8, block_type_str, "Ram")) { |
| @@ -931,7 +960,7 @@ fn luaBarBlockStatic(state: ?*c.lua_State) callconv(.c) c_int { | |||
| 931 | fn luaBarBlockBattery(state: ?*c.lua_State) callconv(.c) c_int { | 960 | fn luaBarBlockBattery(state: ?*c.lua_State) callconv(.c) c_int { |
| 932 | const s = state orelse return 0; | 961 | const s = state orelse return 0; |
| 933 | 962 | ||
| 934 | - c.lua_createtable(s, 0, 6); | 963 | + c.lua_createtable(s, 0, 7); |
| 935 | 964 | ||
| 936 | _ = c.lua_pushstring(s, "Battery"); | 965 | _ = c.lua_pushstring(s, "Battery"); |
| 937 | c.lua_setfield(s, -2, "__block_type"); | 966 | c.lua_setfield(s, -2, "__block_type"); |
| @@ -948,6 +977,9 @@ fn luaBarBlockBattery(state: ?*c.lua_State) callconv(.c) c_int { | |||
| 948 | _ = c.lua_getfield(s, 1, "underline"); | 977 | _ = c.lua_getfield(s, 1, "underline"); |
| 949 | c.lua_setfield(s, -2, "underline"); | 978 | c.lua_setfield(s, -2, "underline"); |
| 950 | 979 | ||
| 980 | + _ = c.lua_getfield(s, 1, "click"); | ||
| 981 | + c.lua_setfield(s, -2, "click"); | ||
| 982 | + | ||
| 951 | c.lua_createtable(s, 0, 4); | 983 | c.lua_createtable(s, 0, 4); |
| 952 | _ = c.lua_getfield(s, 1, "charging"); | 984 | _ = c.lua_getfield(s, 1, "charging"); |
| 953 | c.lua_setfield(s, -2, "charging"); | 985 | c.lua_setfield(s, -2, "charging"); |
| @@ -963,7 +995,7 @@ fn luaBarBlockBattery(state: ?*c.lua_State) callconv(.c) c_int { | |||
| 963 | } | 995 | } |
| 964 | 996 | ||
| 965 | fn createBlockTable(state: *c.lua_State, block_type: [*:0]const u8, arg: ?[]const u8) void { | 997 | fn createBlockTable(state: *c.lua_State, block_type: [*:0]const u8, arg: ?[]const u8) void { |
| 966 | - c.lua_createtable(state, 0, 6); | 998 | + c.lua_createtable(state, 0, 7); |
| 967 | 999 | ||
| 968 | _ = c.lua_pushstring(state, block_type); | 1000 | _ = c.lua_pushstring(state, block_type); |
| 969 | c.lua_setfield(state, -2, "__block_type"); | 1001 | c.lua_setfield(state, -2, "__block_type"); |
| @@ -980,6 +1012,9 @@ fn createBlockTable(state: *c.lua_State, block_type: [*:0]const u8, arg: ?[]cons | |||
| 980 | _ = c.lua_getfield(state, 1, "underline"); | 1012 | _ = c.lua_getfield(state, 1, "underline"); |
| 981 | c.lua_setfield(state, -2, "underline"); | 1013 | c.lua_setfield(state, -2, "underline"); |
| 982 | 1014 | ||
| 1015 | + _ = c.lua_getfield(state, 1, "click"); | ||
| 1016 | + c.lua_setfield(state, -2, "click"); | ||
| 1017 | + | ||
| 983 | if (arg) |a| { | 1018 | if (arg) |a| { |
| 984 | var buf: [256]u8 = undefined; | 1019 | var buf: [256]u8 = undefined; |
| 985 | if (a.len < buf.len) { | 1020 | if (a.len < buf.len) { |
| @@ -991,6 +1026,17 @@ fn createBlockTable(state: *c.lua_State, block_type: [*:0]const u8, arg: ?[]cons | |||
| 991 | } | 1026 | } |
| 992 | } | 1027 | } |
| 993 | 1028 | ||
| 1029 | +fn luaSetFloatingPosition(state: ?*c.lua_State) callconv(.c) c_int { | ||
| 1030 | + const cfg = config orelse return 0; | ||
| 1031 | + const s = state orelse return 0; | ||
| 1032 | + if (getLuaString(s, 1)) |name| { | ||
| 1033 | + if (config_mod.FloatingPosition.fromString(name)) |pos| { | ||
| 1034 | + cfg.floating_position = pos; | ||
| 1035 | + } | ||
| 1036 | + } | ||
| 1037 | + return 0; | ||
| 1038 | +} | ||
| 1039 | + | ||
| 994 | fn luaSetTerminal(state: ?*c.lua_State) callconv(.c) c_int { | 1040 | fn luaSetTerminal(state: ?*c.lua_State) callconv(.c) c_int { |
| 995 | const cfg = config orelse return 0; | 1041 | const cfg = config orelse return 0; |
| 996 | const s = state orelse return 0; | 1042 | const s = state orelse return 0; |
| @@ -1000,6 +1046,20 @@ fn luaSetTerminal(state: ?*c.lua_State) callconv(.c) c_int { | |||
| 1000 | return 0; | 1046 | return 0; |
| 1001 | } | 1047 | } |
| 1002 | 1048 | ||
| 1049 | +fn luaSetLayout(state: ?*c.lua_State) callconv(.c) c_int { | ||
| 1050 | + const cfg = config orelse return 0; | ||
| 1051 | + const s = state orelse return 0; | ||
| 1052 | + const name = getStringArg(s, 1) orelse return 0; | ||
| 1053 | + if (config_mod.Layouts.fromString(name) == null) { | ||
| 1054 | + std.debug.print("set_layout: unknown layout '{s}'\n", .{name}); | ||
| 1055 | + return 0; | ||
| 1056 | + } | ||
| 1057 | + if (dupeLuaString(s, 1)) |layout| { | ||
| 1058 | + cfg.layout = layout; | ||
| 1059 | + } | ||
| 1060 | + return 0; | ||
| 1061 | +} | ||
| 1062 | + | ||
| 1003 | fn luaSetModkey(state: ?*c.lua_State) callconv(.c) c_int { | 1063 | fn luaSetModkey(state: ?*c.lua_State) callconv(.c) c_int { |
| 1004 | const cfg = config orelse return 0; | 1064 | const cfg = config orelse return 0; |
| 1005 | const s = state orelse return 0; | 1065 | const s = state orelse return 0; |
| @@ -1069,22 +1129,29 @@ fn luaSetLayoutSymbol(state: ?*c.lua_State) callconv(.c) c_int { | |||
| 1069 | const name = getStringArg(s, 1) orelse return 0; | 1129 | const name = getStringArg(s, 1) orelse return 0; |
| 1070 | const symbol = dupeLuaString(s, 2) orelse return 0; | 1130 | const symbol = dupeLuaString(s, 2) orelse return 0; |
| 1071 | 1131 | ||
| 1072 | - const layout_map = .{ | 1132 | + const layout = config_mod.Layouts.fromString(name) orelse return 0; |
| 1073 | - .{ "tiling", &cfg.layout_tile_symbol }, | 1133 | + switch (layout) { |
| 1074 | - .{ "tile", &cfg.layout_tile_symbol }, | 1134 | + .tiling => cfg.layout_tile_symbol = symbol, |
| 1075 | - .{ "normie", &cfg.layout_floating_symbol }, | 1135 | + .monocle => cfg.layout_monocle_symbol = symbol, |
| 1076 | - .{ "floating", &cfg.layout_floating_symbol }, | 1136 | + .floating => cfg.layout_floating_symbol = symbol, |
| 1077 | - .{ "float", &cfg.layout_floating_symbol }, | 1137 | + .scrolling => cfg.layout_scrolling_symbol = symbol, |
| 1078 | - .{ "monocle", &cfg.layout_monocle_symbol }, | 1138 | + .grid => cfg.layout_grid_symbol = symbol, |
| 1079 | - .{ "scrolling", &cfg.layout_scrolling_symbol }, | 1139 | + } |
| 1080 | - .{ "scroll", &cfg.layout_scrolling_symbol }, | 1140 | + return 0; |
| 1081 | - }; | 1141 | +} |
| 1082 | 1142 | ||
| 1083 | - inline for (layout_map) |entry| { | 1143 | +fn luaSetTagLayout(state: ?*c.lua_State) callconv(.c) c_int { |
| 1084 | - if (std.mem.eql(u8, name, entry[0])) { | 1144 | + const cfg = config orelse return 0; |
| 1085 | - entry[1].* = symbol; | 1145 | + const s = state orelse return 0; |
| 1086 | - return 0; | 1146 | + const tag_index = c.lua_tointegerx(s, 1, null); |
| 1087 | - } | 1147 | + if (tag_index < 1 or tag_index > 9) return 0; |
| 1148 | + const name = getStringArg(s, 2) orelse return 0; | ||
| 1149 | + if (config_mod.Layouts.fromString(name) == null) { | ||
| 1150 | + std.debug.print("set_tag_layout: unknown layout '{s}'\n", .{name}); | ||
| 1151 | + return 0; | ||
| 1152 | + } | ||
| 1153 | + if (dupeLuaString(s, 2)) |layout_str| { | ||
| 1154 | + cfg.tag_layouts[@intCast(tag_index - 1)] = layout_str; | ||
| 1088 | } | 1155 | } |
| 1089 | return 0; | 1156 | return 0; |
| 1090 | } | 1157 | } |
| @@ -1107,6 +1174,12 @@ fn luaToggleGaps(state: ?*c.lua_State) callconv(.c) c_int { | |||
| 1107 | return 1; | 1174 | return 1; |
| 1108 | } | 1175 | } |
| 1109 | 1176 | ||
| 1177 | +fn luaToggleBar(state: ?*c.lua_State) callconv(.c) c_int { | ||
| 1178 | + const s = state orelse return 0; | ||
| 1179 | + createActionTable(s, "ToggleBar"); | ||
| 1180 | + return 1; | ||
| 1181 | +} | ||
| 1182 | + | ||
| 1110 | fn luaShowKeybinds(state: ?*c.lua_State) callconv(.c) c_int { | 1183 | fn luaShowKeybinds(state: ?*c.lua_State) callconv(.c) c_int { |
| 1111 | const s = state orelse return 0; | 1184 | const s = state orelse return 0; |
| 1112 | createActionTable(s, "ShowKeybinds"); | 1185 | createActionTable(s, "ShowKeybinds"); |
| @@ -1179,6 +1252,30 @@ fn dupeLuaString(state: *c.lua_State, idx: c_int) ?[]const u8 { | |||
| 1179 | return duped; | 1252 | return duped; |
| 1180 | } | 1253 | } |
| 1181 | 1254 | ||
| 1255 | +fn parseClickAction(state: *c.lua_State, idx: c_int) ?config_mod.ClickAction { | ||
| 1256 | + const lua_type = c.lua_type(state, idx); | ||
| 1257 | + if (lua_type == c.LUA_TSTRING) { | ||
| 1258 | + const cmd = dupeLuaString(state, idx) orelse return null; | ||
| 1259 | + return .{ .command = cmd }; | ||
| 1260 | + } else if (lua_type == c.LUA_TTABLE) { | ||
| 1261 | + _ = c.lua_getfield(state, idx, "command"); | ||
| 1262 | + const cmd = dupeLuaString(state, -1); | ||
| 1263 | + c.lua_settop(state, -2); | ||
| 1264 | + if (cmd == null) return null; | ||
| 1265 | + | ||
| 1266 | + _ = c.lua_getfield(state, idx, "floating"); | ||
| 1267 | + const floating = c.lua_toboolean(state, -1) != 0; | ||
| 1268 | + c.lua_settop(state, -2); | ||
| 1269 | + | ||
| 1270 | + _ = c.lua_getfield(state, idx, "bypass_rules"); | ||
| 1271 | + const bypass_rules = c.lua_toboolean(state, -1) != 0; | ||
| 1272 | + c.lua_settop(state, -2); | ||
| 1273 | + | ||
| 1274 | + return .{ .command = cmd.?, .floating = floating, .bypass_rules = bypass_rules }; | ||
| 1275 | + } | ||
| 1276 | + return null; | ||
| 1277 | +} | ||
| 1278 | + | ||
| 1182 | fn parseColor(state: *c.lua_State, idx: c_int) u32 { | 1279 | fn parseColor(state: *c.lua_State, idx: c_int) u32 { |
| 1183 | const lua_type = c.lua_type(state, idx); | 1280 | const lua_type = c.lua_type(state, idx); |
| 1184 | if (lua_type == c.LUA_TNUMBER) { | 1281 | if (lua_type == c.LUA_TNUMBER) { |
| @@ -1257,6 +1354,7 @@ fn parseAction(name: []const u8) ?Action { | |||
| 1257 | .{ "ToggleFloating", Action.toggle_floating }, | 1354 | .{ "ToggleFloating", Action.toggle_floating }, |
| 1258 | .{ "ToggleFullScreen", Action.toggle_fullscreen }, | 1355 | .{ "ToggleFullScreen", Action.toggle_fullscreen }, |
| 1259 | .{ "ToggleGaps", Action.toggle_gaps }, | 1356 | .{ "ToggleGaps", Action.toggle_gaps }, |
| 1357 | + .{ "ToggleBar", Action.toggle_bar }, | ||
| 1260 | .{ "CycleLayout", Action.cycle_layout }, | 1358 | .{ "CycleLayout", Action.cycle_layout }, |
| 1261 | .{ "ChangeLayout", Action.set_layout }, | 1359 | .{ "ChangeLayout", Action.set_layout }, |
| 1262 | .{ "ViewTag", Action.view_tag }, | 1360 | .{ "ViewTag", Action.view_tag }, |
+1 −1 src/overlay.zig
| @@ -172,7 +172,7 @@ pub const KeybindOverlay = struct { | |||
| 172 | if (self.display) |display| { | 172 | if (self.display) |display| { |
| 173 | _ = xlib.XUngrabKeyboard(display, xlib.CurrentTime); | 173 | _ = xlib.XUngrabKeyboard(display, xlib.CurrentTime); |
| 174 | if (self.window != 0) { | 174 | if (self.window != 0) { |
| 175 | - _ = xlib.c.XUnmapWindow(display, self.window); | 175 | + _ = xlib.XUnmapWindow(display, self.window); |
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| 178 | self.visible = false; | 178 | self.visible = false; |
+49 −21 src/wm/actions.zig
| @@ -6,6 +6,7 @@ const lua = @import("../config/lua.zig"); | |||
| 6 | const core = @import("core.zig"); | 6 | const core = @import("core.zig"); |
| 7 | const tiling = @import("../layouts/tiling.zig"); | 7 | const tiling = @import("../layouts/tiling.zig"); |
| 8 | const monitor_mod = @import("../monitor.zig"); | 8 | const monitor_mod = @import("../monitor.zig"); |
| 9 | +const bar_mod = @import("../bar/bar.zig"); | ||
| 9 | const wm_mod = @import("wm.zig"); | 10 | const wm_mod = @import("wm.zig"); |
| 10 | const xlib = @import("../x11/xlib.zig"); | 11 | const xlib = @import("../x11/xlib.zig"); |
| 11 | 12 | ||
| @@ -148,6 +149,12 @@ pub fn toggleView(tag_mask: u32, wm: *WindowManager) void { | |||
| 148 | monitor.mfact = monitor.pertag.mfacts[monitor.pertag.curtag]; | 149 | monitor.mfact = monitor.pertag.mfacts[monitor.pertag.curtag]; |
| 149 | monitor.sel_lt = monitor.pertag.sellts[monitor.pertag.curtag]; | 150 | monitor.sel_lt = monitor.pertag.sellts[monitor.pertag.curtag]; |
| 150 | 151 | ||
| 152 | + const new_show_bar = monitor.pertag.showbars[monitor.pertag.curtag]; | ||
| 153 | + if (new_show_bar != monitor.show_bar) { | ||
| 154 | + monitor.show_bar = new_show_bar; | ||
| 155 | + updateBarVisibility(monitor, wm); | ||
| 156 | + } | ||
| 157 | + | ||
| 151 | core.focusTopClient(monitor, wm); | 158 | core.focusTopClient(monitor, wm); |
| 152 | core.arrange(monitor, wm); | 159 | core.arrange(monitor, wm); |
| 153 | wm.invalidateBars(); | 160 | wm.invalidateBars(); |
| @@ -182,6 +189,35 @@ pub fn toggleGaps(wm: *WindowManager) void { | |||
| 182 | core.arrange(monitor, wm); | 189 | core.arrange(monitor, wm); |
| 183 | } | 190 | } |
| 184 | 191 | ||
| 192 | +pub fn updateBarVisibility(monitor: *Monitor, wm: *WindowManager) void { | ||
| 193 | + const bar = bar_mod.windowToBar(wm.bars, monitor.bar_win) orelse return; | ||
| 194 | + | ||
| 195 | + if (monitor.show_bar) { | ||
| 196 | + _ = xlib.XMapWindow(wm.display.handle, bar.window); | ||
| 197 | + monitor.win_h -= bar.height; | ||
| 198 | + if (std.mem.eql(u8, wm.config.bar_position, "top")) { | ||
| 199 | + monitor.win_y += bar.height; | ||
| 200 | + } | ||
| 201 | + } else { | ||
| 202 | + _ = xlib.XUnmapWindow(wm.display.handle, bar.window); | ||
| 203 | + monitor.win_h += bar.height; | ||
| 204 | + if (std.mem.eql(u8, wm.config.bar_position, "top")) { | ||
| 205 | + monitor.win_y -= bar.height; | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | +} | ||
| 209 | + | ||
| 210 | +pub fn toggleBar(wm: *WindowManager) void { | ||
| 211 | + const monitor = wm.selected_monitor orelse return; | ||
| 212 | + monitor.show_bar = !monitor.show_bar; | ||
| 213 | + monitor.pertag.showbars[monitor.pertag.curtag] = monitor.show_bar; | ||
| 214 | + | ||
| 215 | + updateBarVisibility(monitor, wm); | ||
| 216 | + | ||
| 217 | + core.arrange(monitor, wm); | ||
| 218 | + wm.invalidateBars(); | ||
| 219 | +} | ||
| 220 | + | ||
| 185 | pub fn killFocused(wm: *WindowManager) void { | 221 | pub fn killFocused(wm: *WindowManager) void { |
| 186 | const selected = wm.selected_monitor orelse return; | 222 | const selected = wm.selected_monitor orelse return; |
| 187 | const client = selected.sel orelse return; | 223 | const client = selected.sel orelse return; |
| @@ -342,15 +378,15 @@ pub fn setmfact(delta: f32, wm: *WindowManager) void { | |||
| 342 | 378 | ||
| 343 | pub fn cycleLayout(wm: *WindowManager) void { | 379 | pub fn cycleLayout(wm: *WindowManager) void { |
| 344 | const monitor = wm.selected_monitor orelse return; | 380 | const monitor = wm.selected_monitor orelse return; |
| 345 | - const new_lt = (monitor.sel_lt + 1) % 5; | 381 | + const new_lt = (monitor.sel_lt + 1) % @as(u32, @intCast(std.meta.fields(config_mod.Layouts).len)); |
| 346 | monitor.sel_lt = new_lt; | 382 | monitor.sel_lt = new_lt; |
| 347 | monitor.pertag.sellts[monitor.pertag.curtag] = new_lt; | 383 | monitor.pertag.sellts[monitor.pertag.curtag] = new_lt; |
| 348 | - if (new_lt != 3) { | 384 | + if (new_lt != @intFromEnum(config_mod.Layouts.scrolling)) { |
| 349 | monitor.scroll_offset = 0; | 385 | monitor.scroll_offset = 0; |
| 350 | } | 386 | } |
| 351 | core.arrange(monitor, wm); | 387 | core.arrange(monitor, wm); |
| 352 | wm.invalidateBars(); | 388 | wm.invalidateBars(); |
| 353 | - if (monitor.lt[monitor.sel_lt]) |layout| { | 389 | + if (monitor.lt[@as(usize, monitor.sel_lt)]) |layout| { |
| 354 | std.debug.print("cycle_layout: {s}\n", .{layout.symbol}); | 390 | std.debug.print("cycle_layout: {s}\n", .{layout.symbol}); |
| 355 | } | 391 | } |
| 356 | } | 392 | } |
| @@ -358,44 +394,35 @@ pub fn cycleLayout(wm: *WindowManager) void { | |||
| 358 | pub fn setLayout(layout_name: ?[]const u8, wm: *WindowManager) void { | 394 | pub fn setLayout(layout_name: ?[]const u8, wm: *WindowManager) void { |
| 359 | const monitor = wm.selected_monitor orelse return; | 395 | const monitor = wm.selected_monitor orelse return; |
| 360 | const name = layout_name orelse return; | 396 | const name = layout_name orelse return; |
| 361 | - | 397 | + const new_lt: u32 = if (config_mod.Layouts.fromString(name)) |value| |
| 362 | - const new_lt: u32 = if (std.mem.eql(u8, name, "tiling") or std.mem.eql(u8, name, "[]=")) | 398 | + @intFromEnum(value) |
| 363 | - 0 | ||
| 364 | - else if (std.mem.eql(u8, name, "monocle") or std.mem.eql(u8, name, "[M]")) | ||
| 365 | - 1 | ||
| 366 | - else if (std.mem.eql(u8, name, "floating") or std.mem.eql(u8, name, "><>")) | ||
| 367 | - 2 | ||
| 368 | - else if (std.mem.eql(u8, name, "scrolling") or std.mem.eql(u8, name, "[S]")) | ||
| 369 | - 3 | ||
| 370 | - else if (std.mem.eql(u8, name, "grid") or std.mem.eql(u8, name, "[#]")) | ||
| 371 | - 4 | ||
| 372 | else { | 399 | else { |
| 373 | std.debug.print("set_layout: unknown layout '{s}'\n", .{name}); | 400 | std.debug.print("set_layout: unknown layout '{s}'\n", .{name}); |
| 374 | return; | 401 | return; |
| 375 | }; | 402 | }; |
| 376 | - | ||
| 377 | monitor.sel_lt = new_lt; | 403 | monitor.sel_lt = new_lt; |
| 378 | monitor.pertag.sellts[monitor.pertag.curtag] = new_lt; | 404 | monitor.pertag.sellts[monitor.pertag.curtag] = new_lt; |
| 379 | - if (new_lt != 3) { | 405 | + if (new_lt != @intFromEnum(config_mod.Layouts.scrolling)) { |
| 380 | monitor.scroll_offset = 0; | 406 | monitor.scroll_offset = 0; |
| 381 | } | 407 | } |
| 382 | core.arrange(monitor, wm); | 408 | core.arrange(monitor, wm); |
| 383 | wm.invalidateBars(); | 409 | wm.invalidateBars(); |
| 384 | - if (monitor.lt[monitor.sel_lt]) |layout| { | 410 | + if (monitor.lt[@as(usize, monitor.sel_lt)]) |layout| { |
| 385 | std.debug.print("set_layout: {s}\n", .{layout.symbol}); | 411 | std.debug.print("set_layout: {s}\n", .{layout.symbol}); |
| 386 | } | 412 | } |
| 387 | } | 413 | } |
| 388 | 414 | ||
| 389 | pub fn setLayoutIndex(index: u32, wm: *WindowManager) void { | 415 | pub fn setLayoutIndex(index: u32, wm: *WindowManager) void { |
| 390 | const monitor = wm.selected_monitor orelse return; | 416 | const monitor = wm.selected_monitor orelse return; |
| 391 | - monitor.sel_lt = index; | 417 | + const lt_index = index % @as(u32, @intCast(std.meta.fields(config_mod.Layouts).len)); |
| 392 | - monitor.pertag.sellts[monitor.pertag.curtag] = index; | 418 | + monitor.sel_lt = lt_index; |
| 393 | - if (index != 3) { | 419 | + monitor.pertag.sellts[monitor.pertag.curtag] = lt_index; |
| 420 | + if (lt_index != @intFromEnum(config_mod.Layouts.scrolling)) { | ||
| 394 | monitor.scroll_offset = 0; | 421 | monitor.scroll_offset = 0; |
| 395 | } | 422 | } |
| 396 | core.arrange(monitor, wm); | 423 | core.arrange(monitor, wm); |
| 397 | wm.invalidateBars(); | 424 | wm.invalidateBars(); |
| 398 | - if (monitor.lt[monitor.sel_lt]) |layout| { | 425 | + if (monitor.lt[@as(usize, monitor.sel_lt)]) |layout| { |
| 399 | std.debug.print("set_layout_index: {s}\n", .{layout.symbol}); | 426 | std.debug.print("set_layout_index: {s}\n", .{layout.symbol}); |
| 400 | } | 427 | } |
| 401 | } | 428 | } |
| @@ -774,6 +801,7 @@ pub fn executeAction(action: config_mod.Action, int_arg: i32, str_arg: ?[]const | |||
| 774 | .toggle_floating => toggleFloating(wm), | 801 | .toggle_floating => toggleFloating(wm), |
| 775 | .toggle_fullscreen => toggleFullscreen(wm), | 802 | .toggle_fullscreen => toggleFullscreen(wm), |
| 776 | .toggle_gaps => toggleGaps(wm), | 803 | .toggle_gaps => toggleGaps(wm), |
| 804 | + .toggle_bar => toggleBar(wm), | ||
| 777 | .cycle_layout => cycleLayout(wm), | 805 | .cycle_layout => cycleLayout(wm), |
| 778 | .set_layout => setLayout(str_arg, wm), | 806 | .set_layout => setLayout(str_arg, wm), |
| 779 | .set_layout_tiling => setLayoutIndex(0, wm), | 807 | .set_layout_tiling => setLayoutIndex(0, wm), |
+38 −1 src/wm/core.zig
| @@ -6,6 +6,8 @@ const tiling = @import("../layouts/tiling.zig"); | |||
| 6 | const scrolling = @import("../layouts/scrolling.zig"); | 6 | const scrolling = @import("../layouts/scrolling.zig"); |
| 7 | const window_manager = @import("wm.zig"); | 7 | const window_manager = @import("wm.zig"); |
| 8 | 8 | ||
| 9 | +const config_mod = @import("../config/config.zig"); | ||
| 10 | + | ||
| 9 | const Client = client_mod.Client; | 11 | const Client = client_mod.Client; |
| 10 | const Monitor = monitor_mod.Monitor; | 12 | const Monitor = monitor_mod.Monitor; |
| 11 | const WindowManager = window_manager.WindowManager; | 13 | const WindowManager = window_manager.WindowManager; |
| @@ -38,7 +40,19 @@ pub fn manage(win: xlib.Window, window_attrs: *xlib.XWindowAttributes, wm: *Wind | |||
| 38 | 40 | ||
| 39 | if (client.monitor == null) { | 41 | if (client.monitor == null) { |
| 40 | client.monitor = wm.selected_monitor; | 42 | client.monitor = wm.selected_monitor; |
| 41 | - applyRules(client, wm); | 43 | + if (wm.next_spawn_bypass_rules) { |
| 44 | + if (client.monitor) |monitor| { | ||
| 45 | + client.tags = monitor.tagset[monitor.sel_tags]; | ||
| 46 | + } | ||
| 47 | + wm.next_spawn_bypass_rules = false; | ||
| 48 | + } else { | ||
| 49 | + applyRules(client, wm); | ||
| 50 | + } | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + if (wm.next_spawn_floating) { | ||
| 54 | + client.is_floating = true; | ||
| 55 | + wm.next_spawn_floating = false; | ||
| 42 | } | 56 | } |
| 43 | 57 | ||
| 44 | const monitor = client.monitor orelse return; | 58 | const monitor = client.monitor orelse return; |
| @@ -72,6 +86,7 @@ pub fn manage(win: xlib.Window, window_attrs: *xlib.XWindowAttributes, wm: *Wind | |||
| 72 | client.old_state = client.is_floating; | 86 | client.old_state = client.is_floating; |
| 73 | } | 87 | } |
| 74 | if (client.is_floating) { | 88 | if (client.is_floating) { |
| 89 | + positionFloating(client, monitor, wm.config.floating_position); | ||
| 75 | _ = xlib.XRaiseWindow(wm.display.handle, client.window); | 90 | _ = xlib.XRaiseWindow(wm.display.handle, client.window); |
| 76 | } | 91 | } |
| 77 | 92 | ||
| @@ -432,6 +447,22 @@ pub fn scrollToWindow(client: *Client, animate: bool, wm: *WindowManager) void { | |||
| 432 | } | 447 | } |
| 433 | } | 448 | } |
| 434 | 449 | ||
| 450 | +fn positionFloating(client: *Client, monitor: *Monitor, pos: config_mod.FloatingPosition) void { | ||
| 451 | + const bw = 2 * client.border_width; | ||
| 452 | + const x: i32 = switch (pos) { | ||
| 453 | + .top_left, .center_left, .bottom_left => monitor.win_x, | ||
| 454 | + .top_center, .center, .bottom_center => monitor.win_x + @divTrunc(monitor.win_w - client.width - bw, 2), | ||
| 455 | + .top_right, .center_right, .bottom_right => monitor.win_x + monitor.win_w - client.width - bw, | ||
| 456 | + }; | ||
| 457 | + const y: i32 = switch (pos) { | ||
| 458 | + .top_left, .top_center, .top_right => monitor.win_y, | ||
| 459 | + .center_left, .center, .center_right => monitor.win_y + @divTrunc(monitor.win_h - client.height - bw, 2), | ||
| 460 | + .bottom_left, .bottom_center, .bottom_right => monitor.win_y + monitor.win_h - client.height - bw, | ||
| 461 | + }; | ||
| 462 | + client.x = x; | ||
| 463 | + client.y = y; | ||
| 464 | +} | ||
| 465 | + | ||
| 435 | pub fn applyRules(client: *Client, wm: *WindowManager) void { | 466 | pub fn applyRules(client: *Client, wm: *WindowManager) void { |
| 436 | var class_hint: xlib.XClassHint = .{ .res_name = null, .res_class = null }; | 467 | var class_hint: xlib.XClassHint = .{ .res_name = null, .res_class = null }; |
| 437 | _ = xlib.XGetClassHint(wm.display.handle, client.window, &class_hint); | 468 | _ = xlib.XGetClassHint(wm.display.handle, client.window, &class_hint); |
| @@ -729,6 +760,12 @@ pub fn view(tag_mask: u32, wm: *WindowManager) void { | |||
| 729 | monitor.mfact = monitor.pertag.mfacts[monitor.pertag.curtag]; | 760 | monitor.mfact = monitor.pertag.mfacts[monitor.pertag.curtag]; |
| 730 | monitor.sel_lt = monitor.pertag.sellts[monitor.pertag.curtag]; | 761 | monitor.sel_lt = monitor.pertag.sellts[monitor.pertag.curtag]; |
| 731 | 762 | ||
| 763 | + const new_show_bar = monitor.pertag.showbars[monitor.pertag.curtag]; | ||
| 764 | + if (new_show_bar != monitor.show_bar) { | ||
| 765 | + monitor.show_bar = new_show_bar; | ||
| 766 | + window_manager.actions.updateBarVisibility(monitor, wm); | ||
| 767 | + } | ||
| 768 | + | ||
| 732 | focusTopClient(monitor, wm); | 769 | focusTopClient(monitor, wm); |
| 733 | arrange(monitor, wm); | 770 | arrange(monitor, wm); |
| 734 | wm.invalidateBars(); | 771 | wm.invalidateBars(); |
+4 −0 src/wm/handlers.zig
| @@ -232,6 +232,10 @@ fn handleButtonPress(event: *xlib.XButtonEvent, wm: *WindowManager) void { | |||
| 232 | if (clicked_tag) |tag_index| { | 232 | if (clicked_tag) |tag_index| { |
| 233 | const tag_mask: u32 = @as(u32, 1) << @intCast(tag_index); | 233 | const tag_mask: u32 = @as(u32, 1) << @intCast(tag_index); |
| 234 | core.view(tag_mask, wm); | 234 | core.view(tag_mask, wm); |
| 235 | + } else if (bar.handleBlockClick(event.x)) |click_action| { | ||
| 236 | + wm.next_spawn_floating = click_action.floating; | ||
| 237 | + wm.next_spawn_bypass_rules = click_action.bypass_rules; | ||
| 238 | + actions.spawnCommand(wm, click_action.command); | ||
| 235 | } | 239 | } |
| 236 | return; | 240 | return; |
| 237 | } | 241 | } |
+56 −56 src/wm/wm.zig
| @@ -85,6 +85,8 @@ pub const WindowManager = struct { | |||
| 85 | animation_config: animations.AnimationConfig, | 85 | animation_config: animations.AnimationConfig, |
| 86 | 86 | ||
| 87 | running: bool, | 87 | running: bool, |
| 88 | + next_spawn_floating: bool = false, | ||
| 89 | + next_spawn_bypass_rules: bool = false, | ||
| 88 | last_motion_monitor: ?*Monitor, | 90 | last_motion_monitor: ?*Monitor, |
| 89 | 91 | ||
| 90 | /// Initialises the window manager | 92 | /// Initialises the window manager |
| @@ -159,43 +161,65 @@ pub const WindowManager = struct { | |||
| 159 | self.config.deinit(); | 161 | self.config.deinit(); |
| 160 | } | 162 | } |
| 161 | 163 | ||
| 164 | + const layouts = [_]*const monitor_mod.Layout{ | ||
| 165 | + &tiling.layout, | ||
| 166 | + &monocle.layout, | ||
| 167 | + &floating.layout, | ||
| 168 | + &scrolling.layout, | ||
| 169 | + &grid.layout, | ||
| 170 | + }; | ||
| 171 | + | ||
| 172 | + fn initMonitor(self: *WindowManager, mon: *Monitor, num: usize, x: i16, y: i16, w: c_int, h: c_int) void { | ||
| 173 | + mon.num = @intCast(num); | ||
| 174 | + mon.mon_x = x; | ||
| 175 | + mon.mon_y = y; | ||
| 176 | + mon.mon_w = w; | ||
| 177 | + mon.mon_h = h; | ||
| 178 | + mon.win_x = x; | ||
| 179 | + mon.win_y = y; | ||
| 180 | + mon.win_w = w; | ||
| 181 | + mon.win_h = h; | ||
| 182 | + | ||
| 183 | + for (&mon.lt, layouts) |*slot, layout| { | ||
| 184 | + slot.* = layout; | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + if (config_mod.Layouts.fromString(self.config.layout)) |value| { | ||
| 188 | + mon.sel_lt = @intFromEnum(value); | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + for (0..10) |i| { | ||
| 192 | + for (0..layouts.len) |j| { | ||
| 193 | + mon.pertag.ltidxs[i][j] = mon.lt[j]; | ||
| 194 | + } | ||
| 195 | + mon.pertag.sellts[i] = mon.sel_lt; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + for (self.config.tag_layouts, 0..) |maybe_layout, i| { | ||
| 199 | + if (maybe_layout) |layout_name| { | ||
| 200 | + if (config_mod.Layouts.fromString(layout_name)) |value| { | ||
| 201 | + mon.pertag.sellts[i + 1] = @intFromEnum(value); | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + self.initMonitorGaps(mon); | ||
| 207 | + } | ||
| 208 | + | ||
| 162 | fn setupMonitors(self: *WindowManager) void { | 209 | fn setupMonitors(self: *WindowManager) void { |
| 163 | if (xlib.XineramaIsActive(self.display.handle) != 0) { | 210 | if (xlib.XineramaIsActive(self.display.handle) != 0) { |
| 164 | var screen_count: c_int = 0; | 211 | var screen_count: c_int = 0; |
| 165 | const screens = xlib.XineramaQueryScreens(self.display.handle, &screen_count); | 212 | const screens = xlib.XineramaQueryScreens(self.display.handle, &screen_count); |
| 213 | + defer if (screens != null) { | ||
| 214 | + _ = xlib.XFree(@ptrCast(screens)); | ||
| 215 | + }; | ||
| 166 | 216 | ||
| 167 | if (screen_count > 0 and screens != null) { | 217 | if (screen_count > 0 and screens != null) { |
| 168 | var prev_monitor: ?*Monitor = null; | 218 | var prev_monitor: ?*Monitor = null; |
| 169 | - var index: usize = 0; | 219 | + for (0..@as(usize, @intCast(screen_count))) |index| { |
| 170 | - | ||
| 171 | - while (index < @as(usize, @intCast(screen_count))) : (index += 1) { | ||
| 172 | const screen = screens[index]; | 220 | const screen = screens[index]; |
| 173 | const mon = monitor_mod.create(self.allocator) orelse continue; | 221 | const mon = monitor_mod.create(self.allocator) orelse continue; |
| 174 | - | 222 | + self.initMonitor(mon, index, screen.x_org, screen.y_org, screen.width, screen.height); |
| 175 | - mon.num = @intCast(index); | ||
| 176 | - mon.mon_x = screen.x_org; | ||
| 177 | - mon.mon_y = screen.y_org; | ||
| 178 | - mon.mon_w = screen.width; | ||
| 179 | - mon.mon_h = screen.height; | ||
| 180 | - mon.win_x = screen.x_org; | ||
| 181 | - mon.win_y = screen.y_org; | ||
| 182 | - mon.win_w = screen.width; | ||
| 183 | - mon.win_h = screen.height; | ||
| 184 | - mon.lt[0] = &tiling.layout; | ||
| 185 | - mon.lt[1] = &monocle.layout; | ||
| 186 | - mon.lt[2] = &floating.layout; | ||
| 187 | - mon.lt[3] = &scrolling.layout; | ||
| 188 | - mon.lt[4] = &grid.layout; | ||
| 189 | - | ||
| 190 | - for (0..10) |i| { | ||
| 191 | - mon.pertag.ltidxs[i][0] = mon.lt[0]; | ||
| 192 | - mon.pertag.ltidxs[i][1] = mon.lt[1]; | ||
| 193 | - mon.pertag.ltidxs[i][2] = mon.lt[2]; | ||
| 194 | - mon.pertag.ltidxs[i][3] = mon.lt[3]; | ||
| 195 | - mon.pertag.ltidxs[i][4] = mon.lt[4]; | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - self.initMonitorGaps(mon); | ||
| 199 | 223 | ||
| 200 | if (prev_monitor) |prev| { | 224 | if (prev_monitor) |prev| { |
| 201 | prev.next = mon; | 225 | prev.next = mon; |
| @@ -205,38 +229,12 @@ pub const WindowManager = struct { | |||
| 205 | } | 229 | } |
| 206 | prev_monitor = mon; | 230 | prev_monitor = mon; |
| 207 | } | 231 | } |
| 208 | - | ||
| 209 | - _ = xlib.XFree(@ptrCast(screens)); | ||
| 210 | } | 232 | } |
| 211 | } | 233 | } |
| 212 | 234 | ||
| 213 | - // Fallback: single monitor covering the full screen. | ||
| 214 | if (self.monitors == null) { | 235 | if (self.monitors == null) { |
| 215 | const mon = monitor_mod.create(self.allocator) orelse return; | 236 | const mon = monitor_mod.create(self.allocator) orelse return; |
| 216 | - mon.num = 0; | 237 | + self.initMonitor(mon, 0, 0, 0, self.display.screenWidth(), self.display.screenHeight()); |
| 217 | - mon.mon_x = 0; | ||
| 218 | - mon.mon_y = 0; | ||
| 219 | - mon.mon_w = self.display.screenWidth(); | ||
| 220 | - mon.mon_h = self.display.screenHeight(); | ||
| 221 | - mon.win_x = 0; | ||
| 222 | - mon.win_y = 0; | ||
| 223 | - mon.win_w = mon.mon_w; | ||
| 224 | - mon.win_h = mon.mon_h; | ||
| 225 | - mon.lt[0] = &tiling.layout; | ||
| 226 | - mon.lt[1] = &monocle.layout; | ||
| 227 | - mon.lt[2] = &floating.layout; | ||
| 228 | - mon.lt[3] = &scrolling.layout; | ||
| 229 | - mon.lt[4] = &grid.layout; | ||
| 230 | - | ||
| 231 | - for (0..10) |i| { | ||
| 232 | - mon.pertag.ltidxs[i][0] = mon.lt[0]; | ||
| 233 | - mon.pertag.ltidxs[i][1] = mon.lt[1]; | ||
| 234 | - mon.pertag.ltidxs[i][2] = mon.lt[2]; | ||
| 235 | - mon.pertag.ltidxs[i][3] = mon.lt[3]; | ||
| 236 | - mon.pertag.ltidxs[i][4] = mon.lt[4]; | ||
| 237 | - } | ||
| 238 | - | ||
| 239 | - self.initMonitorGaps(mon); | ||
| 240 | self.monitors = mon; | 238 | self.monitors = mon; |
| 241 | self.selected_monitor = mon; | 239 | self.selected_monitor = mon; |
| 242 | } | 240 | } |
| @@ -714,7 +712,7 @@ pub const WindowManager = struct { | |||
| 714 | 712 | ||
| 715 | /// Converts a config block description into a live status bar block. | 713 | /// Converts a config block description into a live status bar block. |
| 716 | pub fn configBlockToBarBlock(cfg: config_mod.Block) blocks_mod.Block { | 714 | pub fn configBlockToBarBlock(cfg: config_mod.Block) blocks_mod.Block { |
| 717 | - return switch (cfg.block_type) { | 715 | + var block = switch (cfg.block_type) { |
| 718 | .static => blocks_mod.Block.initStatic(cfg.format, cfg.color, cfg.underline), | 716 | .static => blocks_mod.Block.initStatic(cfg.format, cfg.color, cfg.underline), |
| 719 | .datetime => blocks_mod.Block.initDatetime( | 717 | .datetime => blocks_mod.Block.initDatetime( |
| 720 | cfg.format, | 718 | cfg.format, |
| @@ -748,4 +746,6 @@ pub fn configBlockToBarBlock(cfg: config_mod.Block) blocks_mod.Block { | |||
| 748 | cfg.underline, | 746 | cfg.underline, |
| 749 | ), | 747 | ), |
| 750 | }; | 748 | }; |
| 749 | + block.click = cfg.click; | ||
| 750 | + return block; | ||
| 751 | } | 751 | } |
+1 −0 src/x11/xlib.zig
| @@ -42,6 +42,7 @@ pub const XQueryTree = c.XQueryTree; | |||
| 42 | pub const XFree = c.XFree; | 42 | pub const XFree = c.XFree; |
| 43 | pub const XGetWindowAttributes = c.XGetWindowAttributes; | 43 | pub const XGetWindowAttributes = c.XGetWindowAttributes; |
| 44 | pub const XMapWindow = c.XMapWindow; | 44 | pub const XMapWindow = c.XMapWindow; |
| 45 | +pub const XUnmapWindow = c.XUnmapWindow; | ||
| 45 | pub const XConfigureWindow = c.XConfigureWindow; | 46 | pub const XConfigureWindow = c.XConfigureWindow; |
| 46 | pub const XSetInputFocus = c.XSetInputFocus; | 47 | pub const XSetInputFocus = c.XSetInputFocus; |
| 47 | pub const XRaiseWindow = c.XRaiseWindow; | 48 | pub const XRaiseWindow = c.XRaiseWindow; |
+19 −0 templates/config.lua
| @@ -92,6 +92,9 @@ local blocks = { | |||
| 92 | interval = 30, | 92 | interval = 30, |
| 93 | color = colors.green, | 93 | color = colors.green, |
| 94 | underline = true, | 94 | underline = true, |
| 95 | + -- click: run a command when the block is clicked | ||
| 96 | + -- click = "alacritty -e btop", | ||
| 97 | + -- click = { command = "bluetui", floating = true }, | ||
| 95 | }), | 98 | }), |
| 96 | }; | 99 | }; |
| 97 | 100 | ||
| @@ -102,6 +105,9 @@ oxwm.set_terminal(terminal) | |||
| 102 | oxwm.set_modkey(modkey) -- This is for Mod + mouse binds, such as drag/resize | 105 | oxwm.set_modkey(modkey) -- This is for Mod + mouse binds, such as drag/resize |
| 103 | oxwm.set_tags(tags) | 106 | oxwm.set_tags(tags) |
| 104 | 107 | ||
| 108 | +-- Set default layout (tiling by default) | ||
| 109 | +-- oxwm.set_layout("tiling") | ||
| 110 | + | ||
| 105 | ------------------------------------------------------------------------------- | 111 | ------------------------------------------------------------------------------- |
| 106 | -- Layouts | 112 | -- Layouts |
| 107 | ------------------------------------------------------------------------------- | 113 | ------------------------------------------------------------------------------- |
| @@ -111,6 +117,10 @@ oxwm.set_layout_symbol("tiling", "[T]") | |||
| 111 | oxwm.set_layout_symbol("normie", "[F]") | 117 | oxwm.set_layout_symbol("normie", "[F]") |
| 112 | oxwm.set_layout_symbol("tabbed", "[=]") | 118 | oxwm.set_layout_symbol("tabbed", "[=]") |
| 113 | 119 | ||
| 120 | +-- Set default layout of specific tag (tag_index, layout_name) | ||
| 121 | +-- Unset value uses oxwm.set_layout value | ||
| 122 | +-- oxwm.set_tag_layout(1, "grid") | ||
| 123 | + | ||
| 114 | ------------------------------------------------------------------------------- | 124 | ------------------------------------------------------------------------------- |
| 115 | -- Appearance | 125 | -- Appearance |
| 116 | ------------------------------------------------------------------------------- | 126 | ------------------------------------------------------------------------------- |
| @@ -123,6 +133,10 @@ oxwm.border.set_focused_color(colors.blue) | |||
| 123 | -- Color of unfocused window borders | 133 | -- Color of unfocused window borders |
| 124 | oxwm.border.set_unfocused_color(colors.grey) | 134 | oxwm.border.set_unfocused_color(colors.grey) |
| 125 | 135 | ||
| 136 | +-- Where floating windows spawn: "top-left", "top-center", "top-right", | ||
| 137 | +-- "center-left", "center", "center-right", "bottom-left", "bottom-center", "bottom-right" | ||
| 138 | +oxwm.set_floating_position("center") | ||
| 139 | + | ||
| 126 | -- Smart Enabled = No border if 1 window | 140 | -- Smart Enabled = No border if 1 window |
| 127 | oxwm.gaps.set_smart(enabled) | 141 | oxwm.gaps.set_smart(enabled) |
| 128 | -- Inner gaps (horizontal, vertical) in pixels | 142 | -- Inner gaps (horizontal, vertical) in pixels |
| @@ -158,6 +172,9 @@ oxwm.rule.add({ instance = "gimp", floating = true }) | |||
| 158 | -- Font configuration | 172 | -- Font configuration |
| 159 | oxwm.bar.set_font(bar_font) | 173 | oxwm.bar.set_font(bar_font) |
| 160 | 174 | ||
| 175 | +-- Position configuration (top/bottom, top is default) | ||
| 176 | +-- oxwm.bar.set_position("bottom") | ||
| 177 | + | ||
| 161 | -- Set your blocks here (defined above) | 178 | -- Set your blocks here (defined above) |
| 162 | oxwm.bar.set_blocks(blocks) | 179 | oxwm.bar.set_blocks(blocks) |
| 163 | 180 | ||
| @@ -222,6 +239,8 @@ oxwm.key.bind({ modkey }, "P", oxwm.inc_num_master(-1)) | |||
| 222 | 239 | ||
| 223 | -- Gaps toggle | 240 | -- Gaps toggle |
| 224 | oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps()) | 241 | oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps()) |
| 242 | +-- Bar toggle | ||
| 243 | +oxwm.key.bind({ modkey }, "B", oxwm.toggle_bar()) | ||
| 225 | 244 | ||
| 226 | -- Window manager controls | 245 | -- Window manager controls |
| 227 | oxwm.key.bind({ modkey, "Shift" }, "Q", oxwm.quit()) | 246 | oxwm.key.bind({ modkey, "Shift" }, "Q", oxwm.quit()) |
+26 −5 templates/oxwm.lua
| @@ -50,6 +50,23 @@ function oxwm.tiled_resize_mode(enabled) end | |||
| 50 | ---@param symbol string Symbol to display (e.g., "[T]", "[F]", "[=]") | 50 | ---@param symbol string Symbol to display (e.g., "[T]", "[F]", "[=]") |
| 51 | function oxwm.set_layout_symbol(name, symbol) end | 51 | function oxwm.set_layout_symbol(name, symbol) end |
| 52 | 52 | ||
| 53 | +---Set default layout for all tags | ||
| 54 | +---@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", or aliases: "tile", "float", "scroll", "normie") | ||
| 55 | +function oxwm.set_layout(name) end | ||
| 56 | + | ||
| 57 | +---Set default layout for a specific tag | ||
| 58 | +---@param tag integer Tag index (1-9) | ||
| 59 | +---@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", or aliases) | ||
| 60 | +function oxwm.set_tag_layout(tag, name) end | ||
| 61 | + | ||
| 62 | +---Set floating window spawn position | ||
| 63 | +---@param position string Position ("center", "top-left", "top-right", "bottom-left", "bottom-right", "top-center", "bottom-center", "center-left", "center-right", or underscore variants) | ||
| 64 | +function oxwm.set_floating_position(position) end | ||
| 65 | + | ||
| 66 | +---Toggle the status bar visibility | ||
| 67 | +---@return table Action table for keybinding | ||
| 68 | +function oxwm.toggle_bar() end | ||
| 69 | + | ||
| 53 | ---Window rule module | 70 | ---Window rule module |
| 54 | ---@class oxwm.rule | 71 | ---@class oxwm.rule |
| 55 | oxwm.rule = {} | 72 | oxwm.rule = {} |
| @@ -260,6 +277,10 @@ oxwm.bar = {} | |||
| 260 | ---@param font string Font string (e.g., "monospace:style=Bold:size=10") | 277 | ---@param font string Font string (e.g., "monospace:style=Bold:size=10") |
| 261 | function oxwm.bar.set_font(font) end | 278 | function oxwm.bar.set_font(font) end |
| 262 | 279 | ||
| 280 | +---Set status bar position | ||
| 281 | +---@param position string Bar position ("top" or "bottom") | ||
| 282 | +function oxwm.bar.set_position(position) end | ||
| 283 | + | ||
| 263 | ---DEPRECATED: Add a status bar block (use oxwm.bar.set_blocks with block constructors instead) | 284 | ---DEPRECATED: Add a status bar block (use oxwm.bar.set_blocks with block constructors instead) |
| 264 | ---@deprecated | 285 | ---@deprecated |
| 265 | ---@param format string Format string with {} placeholders | 286 | ---@param format string Format string with {} placeholders |
| @@ -279,27 +300,27 @@ function oxwm.bar.set_blocks(blocks) end | |||
| 279 | oxwm.bar.block = {} | 300 | oxwm.bar.block = {} |
| 280 | 301 | ||
| 281 | ---Create a RAM usage block | 302 | ---Create a RAM usage block |
| 282 | ----@param config {format: string, interval: integer, color: string|integer, underline: boolean} Block configuration | 303 | +---@param config {format: string, interval: integer, color: string|integer, underline: boolean, click: string|{command: string, floating: boolean?, bypass_rules: boolean?}?} Block configuration |
| 283 | ---@return table Block configuration | 304 | ---@return table Block configuration |
| 284 | function oxwm.bar.block.ram(config) end | 305 | function oxwm.bar.block.ram(config) end |
| 285 | 306 | ||
| 286 | ---Create a date/time block | 307 | ---Create a date/time block |
| 287 | ----@param config {format: string, date_format: string, interval: integer, color: string|integer, underline: boolean} Block configuration (format is display template with {}, date_format is strftime format) | 308 | +---@param config {format: string, date_format: string, interval: integer, color: string|integer, underline: boolean, click: string|{command: string, floating: boolean?, bypass_rules: boolean?}?} Block configuration (format is display template with {}, date_format is strftime format) |
| 288 | ---@return table Block configuration | 309 | ---@return table Block configuration |
| 289 | function oxwm.bar.block.datetime(config) end | 310 | function oxwm.bar.block.datetime(config) end |
| 290 | 311 | ||
| 291 | ---Create a shell command block | 312 | ---Create a shell command block |
| 292 | ----@param config {format: string, command: string, interval: integer, color: string|integer, underline: boolean} Block configuration | 313 | +---@param config {format: string, command: string, interval: integer, color: string|integer, underline: boolean, click: string|{command: string, floating: boolean?, bypass_rules: boolean?}?} Block configuration |
| 293 | ---@return table Block configuration | 314 | ---@return table Block configuration |
| 294 | function oxwm.bar.block.shell(config) end | 315 | function oxwm.bar.block.shell(config) end |
| 295 | 316 | ||
| 296 | ---Create a static text block | 317 | ---Create a static text block |
| 297 | ----@param config {format: string, text: string, interval: integer, color: string|integer, underline: boolean} Block configuration | 318 | +---@param config {format: string, text: string, interval: integer, color: string|integer, underline: boolean, click: string|{command: string, floating: boolean?, bypass_rules: boolean?}?} Block configuration |
| 298 | ---@return table Block configuration | 319 | ---@return table Block configuration |
| 299 | function oxwm.bar.block.static(config) end | 320 | function oxwm.bar.block.static(config) end |
| 300 | 321 | ||
| 301 | ---Create a battery status block | 322 | ---Create a battery status block |
| 302 | ----@param config {format: string, charging: string, discharging: string, full: string, interval: integer, color: string|integer, underline: boolean, battery_name: string} Block configuration | 323 | +---@param config {format: string, charging: string, discharging: string, full: string, interval: integer, color: string|integer, underline: boolean, battery_name: string, click: string|{command: string, floating: boolean?, bypass_rules: boolean?}?} Block configuration |
| 303 | ---@return table Block configuration | 324 | ---@return table Block configuration |
| 304 | function oxwm.bar.block.battery(config) end | 325 | function oxwm.bar.block.battery(config) end |
| 305 | 326 | ||