From b71af04a239a45ced06ed9f740ce0e518710871f Mon Sep 17 00:00:00 2001 From: tubi16 <49732553+tubi16@users.noreply.github.com> Date: Tue, 2 Jul 2024 01:29:23 +0300 Subject: [PATCH] Added key binds to control brightness I added keybinds to control brightness with brightnessctl. F5 to decrease brightness. f6 to increase brightness. --- src/main.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.zig b/src/main.zig index bff277b..1b768c5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -18,6 +18,9 @@ const Save = @import("config/Save.zig"); const migrator = @import("config/migrator.zig"); const SharedError = @import("SharedError.zig"); const utils = @import("tui/utils.zig"); +const c_import = @cImport({ + @cInclude("unistd.h"); +}); const Ini = ini.Ini; const termbox = interop.termbox; @@ -476,6 +479,16 @@ pub fn main() !void { var sleep = std.ChildProcess.init(&[_][]const u8{ "/bin/sh", "-c", sleep_cmd }, allocator); _ = sleep.spawnAndWait() catch .{}; } + } else if (pressed_key == 5) { + if (c_import.access("/usr/bin/brightnessctl", c_import.X_OK) == 0) { + var brightness = std.ChildProcess.init(&[_][]const u8{ "/usr/bin/brightnessctl", "-q", "s", "5%-" }, allocator); + _ = brightness.spawnAndWait()catch.{}; + } + } else if (pressed_key == 6) { + if (c_import.access("/usr/bin/brightnessctl", c_import.X_OK) == 0) { + var brightness = std.ChildProcess.init(&[_][]const u8{ "/usr/bin/brightnessctl", "-q", "s", "+5%" }, allocator); + _ = brightness.spawnAndWait()catch.{}; + } } }, termbox.TB_KEY_CTRL_C => run = false,