mirror of https://github.com/fairyglade/ly.git
Fix setting numlock
This commit is contained in:
parent
cbc2cb933f
commit
815700f9b6
|
@ -108,16 +108,13 @@ pub fn getLockState(console_dev: [:0]const u8) !struct {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn setNumlock(console_dev: [:0]const u8, val: bool) !void {
|
||||
const fd = try std.posix.open(console_dev, .{ .ACCMODE = .RDONLY }, 0);
|
||||
defer std.posix.close(fd);
|
||||
|
||||
pub fn setNumlock(val: bool) !void {
|
||||
var led: c_char = undefined;
|
||||
_ = std.c.ioctl(fd, KDGKBLED, &led);
|
||||
_ = std.c.ioctl(0, KDGKBLED, &led);
|
||||
|
||||
const numlock = (led & K_NUMLOCK) != 0;
|
||||
if (numlock != val) {
|
||||
const status = std.c.ioctl(fd, KDSKBLED, led ^ K_NUMLOCK);
|
||||
const status = std.c.ioctl(std.posix.STDIN_FILENO, KDSKBLED, led ^ K_NUMLOCK);
|
||||
if (status != 0) return error.FailedToSetNumlock;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ pub fn main() !void {
|
|||
}
|
||||
}
|
||||
|
||||
interop.setNumlock(config.console_dev, config.numlock) catch {};
|
||||
interop.setNumlock(config.numlock) catch {};
|
||||
|
||||
// Initialize information line with host name
|
||||
get_host_name: {
|
||||
|
@ -252,6 +252,7 @@ pub fn main() !void {
|
|||
var restart = false;
|
||||
var auth_fails: u64 = 0;
|
||||
|
||||
// Switch to selected TTY if possible
|
||||
open_console_dev: {
|
||||
const fd = std.posix.open(config.console_dev, .{ .ACCMODE = .WRONLY }, 0) catch {
|
||||
try info_line.setText(lang.err_console_dev);
|
||||
|
@ -259,7 +260,6 @@ pub fn main() !void {
|
|||
};
|
||||
defer std.posix.close(fd);
|
||||
|
||||
// Switch to selected TTY if possible
|
||||
_ = std.c.ioctl(fd, interop.VT_ACTIVATE, config.tty);
|
||||
_ = std.c.ioctl(fd, interop.VT_WAITACTIVE, config.tty);
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ pub fn main() !void {
|
|||
},
|
||||
termbox.TB_KEY_ENTER => {
|
||||
if (config.save) save_last_settings: {
|
||||
var file = std.fs.createFileAbsolute(save_path, .{}) catch break :save_last_settings;
|
||||
var file = std.fs.cwd().createFile(save_path, .{}) catch break :save_last_settings;
|
||||
defer file.close();
|
||||
|
||||
const save_data = Save{
|
||||
|
|
Loading…
Reference in New Issue