Added key binds to control brightness

I added keybinds to control brightness with brightnessctl. 

F5 to decrease brightness.
f6 to increase brightness.
This commit is contained in:
tubi16 2024-07-02 01:29:23 +03:00 committed by GitHub
parent 3d8d8d67df
commit b71af04a23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 0 deletions

View File

@ -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,