mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-21 21:14:20 +02:00
Refactor brightness handling code
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
f0869f0e13
commit
096b1a7d44
3 changed files with 11 additions and 21 deletions
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 .{};
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue