diff --git a/src/config/Lang.zig b/src/config/Lang.zig index cced3e6..58a9703 100644 --- a/src/config/Lang.zig +++ b/src/config/Lang.zig @@ -2,6 +2,7 @@ authenticating: []const u8 = "authenticating...", capslock: []const u8 = "capslock", err_alloc: []const u8 = "failed memory allocation", err_bounds: []const u8 = "out-of-bounds index", +err_brightness_change: []const u8 = "failed to change brightness", err_chdir: []const u8 = "failed to open home folder", err_console_dev: []const u8 = "failed to access console", err_dgn_oob: []const u8 = "log message", @@ -55,4 +56,4 @@ wayland: []const u8 = "wayland", xinitrc: [:0]const u8 = "xinitrc", x11: []const u8 = "x11", brightness_down: []const u8 = "decrease brightness", -brightness_up: []const u8 = "increase brigthness", +brightness_up: []const u8 = "increase brightness", diff --git a/src/main.zig b/src/main.zig index 7216846..62e1a04 100644 --- a/src/main.zig +++ b/src/main.zig @@ -501,16 +501,17 @@ pub fn main() !void { var sleep = std.ChildProcess.init(&[_][]const u8{ "/bin/sh", "-c", sleep_cmd }, allocator); _ = sleep.spawnAndWait() catch .{}; } - } else if (pressed_key == brightness_down_key) { - if (unistd.access(&config.brightnessctl[0], unistd.X_OK) == 0) { - const brightness_str = std.fmt.allocPrint(allocator, "{s}%-", .{config.brightness_change}) catch unreachable; - defer allocator.free(brightness_str); - var brightness = std.ChildProcess.init(&[_][]const u8{ config.brightnessctl, "-q", "s", brightness_str }, allocator); - _ = brightness.spawnAndWait() catch .{}; - } + } else if (pressed_key == brightness_down_key and unistd.access(&config.brightnessctl[0], unistd.X_OK) == 0) brightness_change: { + const brightness_str = std.fmt.allocPrint(allocator, "{s}%-", .{config.brightness_change}) catch { + try info_line.setText(lang.err_brightness_change); + break :brightness_change; + }; + defer allocator.free(brightness_str); + var brightness = std.ChildProcess.init(&[_][]const u8{ config.brightnessctl, "-q", "s", brightness_str }, allocator); + _ = brightness.spawnAndWait() catch .{}; } else if (pressed_key == brightness_up_key and unistd.access(&config.brightnessctl[0], unistd.X_OK) == 0) brightness_change: { const brightness_str = std.fmt.allocPrint(allocator, "+{s}%", .{config.brightness_change}) catch { - try info_line.setText(lang.err_alloc); + try info_line.setText(lang.err_brightness_change); break :brightness_change; }; defer allocator.free(brightness_str);