Diff
diff --git a/src/bar/bar.zig b/src/bar/bar.zig
index 8c036af..a4b1366 100644
--- a/src/bar/bar.zig
+++ b/src/bar/bar.zig
@@ -9,9 +9,8 @@ const ColorScheme = config_mod.ColorScheme;
const Monitor = monitor_mod.Monitor;
const Block = blocks_mod.Block;
-fn get_layout_symbol(layout_index: u32) []const u8 {
- const cfg = config_mod.get_config();
- if (cfg) |conf| {
+fn get_layout_symbol(layout_index: u32, config: ?config_mod.Config) []const u8 {
+ if (config) |conf| {
return switch (layout_index) {
0 => conf.layout_tile_symbol,
1 => conf.layout_monocle_symbol,
@@ -162,7 +161,7 @@ pub const Bar = struct {
self.needs_redraw = true;
}
- pub fn draw(self: *Bar, display: *xlib.Display, tags: []const []const u8) void {
+ pub fn draw(self: *Bar, display: *xlib.Display, tags: []const []const u8, config: ?config_mod.Config) void {
if (!self.needs_redraw) return;
self.fill_rect(display, 0, 0, self.width, self.height, self.scheme_normal.background);
@@ -196,7 +195,7 @@ pub const Bar = struct {
x_position += padding;
- const layout_symbol = get_layout_symbol(monitor.sel_lt);
+ const layout_symbol = get_layout_symbol(monitor.sel_lt, config);
self.draw_text(display, x_position, @divTrunc(self.height + self.font_height, 2) - 4, layout_symbol, self.scheme_normal.foreground);
x_position += self.text_width(display, layout_symbol) + padding;
@@ -326,7 +325,7 @@ pub fn draw_bars(display: *xlib.Display, tags: []const []const u8) void {
while (current_monitor) |monitor| {
_ = monitor;
if (bars) |bar| {
- bar.draw(display, tags);
+ bar.draw(display, tags, null);
}
current_monitor = if (current_monitor) |m| m.next else null;
}
diff --git a/src/config/config.zig b/src/config/config.zig
index 3c5f573..8896a76 100644
--- a/src/config/config.zig
+++ b/src/config/config.zig
@@ -184,13 +184,3 @@ pub const Config = struct {
try self.autostart.append(self.allocator, cmd);
}
};
-
-pub var global_config: ?*Config = null;
-
-pub fn get_config() ?*Config {
- return global_config;
-}
-
-pub fn set_config(cfg: *Config) void {
- global_config = cfg;
-}
diff --git a/src/main.zig b/src/main.zig
index 6c1764d..84f2f38 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -213,7 +213,6 @@ pub fn main() !void {
config = config_mod.Config.init(allocator);
defer config.deinit();
- config_mod.set_config(&config);
if (lua.init(&config)) {
const loaded = if (std.fs.cwd().statFile(config_path)) |_|
@@ -711,7 +710,7 @@ fn run_event_loop(display: *Display) void {
var current_bar = bar_mod.bars;
while (current_bar) |bar| {
bar.update_blocks();
- bar.draw(display.handle, &tags);
+ bar.draw(display.handle, &tags, config);
current_bar = bar.next;
}
@@ -1011,7 +1010,7 @@ fn execute_action(display: *Display, action: config_mod.Action, int_arg: i32, st
if (keybind_overlay) |overlay| {
const mon = monitor_mod.selected_monitor orelse monitor_mod.monitors;
if (mon) |m| {
- overlay.toggle(m.mon_x, m.mon_y, m.mon_w, m.mon_h);
+ overlay.toggle(m.mon_x, m.mon_y, m.mon_w, m.mon_h, &config);
}
}
},
@@ -1860,7 +1859,7 @@ fn handle_expose(display: *Display, event: *xlib.XExposeEvent) void {
if (bar_mod.window_to_bar(event.window)) |bar| {
bar.invalidate();
- bar.draw(display.handle, &tags);
+ bar.draw(display.handle, &tags, config);
}
}
diff --git a/src/overlay.zig b/src/overlay.zig
index dcf934c..7e72892 100644
--- a/src/overlay.zig
+++ b/src/overlay.zig
@@ -89,19 +89,18 @@ pub const Keybind_Overlay = struct {
}
}
- pub fn toggle(self: *Keybind_Overlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32) void {
+ pub fn toggle(self: *Keybind_Overlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void {
if (self.visible) {
self.hide();
} else {
- self.show(mon_x, mon_y, mon_w, mon_h);
+ self.show(mon_x, mon_y, mon_w, mon_h, config);
}
}
- pub fn show(self: *Keybind_Overlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32) void {
+ pub fn show(self: *Keybind_Overlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void {
const display = self.display orelse return;
- const cfg = config_mod.get_config() orelse return;
- self.collect_keybinds(cfg);
+ self.collect_keybinds(config);
if (self.line_count == 0) return;
var max_key_width: i32 = 0;