kble/src/conf.zig

36 lines
1.2 KiB
Zig

// SPDX-License-Identifier: MIT
// Copyright (c) 2021 KikooDX
// This file is part of [KBLE](https://sr.ht/~kikoodx/kble), which is
// MIT licensed. The MIT license requires this copyright notice to be
// included in all copies and substantial portions of the software.
//! Values and types used by different files and that don't fit in any.
//! Read /etc/kble.conf and execute content.
/// Number passed to commands.
const std = @import("std");
pub const arg_type: type = u16;
pub const mouse_enabled: bool = true;
pub const mouse_left_btn: c_int = 0;
pub const mouse_right_btn: c_int = 1;
/// Read /etc/kble.conf and execute all bytes as keypresses.
pub fn source_config() void {
// Open file in read mode.
const file: std.fs.File = std.fs.openFileAbsolute("/etc/kble.conf", std.fs.File.OpenFlags{
.read = true,
.write = false,
}) catch {
std.log.err("Can't open /etc/kble.conf", .{});
return;
};
// Get reader.
const reader: std.fs.File.Reader = file.reader();
// Read all bytes.
while (true) {
const byte: u8 = reader.readByte() catch {
break;
};
std.log.info("{}", .{byte});
}
}