tony / oxwm

implements #135 : set bar position Browse files
Iziram committed 2026-03-07 parent b2691e8 commit d41b5511baed10db58e85f7102b5fb6419f4fc14
Showing 4 changed files with 29 additions and 2 deletions. UnifiedSplit
+13 −2 src/bar/bar.zig
@@ -73,11 +73,23 @@ pub const Bar = struct {
73 73 const font_height = font.*.ascent + font.*.descent;
74 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.mon_y = monitor.mon_y + bar_height;
81 + } else if (std.mem.eql(u8, config.bar_position, "bottom")) {
82 + bar_y = monitor.mon_h - bar_height;
83 + monitor.mon_y = 0;
84 + } else {
85 + return null;
86 + }
87 +
76 88 const window = xlib.c.XCreateSimpleWindow(
77 89 display,
78 90 root,
79 91 monitor.mon_x,
80 - monitor.mon_y,
92 + bar_y,
81 93 @intCast(monitor.mon_w),
82 94 @intCast(bar_height),
83 95 0,
@@ -125,7 +137,6 @@ pub const Bar = struct {
125 137 };
126 138
127 139 monitor.bar_win = window;
128 - monitor.win_y = monitor.mon_y + bar_height;
129 140 monitor.win_h = monitor.mon_h - bar_height;
130 141
131 142 return bar;
+1 −0 src/config/config.zig
@@ -122,6 +122,7 @@ pub const Config = struct {
122 122
123 123 terminal: []const u8 = "st",
124 124 font: []const u8 = "monospace:size=10",
125 + bar_position: []const u8 = "top",
125 126 tags: [9][]const u8 = .{ "1", "2", "3", "4", "5", "6", "7", "8", "9" },
126 127 layout: []const u8 = "tiling",
127 128
+12 −0 src/config/lua.zig
@@ -274,6 +274,9 @@ fn registerBarModule(state: *c.lua_State) void {
274 274 c.lua_pushcfunction(state, luaBarSetHideVacantTags);
275 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 280 c.lua_createtable(state, 0, 6);
278 281
279 282 c.lua_pushcfunction(state, luaBarBlockRam);
@@ -755,6 +758,15 @@ fn luaBarSetFont(state: ?*c.lua_State) callconv(.c) c_int {
755 758 return 0;
756 759 }
757 760
761 +fn luaBarSetPosition(state: ?*c.lua_State) callconv(.c) c_int {
762 + const cfg = config orelse return 0;
763 + const s = state orelse return 0;
764 + if (dupeLuaString(s, 1)) |position| {
765 + cfg.bar_position = position;
766 + }
767 + return 0;
768 +}
769 +
758 770 fn luaBarSetBlocks(state: ?*c.lua_State) callconv(.c) c_int {
759 771 const cfg = config orelse return 0;
760 772 const s = state orelse return 0;
+3 −0 templates/config.lua
@@ -161,6 +161,9 @@ oxwm.rule.add({ instance = "gimp", floating = true })
161 161 -- Font configuration
162 162 oxwm.bar.set_font(bar_font)
163 163
164 +-- Position configuration (top/bottom, top is default)
165 +-- oxwm.bar.set_position("bottom")
166 +
164 167 -- Set your blocks here (defined above)
165 168 oxwm.bar.set_blocks(blocks)
166 169