mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-20 19:24:53 +00:00
Refactor brightness handling code
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -14,10 +14,10 @@ bigclock: bool = false,
|
||||
blank_box: bool = true,
|
||||
border_fg: u16 = 8,
|
||||
box_title: ?[]const u8 = null,
|
||||
brightness_change: []const u8 = "10",
|
||||
brightness_down_cmd: [:0]const u8 = build_options.prefix_directory ++ "/bin/brightnessctl -q s 10%-",
|
||||
brightness_down_key: []const u8 = "F5",
|
||||
brightness_up_cmd: [:0]const u8 = build_options.prefix_directory ++ "/bin/brightnessctl -q s +10%",
|
||||
brightness_up_key: []const u8 = "F6",
|
||||
brightnessctl: [:0]const u8 = build_options.prefix_directory ++ "/bin/brightnessctl",
|
||||
clear_password: bool = false,
|
||||
clock: ?[:0]const u8 = null,
|
||||
cmatrix_fg: u16 = 3,
|
||||
|
||||
18
src/main.zig
18
src/main.zig
@@ -582,21 +582,11 @@ pub fn main() !void {
|
||||
var sleep = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", sleep_cmd }, allocator);
|
||||
_ = sleep.spawnAndWait() catch .{};
|
||||
}
|
||||
} else if (pressed_key == brightness_down_key and unistd.access(config.brightnessctl, unistd.X_OK) == 0) brightness_change: {
|
||||
const brightness_str = std.fmt.allocPrint(allocator, "{s}%-", .{config.brightness_change}) catch {
|
||||
try info_line.addMessage(lang.err_brightness_change, config.error_bg, config.error_fg);
|
||||
break :brightness_change;
|
||||
};
|
||||
defer allocator.free(brightness_str);
|
||||
var brightness = std.process.Child.init(&[_][]const u8{ config.brightnessctl, "-q", "s", brightness_str }, allocator);
|
||||
} else if (pressed_key == brightness_down_key) {
|
||||
var brightness = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", config.brightness_down_cmd }, allocator);
|
||||
_ = brightness.spawnAndWait() catch .{};
|
||||
} else if (pressed_key == brightness_up_key and unistd.access(config.brightnessctl, unistd.X_OK) == 0) brightness_change: {
|
||||
const brightness_str = std.fmt.allocPrint(allocator, "+{s}%", .{config.brightness_change}) catch {
|
||||
try info_line.addMessage(lang.err_brightness_change, config.error_bg, config.error_fg);
|
||||
break :brightness_change;
|
||||
};
|
||||
defer allocator.free(brightness_str);
|
||||
var brightness = std.process.Child.init(&[_][]const u8{ config.brightnessctl, "-q", "s", brightness_str }, allocator);
|
||||
} else if (pressed_key == brightness_up_key) {
|
||||
var brightness = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", config.brightness_up_cmd }, allocator);
|
||||
_ = brightness.spawnAndWait() catch .{};
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user