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:
@@ -53,18 +53,18 @@ border_fg = 8
|
|||||||
# If set to null, none will be shown
|
# If set to null, none will be shown
|
||||||
box_title = null
|
box_title = null
|
||||||
|
|
||||||
# Brightness +/- percentage in one step
|
# Brightness increase command
|
||||||
brightness_change = 10
|
brightness_down_cmd = $PREFIX_DIRECTORY/bin/brightnessctl -q s 10%-
|
||||||
|
|
||||||
# Brightness decrease key
|
# Brightness decrease key
|
||||||
brightness_down_key = F5
|
brightness_down_key = F5
|
||||||
|
|
||||||
|
# Brightness increase command
|
||||||
|
brightness_up_cmd = $PREFIX_DIRECTORY/bin/brightnessctl -q s +10%
|
||||||
|
|
||||||
# Brightness increase key
|
# Brightness increase key
|
||||||
brightness_up_key = F6
|
brightness_up_key = F6
|
||||||
|
|
||||||
# Brightness control command
|
|
||||||
brightnessctl = $PREFIX_DIRECTORY/bin/brightnessctl
|
|
||||||
|
|
||||||
# Erase password input on failure
|
# Erase password input on failure
|
||||||
clear_password = false
|
clear_password = false
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ bigclock: bool = false,
|
|||||||
blank_box: bool = true,
|
blank_box: bool = true,
|
||||||
border_fg: u16 = 8,
|
border_fg: u16 = 8,
|
||||||
box_title: ?[]const u8 = null,
|
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_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",
|
brightness_up_key: []const u8 = "F6",
|
||||||
brightnessctl: [:0]const u8 = build_options.prefix_directory ++ "/bin/brightnessctl",
|
|
||||||
clear_password: bool = false,
|
clear_password: bool = false,
|
||||||
clock: ?[:0]const u8 = null,
|
clock: ?[:0]const u8 = null,
|
||||||
cmatrix_fg: u16 = 3,
|
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);
|
var sleep = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", sleep_cmd }, allocator);
|
||||||
_ = sleep.spawnAndWait() catch .{};
|
_ = sleep.spawnAndWait() catch .{};
|
||||||
}
|
}
|
||||||
} else if (pressed_key == brightness_down_key and unistd.access(config.brightnessctl, unistd.X_OK) == 0) brightness_change: {
|
} else if (pressed_key == brightness_down_key) {
|
||||||
const brightness_str = std.fmt.allocPrint(allocator, "{s}%-", .{config.brightness_change}) catch {
|
var brightness = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", config.brightness_down_cmd }, allocator);
|
||||||
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);
|
|
||||||
_ = brightness.spawnAndWait() catch .{};
|
_ = brightness.spawnAndWait() catch .{};
|
||||||
} else if (pressed_key == brightness_up_key and unistd.access(config.brightnessctl, unistd.X_OK) == 0) brightness_change: {
|
} else if (pressed_key == brightness_up_key) {
|
||||||
const brightness_str = std.fmt.allocPrint(allocator, "+{s}%", .{config.brightness_change}) catch {
|
var brightness = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", config.brightness_up_cmd }, allocator);
|
||||||
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);
|
|
||||||
_ = brightness.spawnAndWait() catch .{};
|
_ = brightness.spawnAndWait() catch .{};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user