tony / oxwm

treewide: change type names to be title case Browse files
emzywastaken committed 2026-02-23 parent b3ae92e commit 2707423c50a45f033b8b14b9cbae7284b2cd22bf
Showing 9 changed files with 61 additions and 61 deletions. UnifiedSplit
+7 −7 src/animations.zig
@@ -17,12 +17,12 @@ pub const Easing = enum {
17 17 }
18 18 };
19 19
20 -pub const Animation_Config = struct {
20 +pub const AnimationConfig = struct {
21 21 duration_ms: u64 = 150,
22 22 easing: Easing = .ease_out,
23 23 };
24 24
25 -pub const Scroll_Animation = struct {
25 +pub const ScrollAnimation = struct {
26 26 start_value: i32 = 0,
27 27 end_value: i32 = 0,
28 28 start_time: i64 = 0,
@@ -30,7 +30,7 @@ pub const Scroll_Animation = struct {
30 30 easing: Easing = .ease_out,
31 31 active: bool = false,
32 32
33 - pub fn start(self: *Scroll_Animation, from: i32, to: i32, config: Animation_Config) void {
33 + pub fn start(self: *ScrollAnimation, from: i32, to: i32, config: AnimationConfig) void {
34 34 if (from == to) {
35 35 self.active = false;
36 36 return;
@@ -43,7 +43,7 @@ pub const Scroll_Animation = struct {
43 43 self.active = true;
44 44 }
45 45
46 - pub fn update(self: *Scroll_Animation) ?i32 {
46 + pub fn update(self: *ScrollAnimation) ?i32 {
47 47 if (!self.active) return null;
48 48
49 49 const now = std.time.milliTimestamp();
@@ -62,15 +62,15 @@ pub const Scroll_Animation = struct {
62 62 return @intFromFloat(current);
63 63 }
64 64
65 - pub fn isActive(self: *const Scroll_Animation) bool {
65 + pub fn isActive(self: *const ScrollAnimation) bool {
66 66 return self.active;
67 67 }
68 68
69 - pub fn target(self: *const Scroll_Animation) i32 {
69 + pub fn target(self: *const ScrollAnimation) i32 {
70 70 return self.end_value;
71 71 }
72 72
73 - pub fn stop(self: *Scroll_Animation) void {
73 + pub fn stop(self: *ScrollAnimation) void {
74 74 self.active = false;
75 75 }
76 76 };
+2 −2 src/bar/blocks/blocks.zig
@@ -1,11 +1,11 @@
1 1 const std = @import("std");
2 2
3 3 pub const Static = @import("static.zig").Static;
4 -pub const Date_Time = @import("datetime.zig").Date_Time;
4 +pub const Date_Time = @import("datetime.zig").DateTime;
5 5 pub const Ram = @import("ram.zig").Ram;
6 6 pub const Shell = @import("shell.zig").Shell;
7 7 pub const Battery = @import("battery.zig").Battery;
8 -pub const Cpu_Temp = @import("cpu_temp.zig").Cpu_Temp;
8 +pub const Cpu_Temp = @import("cpu_temp.zig").CpuTemp;
9 9
10 10 pub const Block = struct {
11 11 data: Data,
+9 −9 src/bar/blocks/cpu_temp.zig
@@ -1,7 +1,7 @@
1 1 const std = @import("std");
2 2 const format_util = @import("format.zig");
3 3
4 -pub const Cpu_Temp = struct {
4 +pub const CpuTemp = struct {
5 5 format: []const u8,
6 6 device: []const u8,
7 7 interval_secs: u64,
@@ -14,8 +14,8 @@ pub const Cpu_Temp = struct {
14 14 device: []const u8,
15 15 interval_secs: u64,
16 16 color: c_ulong,
17 - ) Cpu_Temp {
18 - var self = Cpu_Temp{
17 + ) CpuTemp {
18 + var self = CpuTemp{
19 19 .format = format,
20 20 .device = device,
21 21 .interval_secs = interval_secs,
@@ -27,7 +27,7 @@ pub const Cpu_Temp = struct {
27 27 return self;
28 28 }
29 29
30 - fn detectPath(self: *Cpu_Temp) void {
30 + fn detectPath(self: *CpuTemp) void {
31 31 if (self.device.len > 0 and self.device[0] == '/') {
32 32 if (self.device.len <= self.cached_path.len) {
33 33 @memcpy(self.cached_path[0..self.device.len], self.device);
@@ -46,7 +46,7 @@ pub const Cpu_Temp = struct {
46 46 if (self.tryPath("/sys/class/thermal/{s}/temp", "thermal_zone0")) return;
47 47 }
48 48
49 - fn tryPath(self: *Cpu_Temp, comptime fmt: []const u8, device: []const u8) bool {
49 + fn tryPath(self: *CpuTemp, comptime fmt: []const u8, device: []const u8) bool {
50 50 const path = std.fmt.bufPrint(&self.cached_path, fmt, .{device}) catch return false;
51 51 const file = std.fs.openFileAbsolute(path, .{}) catch return false;
52 52 file.close();
@@ -54,7 +54,7 @@ pub const Cpu_Temp = struct {
54 54 return true;
55 55 }
56 56
57 - fn findHwmonCpu(self: *Cpu_Temp) bool {
57 + fn findHwmonCpu(self: *CpuTemp) bool {
58 58 var dir = std.fs.openDirAbsolute("/sys/class/hwmon", .{ .iterate = true }) catch return false;
59 59 defer dir.close();
60 60
@@ -83,7 +83,7 @@ pub const Cpu_Temp = struct {
83 83 return false;
84 84 }
85 85
86 - pub fn content(self: *Cpu_Temp, buffer: []u8) []const u8 {
86 + pub fn content(self: *CpuTemp, buffer: []u8) []const u8 {
87 87 if (self.cached_path_len == 0) return buffer[0..0];
88 88
89 89 const path = self.cached_path[0..self.cached_path_len];
@@ -103,11 +103,11 @@ pub const Cpu_Temp = struct {
103 103 return format_util.substitute(self.format, deg_str, buffer);
104 104 }
105 105
106 - pub fn interval(self: *Cpu_Temp) u64 {
106 + pub fn interval(self: *CpuTemp) u64 {
107 107 return self.interval_secs;
108 108 }
109 109
110 - pub fn getColor(self: *Cpu_Temp) c_ulong {
110 + pub fn getColor(self: *CpuTemp) c_ulong {
111 111 return self.color;
112 112 }
113 113 };
+5 −5 src/bar/blocks/datetime.zig
@@ -4,13 +4,13 @@ const c = @cImport({
4 4 @cInclude("time.h");
5 5 });
6 6
7 -pub const Date_Time = struct {
7 +pub const DateTime = struct {
8 8 format: []const u8,
9 9 datetime_format: []const u8,
10 10 interval_secs: u64,
11 11 color: c_ulong,
12 12
13 - pub fn init(format: []const u8, datetime_format: []const u8, interval_secs: u64, color: c_ulong) Date_Time {
13 + pub fn init(format: []const u8, datetime_format: []const u8, interval_secs: u64, color: c_ulong) DateTime {
14 14 return .{
15 15 .format = format,
16 16 .datetime_format = datetime_format,
@@ -19,7 +19,7 @@ pub const Date_Time = struct {
19 19 };
20 20 }
21 21
22 - pub fn content(self: *Date_Time, buffer: []u8) []const u8 {
22 + pub fn content(self: *DateTime, buffer: []u8) []const u8 {
23 23 var now: c.time_t = c.time(null);
24 24 const tm_ptr = c.localtime(&now);
25 25 if (tm_ptr == null) return buffer[0..0];
@@ -97,11 +97,11 @@ pub const Date_Time = struct {
97 97 };
98 98 }
99 99
100 - pub fn interval(self: *Date_Time) u64 {
100 + pub fn interval(self: *DateTime) u64 {
101 101 return self.interval_secs;
102 102 }
103 103
104 - pub fn getColor(self: *Date_Time) c_ulong {
104 + pub fn getColor(self: *DateTime) c_ulong {
105 105 return self.color;
106 106 }
107 107 };
+11 −11 src/config/config.zig
@@ -36,13 +36,13 @@ pub const Action = enum {
36 36 scroll_right,
37 37 };
38 38
39 -pub const Key_Press = struct {
39 +pub const KeyPress = struct {
40 40 mod_mask: u32 = 0,
41 41 keysym: u64 = 0,
42 42 };
43 43
44 44 pub const Keybind = struct {
45 - keys: [4]Key_Press = [_]Key_Press{.{}} ** 4,
45 + keys: [4]KeyPress = [_]KeyPress{.{}} ** 4,
46 46 key_count: u8 = 1,
47 47 action: Action,
48 48 int_arg: i32 = 0,
@@ -59,7 +59,7 @@ pub const Rule = struct {
59 59 focus: bool,
60 60 };
61 61
62 -pub const Block_Type = enum {
62 +pub const BlockType = enum {
63 63 static,
64 64 datetime,
65 65 ram,
@@ -68,27 +68,27 @@ pub const Block_Type = enum {
68 68 cpu_temp,
69 69 };
70 70
71 -pub const Click_Target = enum {
71 +pub const ClickTarget = enum {
72 72 client_win,
73 73 root_win,
74 74 tag_bar,
75 75 };
76 76
77 -pub const Mouse_Action = enum {
77 +pub const MouseAction = enum {
78 78 move_mouse,
79 79 resize_mouse,
80 80 toggle_floating,
81 81 };
82 82
83 -pub const Mouse_Button = struct {
84 - click: Click_Target,
83 +pub const MouseButton = struct {
84 + click: ClickTarget,
85 85 mod_mask: u32,
86 86 button: u32,
87 - action: Mouse_Action,
87 + action: MouseAction,
88 88 };
89 89
90 90 pub const Block = struct {
91 - block_type: Block_Type,
91 + block_type: BlockType,
92 92 format: []const u8,
93 93 command: ?[]const u8 = null,
94 94 interval: u32,
@@ -145,7 +145,7 @@ pub const Config = struct {
145 145 keybinds: std.ArrayListUnmanaged(Keybind) = .{},
146 146 rules: std.ArrayListUnmanaged(Rule) = .{},
147 147 blocks: std.ArrayListUnmanaged(Block) = .{},
148 - buttons: std.ArrayListUnmanaged(Mouse_Button) = .{},
148 + buttons: std.ArrayListUnmanaged(MouseButton) = .{},
149 149 autostart: std.ArrayListUnmanaged([]const u8) = .{},
150 150
151 151 pub fn init(allocator: std.mem.Allocator) Config {
@@ -176,7 +176,7 @@ pub const Config = struct {
176 176 try self.blocks.append(self.allocator, block);
177 177 }
178 178
179 - pub fn addButton(self: *Config, button: Mouse_Button) !void {
179 + pub fn addButton(self: *Config, button: MouseButton) !void {
180 180 try self.buttons.append(self.allocator, button);
181 181 }
182 182
+4 −4 src/config/lua.zig
@@ -5,10 +5,10 @@ const Keybind = config_mod.Keybind;
5 5 const Action = config_mod.Action;
6 6 const Rule = config_mod.Rule;
7 7 const Block = config_mod.Block;
8 -const Block_Type = config_mod.Block_Type;
9 -const Mouse_Button = config_mod.Mouse_Button;
10 -const Click_Target = config_mod.Click_Target;
11 -const Mouse_Action = config_mod.Mouse_Action;
8 +const Block_Type = config_mod.BlockType;
9 +const Mouse_Button = config_mod.MouseButton;
10 +const Click_Target = config_mod.ClickTarget;
11 +const Mouse_Action = config_mod.MouseAction;
12 12 const ColorScheme = config_mod.ColorScheme;
13 13
14 14 const c = @cImport({
+3 −3 src/keyboard/chord.zig
@@ -13,7 +13,7 @@ pub const timeout_ms: i64 = 1000;
13 13 /// whether the sequence is still live. Call `reset` to abandon the
14 14 /// current sequence and release the keyboard grab if one is held.
15 15 pub const ChordState = struct {
16 - keys: [max_chord_len]config.Key_Press = .{config.Key_Press{}} ** max_chord_len,
16 + keys: [max_chord_len]config.KeyPress = .{config.KeyPress{}} ** max_chord_len,
17 17 index: u8 = 0,
18 18 last_timestamp: i64 = 0,
19 19 keyboard_grabbed: bool = false,
@@ -22,7 +22,7 @@ pub const ChordState = struct {
22 22 ///
23 23 /// Returns `false` if the sequence is already at maximum length, in which
24 24 /// case the caller should call `reset` before retrying.
25 - pub fn push(self: *ChordState, key: config.Key_Press) bool {
25 + pub fn push(self: *ChordState, key: config.KeyPress) bool {
26 26 if (self.index >= max_chord_len) return false;
27 27 self.keys[self.index] = key;
28 28 self.index += 1;
@@ -42,7 +42,7 @@ pub const ChordState = struct {
42 42 /// `display` may be null only during early startup before the connection
43 43 /// is open, in normal operation it should always be provided.
44 44 pub fn reset(self: *ChordState, display: ?*xlib.Display) void {
45 - self.keys = .{config.Key_Press{}} ** max_chord_len;
45 + self.keys = .{config.KeyPress{}} ** max_chord_len;
46 46 self.index = 0;
47 47 self.last_timestamp = 0;
48 48
+16 −16 src/overlay.zig
@@ -13,7 +13,7 @@ const key_bg_color: c_ulong = 0x2a2a2a;
13 13
14 14 const max_lines: usize = 12;
15 15
16 -pub const Keybind_Overlay = struct {
16 +pub const KeybindOverlay = struct {
17 17 window: xlib.Window = 0,
18 18 pixmap: xlib.Pixmap = 0,
19 19 gc: xlib.GC = null,
@@ -32,8 +32,8 @@ pub const Keybind_Overlay = struct {
32 32 descs: [max_lines][]const u8 = undefined,
33 33 line_count: usize = 0,
34 34
35 - pub fn init(display: *xlib.Display, screen: c_int, root: xlib.Window, font_name: []const u8, allocator: std.mem.Allocator) ?*Keybind_Overlay {
36 - const overlay = allocator.create(Keybind_Overlay) catch return null;
35 + pub fn init(display: *xlib.Display, screen: c_int, root: xlib.Window, font_name: []const u8, allocator: std.mem.Allocator) ?*KeybindOverlay {
36 + const overlay = allocator.create(KeybindOverlay) catch return null;
37 37
38 38 const font_name_z = allocator.dupeZ(u8, font_name) catch {
39 39 allocator.destroy(overlay);
@@ -60,7 +60,7 @@ pub const Keybind_Overlay = struct {
60 60 return overlay;
61 61 }
62 62
63 - pub fn deinit(self: *Keybind_Overlay, allocator: std.mem.Allocator) void {
63 + pub fn deinit(self: *KeybindOverlay, allocator: std.mem.Allocator) void {
64 64 if (self.display) |display| {
65 65 self.destroyWindow(display);
66 66 if (self.font) |font| {
@@ -70,7 +70,7 @@ pub const Keybind_Overlay = struct {
70 70 allocator.destroy(self);
71 71 }
72 72
73 - fn destroyWindow(self: *Keybind_Overlay, display: *xlib.Display) void {
73 + fn destroyWindow(self: *KeybindOverlay, display: *xlib.Display) void {
74 74 if (self.xft_draw) |xft_draw| {
75 75 xlib.XftDrawDestroy(xft_draw);
76 76 self.xft_draw = null;
@@ -89,7 +89,7 @@ pub const Keybind_Overlay = struct {
89 89 }
90 90 }
91 91
92 - pub fn toggle(self: *Keybind_Overlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void {
92 + pub fn toggle(self: *KeybindOverlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void {
93 93 if (self.visible) {
94 94 self.hide();
95 95 } else {
@@ -97,7 +97,7 @@ pub const Keybind_Overlay = struct {
97 97 }
98 98 }
99 99
100 - pub fn show(self: *Keybind_Overlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void {
100 + pub fn show(self: *KeybindOverlay, mon_x: i32, mon_y: i32, mon_w: i32, mon_h: i32, config: *config_mod.Config) void {
101 101 const display = self.display orelse return;
102 102
103 103 self.collectKeybinds(config);
@@ -167,7 +167,7 @@ pub const Keybind_Overlay = struct {
167 167 self.visible = true;
168 168 }
169 169
170 - pub fn hide(self: *Keybind_Overlay) void {
170 + pub fn hide(self: *KeybindOverlay) void {
171 171 if (!self.visible) return;
172 172 if (self.display) |display| {
173 173 _ = xlib.XUngrabKeyboard(display, xlib.CurrentTime);
@@ -178,7 +178,7 @@ pub const Keybind_Overlay = struct {
178 178 self.visible = false;
179 179 }
180 180
181 - pub fn handleKey(self: *Keybind_Overlay, keysym: u64) bool {
181 + pub fn handleKey(self: *KeybindOverlay, keysym: u64) bool {
182 182 if (!self.visible) return false;
183 183 if (keysym == 0xff1b or keysym == 'q' or keysym == 'Q') {
184 184 self.hide();
@@ -187,11 +187,11 @@ pub const Keybind_Overlay = struct {
187 187 return false;
188 188 }
189 189
190 - pub fn isOverlayWindow(self: *Keybind_Overlay, win: xlib.Window) bool {
190 + pub fn isOverlayWindow(self: *KeybindOverlay, win: xlib.Window) bool {
191 191 return self.visible and self.window != 0 and self.window == win;
192 192 }
193 193
194 - fn draw(self: *Keybind_Overlay, display: *xlib.Display, max_key_width: i32, title: []const u8) void {
194 + fn draw(self: *KeybindOverlay, display: *xlib.Display, max_key_width: i32, title: []const u8) void {
195 195 self.fillRect(display, 0, 0, self.width, self.height, bg_color);
196 196
197 197 const title_x = @divTrunc(self.width - self.textWidth(display, title), 2);
@@ -217,12 +217,12 @@ pub const Keybind_Overlay = struct {
217 217 _ = xlib.c.XFlush(display);
218 218 }
219 219
220 - fn fillRect(self: *Keybind_Overlay, display: *xlib.Display, x: i32, y: i32, w: i32, h: i32, color: c_ulong) void {
220 + fn fillRect(self: *KeybindOverlay, display: *xlib.Display, x: i32, y: i32, w: i32, h: i32, color: c_ulong) void {
221 221 _ = xlib.XSetForeground(display, self.gc, color);
222 222 _ = xlib.XFillRectangle(display, self.pixmap, self.gc, x, y, @intCast(w), @intCast(h));
223 223 }
224 224
225 - fn drawText(self: *Keybind_Overlay, display: *xlib.Display, x: i32, y: i32, text: []const u8, color: c_ulong) void {
225 + fn drawText(self: *KeybindOverlay, display: *xlib.Display, x: i32, y: i32, text: []const u8, color: c_ulong) void {
226 226 if (self.xft_draw == null or self.font == null) return;
227 227 if (text.len == 0) return;
228 228
@@ -241,14 +241,14 @@ pub const Keybind_Overlay = struct {
241 241 xlib.XftColorFree(display, visual, colormap, &xft_color);
242 242 }
243 243
244 - fn textWidth(self: *Keybind_Overlay, display: *xlib.Display, text: []const u8) i32 {
244 + fn textWidth(self: *KeybindOverlay, display: *xlib.Display, text: []const u8) i32 {
245 245 if (self.font == null or text.len == 0) return 0;
246 246 var extents: xlib.XGlyphInfo = undefined;
247 247 xlib.XftTextExtentsUtf8(display, self.font, text.ptr, @intCast(text.len), &extents);
248 248 return extents.xOff;
249 249 }
250 250
251 - fn collectKeybinds(self: *Keybind_Overlay, cfg: *config_mod.Config) void {
251 + fn collectKeybinds(self: *KeybindOverlay, cfg: *config_mod.Config) void {
252 252 const priority_actions = [_]config_mod.Action{
253 253 .show_keybinds,
254 254 .quit,
@@ -280,7 +280,7 @@ pub const Keybind_Overlay = struct {
280 280 }
281 281 }
282 282
283 - fn formatKeyToBuf(self: *Keybind_Overlay, idx: usize, key: *const config_mod.Key_Press) void {
283 + fn formatKeyToBuf(self: *KeybindOverlay, idx: usize, key: *const config_mod.KeyPress) void {
284 284 var len: usize = 0;
285 285 var buf = &self.key_bufs[idx];
286 286
+4 −4 src/wm/wm.zig
@@ -78,10 +78,10 @@ pub const WindowManager = struct {
78 78
79 79 chord: ChordState,
80 80
81 - overlay: ?*overlay_mod.Keybind_Overlay,
81 + overlay: ?*overlay_mod.KeybindOverlay,
82 82
83 - scroll_animation: animations.Scroll_Animation,
84 - animation_config: animations.Animation_Config,
83 + scroll_animation: animations.ScrollAnimation,
84 + animation_config: animations.AnimationConfig,
85 85
86 86 running: bool,
87 87 last_motion_monitor: ?*Monitor,
@@ -306,7 +306,7 @@ pub const WindowManager = struct {
306 306 }
307 307
308 308 fn setupOverlay(self: *WindowManager) void {
309 - self.overlay = overlay_mod.Keybind_Overlay.init(
309 + self.overlay = overlay_mod.KeybindOverlay.init(
310 310 self.display.handle,
311 311 self.display.screen,
312 312 self.display.root,