Fix config.brightnessctl missing + bugs

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion 2024-08-01 00:54:00 +02:00
parent 872b15c0d4
commit 1314c57796
No known key found for this signature in database
GPG Key ID: 3E85EB44F610AD7F
4 changed files with 13 additions and 11 deletions

View File

@ -41,6 +41,7 @@ pub fn build(b: *std.Build) !void {
default_tty_str = try std.fmt.allocPrint(b.allocator, "{d}", .{default_tty});
build_options.addOption([]const u8, "config_directory", bin_directory);
build_options.addOption([]const u8, "prefix_directory", prefix_directory);
build_options.addOption([]const u8, "version", version_str);
build_options.addOption(u8, "tty", default_tty);
build_options.addOption(bool, "enable_x11_support", enable_x11_support);

View File

@ -186,4 +186,5 @@ xsessions = $PREFIX_DIRECTORY/share/xsessions
# Brightness control
brightness_down_key = F5
brightness_up_key = F6
brightnessctl = $PREFIX_DIRECTORY/bin/brightnessctl
brightness_change = 10

View File

@ -28,33 +28,33 @@ lang: []const u8 = "en",
load: bool = true,
margin_box_h: u8 = 2,
margin_box_v: u8 = 1,
mcookie_cmd: [:0]const u8 = "/usr/bin/mcookie",
mcookie_cmd: [:0]const u8 = build_options.prefix_directory ++ "/bin/mcookie",
min_refresh_delta: u16 = 5,
numlock: bool = false,
path: ?[:0]const u8 = "/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin",
restart_cmd: []const u8 = "/sbin/shutdown -r now",
restart_key: []const u8 = "F2",
save: bool = true,
save_file: []const u8 = "/etc/ly/save",
save_file: []const u8 = build_options.config_directory ++ "/ly/save",
service_name: [:0]const u8 = "ly",
shutdown_cmd: []const u8 = "/sbin/shutdown -a now",
shutdown_key: []const u8 = "F1",
sleep_cmd: ?[]const u8 = null,
sleep_key: []const u8 = "F3",
term_reset_cmd: [:0]const u8 = "/usr/bin/tput reset",
term_restore_cursor_cmd: []const u8 = "/usr/bin/tput cnorm",
term_reset_cmd: [:0]const u8 = build_options.prefix_directory ++ "/bin/tput reset",
term_restore_cursor_cmd: []const u8 = build_options.prefix_directory ++ "/bin/tput cnorm",
tty: u8 = build_options.tty,
vi_mode: bool = false,
vi_default_mode: ViMode = .normal,
wayland_cmd: []const u8 = build_options.config_directory ++ "/ly/wsetup.sh",
waylandsessions: []const u8 = "/usr/share/wayland-sessions",
x_cmd: []const u8 = "/usr/bin/X",
waylandsessions: []const u8 = build_options.prefix_directory ++ "/share/wayland-sessions",
x_cmd: []const u8 = build_options.prefix_directory ++ "/bin/X",
xinitrc: ?[]const u8 = "~/.xinitrc",
x_cmd_setup: []const u8 = build_options.config_directory ++ "/ly/xsetup.sh",
xauth_cmd: []const u8 = "/usr/bin/xauth",
xsessions: []const u8 = "/usr/share/xsessions",
xauth_cmd: []const u8 = build_options.prefix_directory ++ "/bin/xauth",
xsessions: []const u8 = build_options.prefix_directory ++ "/share/xsessions",
brightness_down_key: []const u8 = "F5",
brightness_up_key: []const u8 = "F6",
brightnessctl: []const u8 = "/usr/bin/brightnessctl",
brightnessctl: [:0]const u8 = build_options.prefix_directory ++ "/bin/brightnessctl",
brightness_change: []const u8 = "10",
animation_timeout_sec: u12 = 0,

View File

@ -594,7 +594,7 @@ 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[0], unistd.X_OK) == 0) brightness_change: {
} 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;
@ -602,7 +602,7 @@ pub fn main() !void {
defer allocator.free(brightness_str);
var brightness = std.process.Child.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: {
} 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;