mirror of https://github.com/fairyglade/ly.git
code improvement and changes
This commit is contained in:
parent
a09086c2b2
commit
77f62c69b6
|
@ -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",
|
||||
|
|
17
src/main.zig
17
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);
|
||||
|
|
Loading…
Reference in New Issue