From 5905e054c587df65f9e4559f33595de1bfccaaae Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 1 May 2026 07:47:48 +0200 Subject: [PATCH 01/77] Start Ly v1.5.0 development cycle Signed-off-by: AnErrupTion --- build.zig | 2 +- build.zig.zon | 2 +- ly-core/build.zig.zon | 2 +- ly-ui/build.zig.zon | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index 2aeac26..0e626d7 100644 --- a/build.zig +++ b/build.zig @@ -23,7 +23,7 @@ comptime { } } -const ly_version = std.SemanticVersion{ .major = 1, .minor = 4, .patch = 0 }; +const ly_version = std.SemanticVersion{ .major = 1, .minor = 5, .patch = 0 }; var dest_directory: []const u8 = undefined; var config_directory: []const u8 = undefined; diff --git a/build.zig.zon b/build.zig.zon index 63e8c32..3c091cb 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .ly, - .version = "1.4.0", + .version = "1.5.0", .fingerprint = 0xa148ffcc5dc2cb59, .minimum_zig_version = "0.16.0", .dependencies = .{ diff --git a/ly-core/build.zig.zon b/ly-core/build.zig.zon index a389405..b40c8f8 100644 --- a/ly-core/build.zig.zon +++ b/ly-core/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .ly_core, - .version = "1.0.0", + .version = "1.1.0", .fingerprint = 0xddda7afda795472, .minimum_zig_version = "0.16.0", .dependencies = .{ diff --git a/ly-ui/build.zig.zon b/ly-ui/build.zig.zon index 598cba0..2a7e175 100644 --- a/ly-ui/build.zig.zon +++ b/ly-ui/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .ly_ui, - .version = "1.0.0", + .version = "1.1.0", .fingerprint = 0x8d11bf85a74ec803, .minimum_zig_version = "0.16.0", .dependencies = .{ From 3869bfd2f95acc4cd7dcc08675155047da1d4676 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 1 May 2026 17:40:04 +0200 Subject: [PATCH 02/77] Add config validation argument (closes #969) Signed-off-by: AnErrupTion --- readme.md | 6 ++++++ src/main.zig | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index aa23db8..78ebffc 100644 --- a/readme.md +++ b/readme.md @@ -226,6 +226,12 @@ You can, of course, still select the init system of your choice when using this You can find all the configuration in `/etc/ly/config.ini`. The file is fully commented, and includes the default values. +You may also check the validity of your configuration file (i.e. if there are any errors in it) with the following command: + +``` +$ ly --validate-config /etc/ly/config.ini +``` + ## Controls Use the Up/Down arrow keys to change the current field, and the Left/Right arrow keys to scroll through the different fields (whether it be the info line, the desktop environment, or the username). The info line is where messages and errors are displayed. diff --git a/src/main.zig b/src/main.zig index 81c44b4..6373751 100644 --- a/src/main.zig +++ b/src/main.zig @@ -172,7 +172,8 @@ pub fn main(init: std.process.Init) !void { \\-h, --help Shows all commands. \\-v, --version Shows the version of Ly. \\-c, --config Overrides the default configuration path. Example: --config /usr/share/ly - \\--use-kmscon-vt Use KMSCON instead of kernel VT + \\--use-kmscon-vt Uses KMSCON instead of the kernel VT. + \\--validate-config Validates the given configuration file. ); var diag = clap.Diagnostic{}; @@ -211,6 +212,30 @@ pub fn main(init: std.process.Init) !void { } if (res.args.config) |path| config_parent_path = path; if (res.args.@"use-kmscon-vt" != 0) state.use_kmscon_vt = true; + if (res.args.@"validate-config") |path| { + var parser = try IniParser(Config).init( + state.allocator, + state.io, + path, + migrator.configFieldHandler, + ); + defer parser.deinit(); + + for (parser.errors.items) |err| { + std.log.err( + "failed to convert value '{s}' of option '{s}' to type '{s}': {s}", + .{ err.value, err.key, err.type_name, err.error_name }, + ); + } + + if (parser.maybe_load_error) |err| { + std.log.err("failed to load config file: {s}", .{@errorName(err)}); + std.process.exit(1); + } + + std.log.info("no errors detected!", .{}); + std.process.exit(0); + } } // Load configuration file From 79eebd8ee0a1a8e9a958679605f81620c611ecb4 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 1 May 2026 17:43:28 +0200 Subject: [PATCH 03/77] Prefer std.log instead of stderr directly Signed-off-by: AnErrupTion --- src/main.zig | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main.zig b/src/main.zig index 6373751..ce222db 100644 --- a/src/main.zig +++ b/src/main.zig @@ -146,12 +146,10 @@ pub fn main(init: std.process.Init) !void { // If we can't shutdown or restart due to an error, we print it to standard error. If that fails, just bail out if (shutdown) { const shutdown_error = std.process.replace(state.io, .{ .argv = &[_][]const u8{ "/bin/sh", "-c", shutdown_cmd } }); - stderr.print("error: couldn't shutdown: {s}\n", .{@errorName(shutdown_error)}) catch std.process.exit(1); - stderr.flush() catch std.process.exit(1); + std.log.err("couldn't shutdown: {s}", .{@errorName(shutdown_error)}); } else if (restart) { const restart_error = std.process.replace(state.io, .{ .argv = &[_][]const u8{ "/bin/sh", "-c", restart_cmd } }); - stderr.print("error: couldn't restart: {s}\n", .{@errorName(restart_error)}) catch std.process.exit(1); - stderr.flush() catch std.process.exit(1); + std.log.err("couldn't restart: {s}", .{@errorName(restart_error)}); } else { // The user has quit Ly using Ctrl+C if (commands_allocated) { @@ -201,13 +199,11 @@ pub fn main(init: std.process.Init) !void { if (res.args.help != 0) { try clap.help(stderr, clap.Help, ¶ms, .{}); - _ = try stderr.write("Note: if you want to configure Ly, please check the config file, which is located at " ++ build_options.config_directory ++ "/ly/config.ini.\n"); - try stderr.flush(); + std.log.info("note: if you want to configure Ly, please check the config file, which is located at " ++ build_options.config_directory ++ "/ly/config.ini.", .{}); std.process.exit(0); } if (res.args.version != 0) { - _ = try stderr.write("Ly version " ++ build_options.version ++ "\n"); - try stderr.flush(); + std.log.info("ly version " ++ build_options.version, .{}); std.process.exit(0); } if (res.args.config) |path| config_parent_path = path; From fdf241bed53baf386a6023785c29b0cbd591fb34 Mon Sep 17 00:00:00 2001 From: MartorSkull Date: Fri, 1 May 2026 20:09:34 +0200 Subject: [PATCH 04/77] Add option to move the box relative to the screen size (#964) ## What are the changes about? Added a new option in the configuration file for moving the box relative to the screen size. ``` box_h_position = 0.5 box_v_position = 0.5 ``` The big clock is centered relative to the box. In the cases where it would be outside of the screen, it moves the box to fit in the screen. ## What existing issue does this resolve? Add more options for personalization ## Examples Normal usage: ``` box_h_position = 0.15 box_v_position = 0.35 ``` ![image](/attachments/6595dfa9-aade-45f4-887c-e5db7f8d5a89) Clock would be outside of the screen vertically: ``` box_h_position = 0.15 box_v_position = -1.0 ``` ![image](/attachments/0d6bdcc4-e9dd-4671-a65d-b8b9f063ffb6) Clock would be outside of the screen horizontally and vertically: ``` box_h_position = -1.0 box_v_position = -1.0 input_len = 3 ``` ![image](/attachments/630b07fd-b400-4e71-8a67-1baf3a6700a0) Clock would be outside of the screen horizontally and vertically on the bottom left of the screen: ``` box_h_position = 2.0 box_v_position = 2.0 input_len = 3 ``` ![image](/attachments/28902967-11a8-4c02-a4c9-1b92f9a728ee) ## What existing issue does this resolve? _Replace this with a reference to an existing issue, or N/A if there is none_ ## Pre-requisites - [x] I have tested & confirmed the changes work locally - [x] I have run `zig fmt` throughout my changes Co-authored-by: AnErrupTion Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/964 Reviewed-by: AnErrupTion --- res/config.ini | 8 ++++++++ src/config/Config.zig | 2 ++ src/main.zig | 38 ++++++++++++++++++++++++++------------ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/res/config.ini b/res/config.ini index 86f44b4..c2d885c 100644 --- a/res/config.ini +++ b/res/config.ini @@ -97,6 +97,14 @@ blank_box = true # Border foreground color id border_fg = 0x00FFFFFF +# Relative horizontal position from the end of the screen +# default: 0.5 +box_position_h = 0.5 + +# Relative vertical position from the bottom of the screen +# default: 0.4 +box_position_v = 0.4 + # Title to show at the top of the main box # If set to null, none will be shown box_title = null diff --git a/src/config/Config.zig b/src/config/Config.zig index 2233cb4..9efaaf7 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -23,6 +23,8 @@ bigclock_12hr: bool = false, bigclock_seconds: bool = false, blank_box: bool = true, border_fg: u32 = 0x00FFFFFF, +box_position_h: f32 = 0.5, +box_position_v: f32 = 0.4, box_title: ?[]const u8 = null, brightness_down_cmd: [:0]const u8 = build_options.prefix_directory ++ "/bin/brightnessctl -q -n s 10%-", brightness_down_key: ?[]const u8 = "F5", diff --git a/src/main.zig b/src/main.zig index ce222db..35239d7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2046,22 +2046,36 @@ fn positionWidgets(ptr: *anyopaque) !void { .childrenPosition() .removeX(TerminalBuffer.strWidth(state.lang.numlock) + TerminalBuffer.strWidth(state.lang.capslock) + 1)); - state.box.positionXY(TerminalBuffer.START_POSITION - .addX((state.buffer.width - @min(state.buffer.width - 2, state.box.width)) / 2) - .addY((state.buffer.height - @min(state.buffer.height - 2, state.box.height)) / 2)); + var bb_height = state.box.height; + var bb_width = state.box.width; + const clock_text_len = TerminalBuffer.strWidth(state.bigclock_label.text) * (BigLabel.CHAR_WIDTH + 1); if (state.config.bigclock != .none) { - const half_width = state.buffer.width / 2; - const half_label_width = (TerminalBuffer.strWidth(state.bigclock_label.text) * (BigLabel.CHAR_WIDTH + 1)) / 2; - const half_height = (if (state.buffer.height > state.box.height) state.buffer.height - state.box.height else state.buffer.height) / 2; - - state.bigclock_label.positionXY(TerminalBuffer.START_POSITION - .addX(half_width) - .removeXIf(half_label_width, half_width > half_label_width) - .addY(half_height) - .removeYIf(BigLabel.CHAR_HEIGHT + 2, half_height > BigLabel.CHAR_HEIGHT + 2)); + bb_height += BigLabel.CHAR_HEIGHT + 2; + bb_width = @max(bb_width, clock_text_len); } + const max_v_position: f32 = @floatFromInt(state.buffer.height - bb_height - 1); + const max_h_position: f32 = @floatFromInt(state.buffer.width - bb_width - 1); + + bb_height = @min(bb_height, state.buffer.height - 2); + bb_width = @min(bb_width, state.buffer.width - 2); + + const v_space: f32 = @floatFromInt(state.buffer.height - bb_height); + const v_position: usize = @intFromFloat(std.math.clamp(v_space * state.config.box_position_v, 1.0, max_v_position)); + const h_space: f32 = @floatFromInt(state.buffer.width - bb_width); + const h_position: usize = @intFromFloat(std.math.clamp(h_space * state.config.box_position_h, 1.0, max_h_position)); + + if (state.config.bigclock != .none) { + state.bigclock_label.positionXY(TerminalBuffer.START_POSITION + .addX(h_position + (bb_width - clock_text_len) / 2) + .addY(v_position)); + } + + state.box.positionXY(TerminalBuffer.START_POSITION + .addX(h_position + (bb_width - state.box.width) / 2) + .addY(v_position + (bb_height - state.box.height))); + state.info_line.label.positionY(state.box .childrenPosition()); From c50af66407b3005dd72979a9c62b9a81cefa3682 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 1 May 2026 20:54:54 +0200 Subject: [PATCH 05/77] Fix log file race condition Signed-off-by: AnErrupTion --- src/auth.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/auth.zig b/src/auth.zig index 87ddc09..6a97fff 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -417,19 +417,27 @@ fn xauth(log_file: *LogFile, allocator: std.mem.Allocator, io: std.Io, display_n const magic_cookie = mcookie(io); + log_file.deinit(io); + const pid = std.posix.system.fork(); if (pid == 0) { + try log_file.reinit(io); + var cmd_buffer: [1024]u8 = undefined; const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} add {s} . {s}", .{ options.xauth_cmd, display_name, magic_cookie }) catch std.process.exit(1); try log_file.info(io, "auth/x11", "executing: {s} -c {s}", .{ shell, cmd_str }); const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str }; _ = std.posix.system.execve(shell, &args, std.c.environ); + + log_file.deinit(io); std.process.exit(1); } var status: c_int = undefined; const result = std.posix.system.waitpid(pid, &status, 0); + + try log_file.reinit(io); if (interop.isError(result) or status != 0) { try log_file.err( io, From 864f5f289244f35890875a313c056df1ae775c0b Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 1 May 2026 21:51:27 +0200 Subject: [PATCH 06/77] Implement syslog functionality (closes # Signed-off-by: AnErrupTion --- ly-core/src/LogFile.zig | 85 +++++++++++++++++++++++++++++------------ res/config.ini | 1 + src/config/Config.zig | 2 +- 3 files changed, 62 insertions(+), 26 deletions(-) diff --git a/ly-core/src/LogFile.zig b/ly-core/src/LogFile.zig index f60b153..192f338 100644 --- a/ly-core/src/LogFile.zig +++ b/ly-core/src/LogFile.zig @@ -3,50 +3,85 @@ const interop = @import("interop.zig"); const LogFile = @This(); -path: []const u8, +maybe_path: ?[]const u8, could_open_log_file: bool = undefined, -file: std.Io.File = undefined, +maybe_file: ?std.Io.File = null, buffer: []u8, -file_writer: std.Io.File.Writer = undefined, +maybe_file_writer: ?std.Io.File.Writer = null, + +pub fn init(io: std.Io, path: ?[]const u8, buffer: []u8) !LogFile { + var log_file = LogFile{ + .maybe_path = path, + .buffer = buffer, + }; + + if (path) |p| { + log_file.could_open_log_file = try openLogFile(io, p, &log_file); + } else { + std.posix.system.openlog("ly", 0, 0); + log_file.could_open_log_file = true; + } -pub fn init(io: std.Io, path: []const u8, buffer: []u8) !LogFile { - var log_file = LogFile{ .path = path, .buffer = buffer }; - log_file.could_open_log_file = try openLogFile(io, path, &log_file); return log_file; } pub fn reinit(self: *LogFile, io: std.Io) !void { - self.could_open_log_file = try openLogFile(io, self.path, self); + if (self.maybe_path) |path| { + self.could_open_log_file = try openLogFile(io, path, self); + } else { + std.posix.system.openlog("ly", 0, 0); + self.could_open_log_file = true; + } } pub fn deinit(self: *LogFile, io: std.Io) void { - self.file.close(io); + if (self.maybe_file) |file| { + file.close(io); + } else { + std.posix.system.closelog(); + } } pub fn info(self: *LogFile, io: std.Io, category: []const u8, comptime message: []const u8, args: anytype) !void { - var buffer: [128:0]u8 = undefined; - const time = interop.timeAsString(io, &buffer, "%Y-%m-%d %H:%M:%S"); + if (self.maybe_file_writer) |*writer| { + var buffer: [128:0]u8 = undefined; + const time = interop.timeAsString(io, &buffer, "%Y-%m-%d %H:%M:%S"); - try self.file_writer.interface.print("{s} [info/{s}] ", .{ time, category }); - try self.file_writer.interface.print(message, args); - try self.file_writer.interface.writeByte('\n'); - try self.file_writer.interface.flush(); + try writer.interface.print("{s} [info/{s}] ", .{ time, category }); + try writer.interface.print(message, args); + try writer.interface.writeByte('\n'); + try writer.interface.flush(); + } else { + var buffer: [1024]u8 = undefined; + const slice = try std.fmt.bufPrint(&buffer, message, args); + const msg = try std.fmt.bufPrintZ(buffer[slice.len..], "[info/{s}] {s}", .{ category, slice }); + + std.posix.system.syslog(std.posix.LOG.INFO, msg.ptr); + } } pub fn err(self: *LogFile, io: std.Io, category: []const u8, comptime message: []const u8, args: anytype) !void { - var buffer: [128:0]u8 = undefined; - const time = interop.timeAsString(io, &buffer, "%Y-%m-%d %H:%M:%S"); + if (self.maybe_file_writer) |*writer| { + var buffer: [128:0]u8 = undefined; + const time = interop.timeAsString(io, &buffer, "%Y-%m-%d %H:%M:%S"); - try self.file_writer.interface.print("{s} [err/{s}] ", .{ time, category }); - try self.file_writer.interface.print(message, args); - try self.file_writer.interface.writeByte('\n'); - try self.file_writer.interface.flush(); + try writer.interface.print("{s} [err/{s}] ", .{ time, category }); + try writer.interface.print(message, args); + try writer.interface.writeByte('\n'); + try writer.interface.flush(); + } else { + var buffer: [1024]u8 = undefined; + const slice = try std.fmt.bufPrint(&buffer, message, args); + const msg = try std.fmt.bufPrintZ(buffer[slice.len..], "[info/{s}] {s}", .{ category, slice }); + + std.posix.system.syslog(std.posix.LOG.ERR, msg.ptr); + } } fn openLogFile(io: std.Io, path: []const u8, log_file: *LogFile) !bool { var could_open_log_file = true; open_log_file: { - log_file.file = std.Io.Dir.cwd().openFile(io, path, .{ .mode = .write_only }) catch std.Io.Dir.cwd().createFile(io, path, .{ .permissions = .fromMode(0o666) }) catch { + log_file.maybe_file = std.Io.Dir.cwd().openFile(io, path, .{ .mode = .write_only }) catch std.Io.Dir.cwd().createFile(io, path, .{ .permissions = .fromMode(0o666) }) catch { // If we could neither open an existing log file nor create a new // one, abort. could_open_log_file = false; @@ -55,17 +90,17 @@ fn openLogFile(io: std.Io, path: []const u8, log_file: *LogFile) !bool { } if (!could_open_log_file) { - log_file.file = try std.Io.Dir.openFileAbsolute(io, "/dev/null", .{ .mode = .write_only }); + log_file.maybe_file = try std.Io.Dir.openFileAbsolute(io, "/dev/null", .{ .mode = .write_only }); } - var log_file_writer = log_file.file.writer(io, log_file.buffer); + var log_file_writer = log_file.maybe_file.?.writer(io, log_file.buffer); // Seek to the end of the log file if (could_open_log_file) { - const stat = try log_file.file.stat(io); + const stat = try log_file.maybe_file.?.stat(io); try log_file_writer.seekTo(stat.size); } - log_file.file_writer = log_file_writer; + log_file.maybe_file_writer = log_file_writer; return could_open_log_file; } diff --git a/res/config.ini b/res/config.ini index c2d885c..a290773 100644 --- a/res/config.ini +++ b/res/config.ini @@ -299,6 +299,7 @@ login_defs_path = /etc/login.defs logout_cmd = null # General log file path +# If null, syslog will be used instead ly_log = /var/log/ly.log # Main box horizontal margin diff --git a/src/config/Config.zig b/src/config/Config.zig index 9efaaf7..a592faa 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -74,7 +74,7 @@ lang: []const u8 = "en", login_cmd: ?[]const u8 = null, login_defs_path: []const u8 = "/etc/login.defs", logout_cmd: ?[]const u8 = null, -ly_log: []const u8 = "/var/log/ly.log", +ly_log: ?[]const u8 = "/var/log/ly.log", margin_box_h: u8 = 2, margin_box_v: u8 = 1, numlock: bool = false, From 4db9295102ac43d054c4e12f067429c5104f6e19 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sun, 3 May 2026 20:05:44 +0200 Subject: [PATCH 07/77] Fix building without X11 Signed-off-by: AnErrupTion --- build.zig | 6 +++++- ly-core/build.zig | 5 ++++- ly-ui/build.zig | 7 ++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 0e626d7..45a548b 100644 --- a/build.zig +++ b/build.zig @@ -72,7 +72,11 @@ pub fn build(b: *std.Build) !void { .use_llvm = true, }); - const ly_ui = b.dependency("ly_ui", .{ .target = target, .optimize = optimize }); + const ly_ui = b.dependency("ly_ui", .{ + .target = target, + .optimize = optimize, + .enable_x11_support = enable_x11_support, + }); exe.root_module.addImport("ly-ui", ly_ui.module("ly-ui")); exe.root_module.addOptions("build_options", build_options); diff --git a/ly-core/build.zig b/ly-core/build.zig index dc722b5..f6574de 100644 --- a/ly-core/build.zig +++ b/ly-core/build.zig @@ -4,6 +4,7 @@ const Translator = @import("translate_c").Translator; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const enable_x11_support = b.option(bool, "enable_x11_support", "Enable X11 support") orelse true; const mod = b.addModule("ly-core", .{ .root_source_file = b.path("src/root.zig"), .target = target, @@ -20,7 +21,9 @@ pub fn build(b: *std.Build) void { addCImport(b, mod, translate_c, target, optimize, "pam", "#include "); addCImport(b, mod, translate_c, target, optimize, "utmp", "#include "); - addCImport(b, mod, translate_c, target, optimize, "xcb", "#include "); + if (enable_x11_support) { + addCImport(b, mod, translate_c, target, optimize, "xcb", "#include "); + } if (target.result.os.tag == .freebsd) { addCImport(b, mod, translate_c, target, optimize, "pwd", \\#include diff --git a/ly-ui/build.zig b/ly-ui/build.zig index a7a3051..7397873 100644 --- a/ly-ui/build.zig +++ b/ly-ui/build.zig @@ -4,13 +4,18 @@ const Translator = @import("translate_c").Translator; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const enable_x11_support = b.option(bool, "enable_x11_support", "Enable X11 support") orelse true; const mod = b.addModule("ly-ui", .{ .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize, }); - const ly_core = b.dependency("ly_core", .{ .target = target, .optimize = optimize }); + const ly_core = b.dependency("ly_core", .{ + .target = target, + .optimize = optimize, + .enable_x11_support = enable_x11_support, + }); mod.addImport("ly-core", ly_core.module("ly-core")); const termbox_dep = b.dependency("termbox2", .{ From b8ae1266236e23a7f2620045cf630ec5e26f03c1 Mon Sep 17 00:00:00 2001 From: Titanium Brain Date: Mon, 4 May 2026 12:34:32 +0200 Subject: [PATCH 08/77] Apply the typestate pattern to DurFormat (#972) --- src/animations/DurFile.zig | 168 +++++++++++++++++++++++++++---------- 1 file changed, 123 insertions(+), 45 deletions(-) diff --git a/src/animations/DurFile.zig b/src/animations/DurFile.zig index c20c2d2..57d38c0 100644 --- a/src/animations/DurFile.zig +++ b/src/animations/DurFile.zig @@ -62,7 +62,7 @@ const Frame = struct { }; // https://github.com/cmang/durdraw/blob/0.29.0/durformat.md -const DurFormat = struct { +const DurFormatRaw = struct { allocator: Allocator, formatVersion: ?i64 = null, colorFormat: ?[]const u8 = null, @@ -72,38 +72,48 @@ const DurFormat = struct { lines: ?i64 = null, frames: std.ArrayList(Frame) = undefined, - pub fn valid(self: *DurFormat) bool { - if (self.formatVersion != null and - self.colorFormat != null and - self.encoding != null and - self.framerate != null and - self.columns != null and - self.lines != null and - self.frames.items.len >= 1) - { - // v8 may have breaking changes like changing the colormap xy direction - // (https://github.com/cmang/durdraw/issues/24) - if (self.formatVersion.? != 7) return false; + // Validate data and return a valid DurFormat + // Consumes `self`, making it unusable after + pub fn validate(self: *DurFormatRaw) !DurFormat { + // v8 may have breaking changes like changing the colormap xy direction + // (https://github.com/cmang/durdraw/issues/24) + const format_version = self.formatVersion orelse return error.MissingFieldVersion; + if (format_version != 7) return error.UnsupportedVersion; - // Code currently only supports 16 and 256 color format only - if (!(eql(u8, "16", self.colorFormat.?) or eql(u8, "256", self.colorFormat.?))) - return false; + const color_format_str = self.colorFormat orelse return error.MissingFieldColorFormat; + // Code currently only supports 16 and 256 color format only + const color_format: DurColorFormat = + if (eql(u8, color_format_str, "16")) .@"16" else if (eql(u8, color_format_str, "256")) .@"256" else return error.UnsupportedColorFormat; - // Code currently supports only utf-8 encoding - if (!eql(u8, self.encoding.?, "utf-8")) return false; + const encoding_str = self.encoding orelse return error.MissingFieldEncoding; + // Code currently supports only utf-8 encoding + const encoding: DurEncoding = if (eql(u8, encoding_str, "utf-8")) .utf_8 else return error.UnsupportedEncoding; - // Sanity check on file - if (self.columns.? <= 0) return false; - if (self.lines.? <= 0) return false; - if (self.framerate.? < 0) return false; + if (self.framerate == null) return error.MissingFieldFramerate; + if (self.framerate.? <= 0) return error.InvalidFramerate; + const framerate: f64 = self.framerate.?; - return true; - } + // Sanity check on file + if (self.columns == null or self.lines == null) return error.MissingDimensions; + const columns = std.math.cast(u32, self.columns.?) orelse return error.InvalidColumnCount; + const lines = std.math.cast(u32, self.lines.?) orelse return error.InvalidLineCount; - return false; + if (self.frames.items.len == 0) return error.NoFrames; + const frames = self.frames; + + return .{ + .allocator = self.allocator, + .formatVersion = format_version, + .colorFormat = color_format, + .encoding = encoding, + .framerate = framerate, + .columns = columns, + .lines = lines, + .frames = frames, + }; } - fn parse_dur_from_json(self: *DurFormat, allocator: Allocator, dur_json_root: Json.Value) !void { + fn parse_dur_from_json(self: *DurFormatRaw, allocator: Allocator, dur_json_root: Json.Value) !void { var dur_movie = if (dur_json_root.object.get("DurMovie")) |dm| dm.object else return error.NotValidFile; // Depending on the version, a dur file can have different json object names (ie: columns vs sizeX) @@ -150,7 +160,7 @@ const DurFormat = struct { } } - pub fn create_from_file(self: *DurFormat, allocator: Allocator, io: std.Io, file_path: []const u8) !void { + pub fn create_from_file(self: *DurFormatRaw, allocator: Allocator, io: std.Io, file_path: []const u8) !void { const file_decompressed = try read_decompress_file(allocator, io, file_path); defer allocator.free(file_decompressed); @@ -158,20 +168,36 @@ const DurFormat = struct { defer parsed.deinit(); try parse_dur_from_json(self, allocator, parsed.value); - - if (!self.valid()) { - return error.NotValidFile; - } } - pub fn init(allocator: Allocator) DurFormat { + pub fn init(allocator: Allocator) DurFormatRaw { return .{ .allocator = allocator }; } - pub fn deinit(self: *DurFormat) void { + pub fn deinit(self: *DurFormatRaw) void { if (self.colorFormat) |str| self.allocator.free(str); if (self.encoding) |str| self.allocator.free(str); + } +}; +const DurColorFormat = enum { + @"16", + @"256", +}; + +const DurEncoding = enum { utf_8 }; + +const DurFormat = struct { + allocator: Allocator, + formatVersion: i64, + colorFormat: DurColorFormat, + encoding: DurEncoding, + framerate: f64, + columns: u32, + lines: u32, + frames: std.ArrayList(Frame), + + pub fn deinit(self: *DurFormat) void { for (self.frames.items) |frame| { frame.deinit(self.allocator); } @@ -324,16 +350,16 @@ offset_alignment: DurOffsetAlignment, offset: IVec2, // if the user has an even number of columns or rows, we will default to the left or higher position (e.g. 4 columns center = .x..) -fn center(v: u32) i64 { - return @intCast((v / 2) + (v % 2)); +fn center(v: i64) i64 { + return @intCast(@divTrunc(v, 2) + @mod(v, 2)); } fn calc_start_position(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat, offset_alignment: DurOffsetAlignment, offset: IVec2) IVec2 { const buf_width: u32 = @intCast(terminal_buffer.width); const buf_height: u32 = @intCast(terminal_buffer.height); - var movie_width: u32 = @intCast(dur_movie.columns.?); - var movie_height: u32 = @intCast(dur_movie.lines.?); + var movie_width: u32 = dur_movie.columns; + var movie_height: u32 = dur_movie.lines; if (movie_width > buf_width) movie_width = buf_width; if (movie_height > buf_height) movie_height = buf_height; @@ -357,8 +383,8 @@ fn calc_frame_size(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat) UVec const buf_width: u32 = @intCast(terminal_buffer.width); const buf_height: u32 = @intCast(terminal_buffer.height); - const movie_width: u32 = @intCast(dur_movie.columns.?); - const movie_height: u32 = @intCast(dur_movie.lines.?); + const movie_width: u32 = dur_movie.columns; + const movie_height: u32 = dur_movie.lines; // Draw only the needed amount if movie smaller than screen. If movie is bigger, we will just draw entire screen const frame_width = if (movie_width < buf_width) movie_width else buf_width; @@ -381,9 +407,10 @@ pub fn init( timeout_sec: u12, frame_delay: u16, ) !DurFile { - var dur_movie: DurFormat = .init(allocator); + var dur_movie_raw: DurFormatRaw = .init(allocator); + defer dur_movie_raw.deinit(); - dur_movie.create_from_file(allocator, io, file_path) catch |err| switch (err) { + dur_movie_raw.create_from_file(allocator, io, file_path) catch |err| switch (err) { error.FileNotFound => { try log_file.err(io, "tui", "dur_file was not found at: {s}", .{file_path}); return err; @@ -395,11 +422,62 @@ pub fn init( else => return err, }; + var dur_movie = dur_movie_raw.validate() catch |err| switch (err) { + error.MissingFieldVersion => { + try log_file.err(io, "tui", "dur_file loaded was invalid: missing field formatVersion!", .{}); + return err; + }, + error.UnsupportedVersion => { + try log_file.err(io, "tui", "dur_file loaded was invalid: unsupported version ({d})!", .{dur_movie_raw.formatVersion.?}); + return err; + }, + error.MissingFieldColorFormat => { + try log_file.err(io, "tui", "dur_file loaded was invalid: missing field colorFormat!", .{}); + return err; + }, + error.UnsupportedColorFormat => { + try log_file.err(io, "tui", "dur_file loaded was invalid: unsupported colorFormat ({s})!", .{dur_movie_raw.colorFormat.?}); + return err; + }, + error.MissingFieldEncoding => { + try log_file.err(io, "tui", "dur_file loaded was invalid: missing field encoding!", .{}); + return err; + }, + error.UnsupportedEncoding => { + try log_file.err(io, "tui", "dur_file loaded was invalid: unsupported encoding ({s})!", .{dur_movie_raw.encoding.?}); + return err; + }, + error.MissingFieldFramerate => { + try log_file.err(io, "tui", "dur_file loaded was invalid: missing field framerate!", .{}); + return err; + }, + error.InvalidFramerate => { + try log_file.err(io, "tui", "dur_file loaded was invalid: negative framerate value found!", .{}); + return err; + }, + error.MissingDimensions => { + try log_file.err(io, "tui", "dur_file loaded was invalid: missing field(s) lines and/or columns!", .{}); + return err; + }, + error.InvalidColumnCount => { + try log_file.err(io, "tui", "dur_file loaded was invalid: columns value falls outside of supported range ({d})!", .{dur_movie_raw.columns.?}); + return err; + }, + error.InvalidLineCount => { + try log_file.err(io, "tui", "dur_file loaded was invalid: lines value falls outside of supported range ({d})!", .{dur_movie_raw.lines.?}); + return err; + }, + error.NoFrames => { + try log_file.err(io, "tui", "dur_file loaded was invalid: animation has no frames!", .{}); + return err; + }, + }; + // 4 bit mode with 256 color is unsupported - if (!full_color and eql(u8, dur_movie.colorFormat.?, "256")) { + if (!full_color and dur_movie.colorFormat == .@"256") { try log_file.err(io, "tui", "dur_file can not be 256 color encoded when not using full_color option!", .{}); dur_movie.deinit(); - return error.InvalidColorFormat; + return error.NotFullColor; } const offset: IVec2 = .{ x_offset, y_offset }; @@ -408,7 +486,7 @@ pub fn init( const frame_size = calc_frame_size(terminal_buffer, &dur_movie); // Convert dur fps to frames per ms - const frame_time: u32 = @trunc(1000 / dur_movie.framerate.?); + const frame_time: u32 = @trunc(1000 / dur_movie.framerate); return .{ .instance = null, @@ -426,7 +504,7 @@ pub fn init( .frame_delay = frame_delay, .dur_movie = dur_movie, .frame_time = frame_time, - .is_color_format_16 = eql(u8, dur_movie.colorFormat.?, "16"), + .is_color_format_16 = dur_movie.colorFormat == .@"16", .offset_alignment = offset_alignment, .offset = offset, }; From b3830d5bb6de38f5ebe529b48b9682069467da06 Mon Sep 17 00:00:00 2001 From: Titanium Brain Date: Sat, 9 May 2026 21:06:45 +0200 Subject: [PATCH 09/77] fix(dur): apply correct offset for animations bigger than the terminal (#966) Animations bigger than the rendering area would have an alignment to the top left instead of center. ## What are the changes about? Fixes incorrect offset calculations for dur movies bigger than the screen. ## What existing issue does this resolve? N/A ## Pre-requisites - [x] I have tested & confirmed the changes work locally - [x] I have run `zig fmt` throughout my changes Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/966 Reviewed-by: AnErrupTion --- ly-ui/src/TerminalBuffer.zig | 6 +++++ src/animations/DurFile.zig | 51 +++++++----------------------------- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/ly-ui/src/TerminalBuffer.zig b/ly-ui/src/TerminalBuffer.zig index 565593b..1fd9999 100644 --- a/ly-ui/src/TerminalBuffer.zig +++ b/ly-ui/src/TerminalBuffer.zig @@ -381,6 +381,12 @@ pub fn setCell(x: usize, y: usize, cell: Cell) void { ); } +pub fn setCellBoundsChecked(self: *TerminalBuffer, x: isize, y: isize, cell: Cell) void { + if (0 <= x and x < self.width and 0 <= y and y < self.height) { + cell.put(@intCast(x), @intCast(y)); + } +} + pub fn reclaim(self: TerminalBuffer) !void { if (self.termios) |termios| { // Take back control of the TTY diff --git a/src/animations/DurFile.zig b/src/animations/DurFile.zig index 57d38c0..969157b 100644 --- a/src/animations/DurFile.zig +++ b/src/animations/DurFile.zig @@ -337,7 +337,6 @@ io: std.Io, terminal_buffer: *TerminalBuffer, dur_movie: DurFormat, frames: usize, -frame_size: UVec2, start_pos: IVec2, full_color: bool, animate: *bool, @@ -355,14 +354,11 @@ fn center(v: i64) i64 { } fn calc_start_position(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat, offset_alignment: DurOffsetAlignment, offset: IVec2) IVec2 { - const buf_width: u32 = @intCast(terminal_buffer.width); - const buf_height: u32 = @intCast(terminal_buffer.height); + const buf_width: i64 = @intCast(terminal_buffer.width); + const buf_height: i64 = @intCast(terminal_buffer.height); - var movie_width: u32 = dur_movie.columns; - var movie_height: u32 = dur_movie.lines; - - if (movie_width > buf_width) movie_width = buf_width; - if (movie_height > buf_height) movie_height = buf_height; + const movie_width: i64 = @intCast(dur_movie.columns); + const movie_height: i64 = @intCast(dur_movie.lines); const start_pos: IVec2 = switch (offset_alignment) { DurOffsetAlignment.center => .{ center(buf_width) - center(movie_width), center(buf_height) - center(movie_height) }, @@ -379,20 +375,6 @@ fn calc_start_position(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat, return start_pos + offset; } -fn calc_frame_size(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat) UVec2 { - const buf_width: u32 = @intCast(terminal_buffer.width); - const buf_height: u32 = @intCast(terminal_buffer.height); - - const movie_width: u32 = dur_movie.columns; - const movie_height: u32 = dur_movie.lines; - - // Draw only the needed amount if movie smaller than screen. If movie is bigger, we will just draw entire screen - const frame_width = if (movie_width < buf_width) movie_width else buf_width; - const frame_height = if (movie_height < buf_height) movie_height else buf_height; - - return .{ frame_width, frame_height }; -} - pub fn init( allocator: Allocator, io: std.Io, @@ -483,7 +465,6 @@ pub fn init( const offset: IVec2 = .{ x_offset, y_offset }; const start_pos = calc_start_position(terminal_buffer, &dur_movie, offset_alignment, offset); - const frame_size = calc_frame_size(terminal_buffer, &dur_movie); // Convert dur fps to frames per ms const frame_time: u32 = @trunc(1000 / dur_movie.framerate); @@ -496,7 +477,6 @@ pub fn init( .terminal_buffer = terminal_buffer, .frames = 0, .time_previous = std.Io.Timestamp.now(io, .real).toMilliseconds(), - .frame_size = frame_size, .start_pos = start_pos, .full_color = full_color, .animate = animate, @@ -531,9 +511,8 @@ fn deinit(self: *DurFile) void { } fn realloc(self: *DurFile) !void { - // when terminal size changes, we need to recalculate the start_pos and frame_size based on the new size + // when terminal size changes, we need to recalculate the start_pos based on the new size self.start_pos = calc_start_position(self.terminal_buffer, &self.dur_movie, self.offset_alignment, self.offset); - self.frame_size = calc_frame_size(self.terminal_buffer, &self.dur_movie); } fn draw(self: *DurFile) void { @@ -541,24 +520,14 @@ fn draw(self: *DurFile) void { const current_frame = self.dur_movie.frames.items[self.frames]; - const buf_width: u32 = @intCast(self.terminal_buffer.width); - const buf_height: u32 = @intCast(self.terminal_buffer.height); - // y is used as an iterator in the durformat, while cell_y gives us the correct placement for the cell (same for x) - for (0..self.frame_size[VEC_Y]) |y| { - const y_offset_i = @as(i32, @intCast(y)) + self.start_pos[VEC_Y]; - // we skip the pass if it falls outside of the draw window (ensure no int underflow) - const cell_y: u32 = if (y_offset_i >= 0 and y_offset_i < buf_height) @intCast(y_offset_i) else continue; + for (0..@intCast(self.dur_movie.lines)) |y| { + const cell_y = @as(i32, @intCast(y)) + self.start_pos[VEC_Y]; var iter = std.unicode.Utf8View.initUnchecked(current_frame.contents[y]).iterator(); - for (0..self.frame_size[VEC_X]) |x| { - const x_offset_i = @as(i32, @intCast(x)) + self.start_pos[VEC_X]; - // skip pass, same as y but also increment the codepoint iter to fetch correct values in later passes - const cell_x: u32 = if (x_offset_i >= 0 and x_offset_i < buf_width) @intCast(x_offset_i) else { - _ = iter.nextCodepoint().?; - continue; - }; + for (0..@intCast(self.dur_movie.columns)) |x| { + const cell_x = @as(i32, @intCast(x)) + self.start_pos[VEC_X]; const codepoint: u21 = iter.nextCodepoint().?; const color_map = current_frame.colorMap[x][y]; @@ -576,7 +545,7 @@ fn draw(self: *DurFile) void { const cell = Cell{ .ch = @intCast(codepoint), .fg = fg_color, .bg = bg_color }; - cell.put(cell_x, cell_y); + self.terminal_buffer.setCellBoundsChecked(cell_x, cell_y, cell); } } From 9ff4ddd129a607ffb8f8fe56f0f09e5f0ffdfaab Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sun, 10 May 2026 13:55:19 +0200 Subject: [PATCH 10/77] Improve keyboard handling (closes #982) Signed-off-by: AnErrupTion --- ly-ui/src/keyboard.zig | 55 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/ly-ui/src/keyboard.zig b/ly-ui/src/keyboard.zig index 2e6e0e2..a90148b 100644 --- a/ly-ui/src/keyboard.zig +++ b/ly-ui/src/keyboard.zig @@ -171,6 +171,7 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { const code = if (tb_event.ch == 0 and tb_event.key < 128) tb_event.key else tb_event.ch; switch (code) { + // Non-standard control codes 0 => { key.ctrl = true; key.@"2" = true; @@ -342,7 +343,9 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key = std.mem.zeroes(Key); key._ = true; }, + // Standard ASCII characters 32 => { + key = std.mem.zeroes(Key); key.@" " = true; }, 33 => { @@ -370,6 +373,7 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.@"&" = true; }, 39 => { + key = std.mem.zeroes(Key); key.@"'" = true; }, 40 => { @@ -389,74 +393,86 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.@"+" = true; }, 44 => { + key = std.mem.zeroes(Key); key.@"," = true; }, 45 => { + key = std.mem.zeroes(Key); key.@"-" = true; }, 46 => { + key = std.mem.zeroes(Key); key.@"." = true; }, 47 => { + key = std.mem.zeroes(Key); key.@"/" = true; }, 48 => { + key = std.mem.zeroes(Key); key.@"0" = true; }, 49 => { + key = std.mem.zeroes(Key); key.@"1" = true; }, 50 => { + key = std.mem.zeroes(Key); key.@"2" = true; }, 51 => { + key = std.mem.zeroes(Key); key.@"3" = true; }, 52 => { + key = std.mem.zeroes(Key); key.@"4" = true; }, 53 => { + key = std.mem.zeroes(Key); key.@"5" = true; }, 54 => { + key = std.mem.zeroes(Key); key.@"6" = true; }, 55 => { + key = std.mem.zeroes(Key); key.@"7" = true; }, 56 => { + key = std.mem.zeroes(Key); key.@"8" = true; }, 57 => { + key = std.mem.zeroes(Key); key.@"9" = true; }, 58 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@":" = true; }, 59 => { + key = std.mem.zeroes(Key); key.@";" = true; }, 60 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@"<" = true; }, 61 => { + key = std.mem.zeroes(Key); key.@"=" = true; }, 62 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@">" = true; }, 63 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@"?" = true; }, 64 => { - key.shift = true; - key.@"2" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key.@"@" = true; }, @@ -565,12 +581,15 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.z = true; }, 91 => { + key = std.mem.zeroes(Key); key.@"[" = true; }, 92 => { + key = std.mem.zeroes(Key); key.@"\\" = true; }, 93 => { + key = std.mem.zeroes(Key); key.@"]" = true; }, 94 => { @@ -578,14 +597,11 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.@"^" = true; }, 95 => { - key.shift = true; - key.@"-" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key._ = true; }, 96 => { + key = std.mem.zeroes(Key); key.@"`" = true; }, 97 => { @@ -667,34 +683,21 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.z = true; }, 123 => { - key.shift = true; key.@"{" = true; }, 124 => { - key.shift = true; - key.@"\\" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key.@"|" = true; }, 125 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@"}" = true; }, 126 => { - key.shift = true; - key.@"`" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key.@"~" = true; }, 127 => { - key.ctrl = true; - key.@"8" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key.backspace = true; }, From ee3196bab89edb2bcdd2359903586bf288c8177f Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 11 May 2026 21:00:52 +0200 Subject: [PATCH 11/77] Fix labels_max_length calculation (closes #984) Signed-off-by: AnErrupTion --- src/main.zig | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index 35239d7..6413935 100644 --- a/src/main.zig +++ b/src/main.zig @@ -380,7 +380,16 @@ pub fn main(init: std.process.Init) !void { // Initialize terminal buffer try state.log_file.info(state.io, "tui", "initializing terminal buffer", .{}); - state.labels_max_length = @max(TerminalBuffer.strWidth(state.lang.login), TerminalBuffer.strWidth(state.lang.password)); + var labels = [_][]const u8{ + state.lang.login, + state.lang.password, + state.lang.wayland, + state.lang.x11, + state.lang.shell, + state.lang.xinitrc, + state.lang.custom, + }; + state.labels_max_length = maxWidths(&labels); var seed: u64 = undefined; state.io.random(std.mem.asBytes(&seed)); // Get a random seed for the PRNG (used by animations) @@ -1333,6 +1342,16 @@ pub fn main(init: std.process.Init) !void { ); } +fn maxWidths(labels: [][]const u8) usize { + var max_width: usize = 0; + + for (labels) |label| { + max_width = @max(max_width, TerminalBuffer.strWidth(label)); + } + + return max_width; +} + fn uiErrorHandler(err: anyerror, ctx: *anyopaque) anyerror!void { var state: *UiState = @ptrCast(@alignCast(ctx)); From de8579854c3c8d704d7eff548ef151ffd2fec2f5 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 11 May 2026 21:03:01 +0200 Subject: [PATCH 12/77] Use $EXECUTABLE_NAME in kmscon service Signed-off-by: AnErrupTion --- res/ly-kmsconvt@.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/ly-kmsconvt@.service b/res/ly-kmsconvt@.service index 3e7d1fd..80eb1da 100644 --- a/res/ly-kmsconvt@.service +++ b/res/ly-kmsconvt@.service @@ -5,7 +5,7 @@ After=kmsconvt@%i.service Conflicts=kmsconvt@%i.service [Service] -ExecStart=$PREFIX_DIRECTORY/bin/kmscon --font-engine unifont --vt=%I --seats=seat0 --login -- $PREFIX_DIRECTORY/bin/ly --use-kmscon-vt +ExecStart=$PREFIX_DIRECTORY/bin/kmscon --font-engine unifont --vt=%I --seats=seat0 --login -- $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME --use-kmscon-vt StandardInput=tty UtmpIdentifier=%I TTYPath=/dev/%I From cd426bb3df9da46b938aec3917897bc880675eb1 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 11 May 2026 21:09:46 +0200 Subject: [PATCH 13/77] Start Ly v1.4.1 development cycle Signed-off-by: AnErrupTion --- build.zig | 2 +- build.zig.zon | 2 +- ly-core/build.zig.zon | 2 +- ly-ui/build.zig.zon | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index 2aeac26..2cdb079 100644 --- a/build.zig +++ b/build.zig @@ -23,7 +23,7 @@ comptime { } } -const ly_version = std.SemanticVersion{ .major = 1, .minor = 4, .patch = 0 }; +const ly_version = std.SemanticVersion{ .major = 1, .minor = 4, .patch = 1 }; var dest_directory: []const u8 = undefined; var config_directory: []const u8 = undefined; diff --git a/build.zig.zon b/build.zig.zon index 63e8c32..2f4c1be 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .ly, - .version = "1.4.0", + .version = "1.4.1", .fingerprint = 0xa148ffcc5dc2cb59, .minimum_zig_version = "0.16.0", .dependencies = .{ diff --git a/ly-core/build.zig.zon b/ly-core/build.zig.zon index a389405..8998484 100644 --- a/ly-core/build.zig.zon +++ b/ly-core/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .ly_core, - .version = "1.0.0", + .version = "1.0.1", .fingerprint = 0xddda7afda795472, .minimum_zig_version = "0.16.0", .dependencies = .{ diff --git a/ly-ui/build.zig.zon b/ly-ui/build.zig.zon index 598cba0..2ec2741 100644 --- a/ly-ui/build.zig.zon +++ b/ly-ui/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .ly_ui, - .version = "1.0.0", + .version = "1.0.1", .fingerprint = 0x8d11bf85a74ec803, .minimum_zig_version = "0.16.0", .dependencies = .{ From 1080583233c611107798d69303a877b512073d8b Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 1 May 2026 20:54:54 +0200 Subject: [PATCH 14/77] Fix log file race condition Signed-off-by: AnErrupTion --- src/auth.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/auth.zig b/src/auth.zig index 87ddc09..6a97fff 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -417,19 +417,27 @@ fn xauth(log_file: *LogFile, allocator: std.mem.Allocator, io: std.Io, display_n const magic_cookie = mcookie(io); + log_file.deinit(io); + const pid = std.posix.system.fork(); if (pid == 0) { + try log_file.reinit(io); + var cmd_buffer: [1024]u8 = undefined; const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} add {s} . {s}", .{ options.xauth_cmd, display_name, magic_cookie }) catch std.process.exit(1); try log_file.info(io, "auth/x11", "executing: {s} -c {s}", .{ shell, cmd_str }); const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str }; _ = std.posix.system.execve(shell, &args, std.c.environ); + + log_file.deinit(io); std.process.exit(1); } var status: c_int = undefined; const result = std.posix.system.waitpid(pid, &status, 0); + + try log_file.reinit(io); if (interop.isError(result) or status != 0) { try log_file.err( io, From f6c44d5e57ecdfa1adfae8713cf849659d0c5d56 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sun, 3 May 2026 20:05:44 +0200 Subject: [PATCH 15/77] Fix building without X11 Signed-off-by: AnErrupTion --- build.zig | 6 +++++- ly-core/build.zig | 5 ++++- ly-ui/build.zig | 7 ++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index 2cdb079..fb0d07d 100644 --- a/build.zig +++ b/build.zig @@ -72,7 +72,11 @@ pub fn build(b: *std.Build) !void { .use_llvm = true, }); - const ly_ui = b.dependency("ly_ui", .{ .target = target, .optimize = optimize }); + const ly_ui = b.dependency("ly_ui", .{ + .target = target, + .optimize = optimize, + .enable_x11_support = enable_x11_support, + }); exe.root_module.addImport("ly-ui", ly_ui.module("ly-ui")); exe.root_module.addOptions("build_options", build_options); diff --git a/ly-core/build.zig b/ly-core/build.zig index dc722b5..f6574de 100644 --- a/ly-core/build.zig +++ b/ly-core/build.zig @@ -4,6 +4,7 @@ const Translator = @import("translate_c").Translator; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const enable_x11_support = b.option(bool, "enable_x11_support", "Enable X11 support") orelse true; const mod = b.addModule("ly-core", .{ .root_source_file = b.path("src/root.zig"), .target = target, @@ -20,7 +21,9 @@ pub fn build(b: *std.Build) void { addCImport(b, mod, translate_c, target, optimize, "pam", "#include "); addCImport(b, mod, translate_c, target, optimize, "utmp", "#include "); - addCImport(b, mod, translate_c, target, optimize, "xcb", "#include "); + if (enable_x11_support) { + addCImport(b, mod, translate_c, target, optimize, "xcb", "#include "); + } if (target.result.os.tag == .freebsd) { addCImport(b, mod, translate_c, target, optimize, "pwd", \\#include diff --git a/ly-ui/build.zig b/ly-ui/build.zig index a7a3051..7397873 100644 --- a/ly-ui/build.zig +++ b/ly-ui/build.zig @@ -4,13 +4,18 @@ const Translator = @import("translate_c").Translator; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const enable_x11_support = b.option(bool, "enable_x11_support", "Enable X11 support") orelse true; const mod = b.addModule("ly-ui", .{ .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize, }); - const ly_core = b.dependency("ly_core", .{ .target = target, .optimize = optimize }); + const ly_core = b.dependency("ly_core", .{ + .target = target, + .optimize = optimize, + .enable_x11_support = enable_x11_support, + }); mod.addImport("ly-core", ly_core.module("ly-core")); const termbox_dep = b.dependency("termbox2", .{ From 692ca9f7b53793b4fd0bc1bb613d1014df36f376 Mon Sep 17 00:00:00 2001 From: Titanium Brain Date: Sat, 9 May 2026 21:06:45 +0200 Subject: [PATCH 16/77] Resolve merge conflict Signed-off-by: AnErrupTion --- ly-ui/src/TerminalBuffer.zig | 6 +++++ src/animations/DurFile.zig | 51 +++++++----------------------------- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/ly-ui/src/TerminalBuffer.zig b/ly-ui/src/TerminalBuffer.zig index 565593b..1fd9999 100644 --- a/ly-ui/src/TerminalBuffer.zig +++ b/ly-ui/src/TerminalBuffer.zig @@ -381,6 +381,12 @@ pub fn setCell(x: usize, y: usize, cell: Cell) void { ); } +pub fn setCellBoundsChecked(self: *TerminalBuffer, x: isize, y: isize, cell: Cell) void { + if (0 <= x and x < self.width and 0 <= y and y < self.height) { + cell.put(@intCast(x), @intCast(y)); + } +} + pub fn reclaim(self: TerminalBuffer) !void { if (self.termios) |termios| { // Take back control of the TTY diff --git a/src/animations/DurFile.zig b/src/animations/DurFile.zig index c20c2d2..a709e3a 100644 --- a/src/animations/DurFile.zig +++ b/src/animations/DurFile.zig @@ -311,7 +311,6 @@ io: std.Io, terminal_buffer: *TerminalBuffer, dur_movie: DurFormat, frames: usize, -frame_size: UVec2, start_pos: IVec2, full_color: bool, animate: *bool, @@ -329,14 +328,11 @@ fn center(v: u32) i64 { } fn calc_start_position(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat, offset_alignment: DurOffsetAlignment, offset: IVec2) IVec2 { - const buf_width: u32 = @intCast(terminal_buffer.width); - const buf_height: u32 = @intCast(terminal_buffer.height); + const buf_width: i64 = @intCast(terminal_buffer.width); + const buf_height: i64 = @intCast(terminal_buffer.height); - var movie_width: u32 = @intCast(dur_movie.columns.?); - var movie_height: u32 = @intCast(dur_movie.lines.?); - - if (movie_width > buf_width) movie_width = buf_width; - if (movie_height > buf_height) movie_height = buf_height; + const movie_width: i64 = @intCast(dur_movie.columns.?); + const movie_height: i64 = @intCast(dur_movie.lines.?); const start_pos: IVec2 = switch (offset_alignment) { DurOffsetAlignment.center => .{ center(buf_width) - center(movie_width), center(buf_height) - center(movie_height) }, @@ -353,20 +349,6 @@ fn calc_start_position(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat, return start_pos + offset; } -fn calc_frame_size(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat) UVec2 { - const buf_width: u32 = @intCast(terminal_buffer.width); - const buf_height: u32 = @intCast(terminal_buffer.height); - - const movie_width: u32 = @intCast(dur_movie.columns.?); - const movie_height: u32 = @intCast(dur_movie.lines.?); - - // Draw only the needed amount if movie smaller than screen. If movie is bigger, we will just draw entire screen - const frame_width = if (movie_width < buf_width) movie_width else buf_width; - const frame_height = if (movie_height < buf_height) movie_height else buf_height; - - return .{ frame_width, frame_height }; -} - pub fn init( allocator: Allocator, io: std.Io, @@ -405,7 +387,6 @@ pub fn init( const offset: IVec2 = .{ x_offset, y_offset }; const start_pos = calc_start_position(terminal_buffer, &dur_movie, offset_alignment, offset); - const frame_size = calc_frame_size(terminal_buffer, &dur_movie); // Convert dur fps to frames per ms const frame_time: u32 = @trunc(1000 / dur_movie.framerate.?); @@ -418,7 +399,6 @@ pub fn init( .terminal_buffer = terminal_buffer, .frames = 0, .time_previous = std.Io.Timestamp.now(io, .real).toMilliseconds(), - .frame_size = frame_size, .start_pos = start_pos, .full_color = full_color, .animate = animate, @@ -453,9 +433,8 @@ fn deinit(self: *DurFile) void { } fn realloc(self: *DurFile) !void { - // when terminal size changes, we need to recalculate the start_pos and frame_size based on the new size + // when terminal size changes, we need to recalculate the start_pos based on the new size self.start_pos = calc_start_position(self.terminal_buffer, &self.dur_movie, self.offset_alignment, self.offset); - self.frame_size = calc_frame_size(self.terminal_buffer, &self.dur_movie); } fn draw(self: *DurFile) void { @@ -463,24 +442,14 @@ fn draw(self: *DurFile) void { const current_frame = self.dur_movie.frames.items[self.frames]; - const buf_width: u32 = @intCast(self.terminal_buffer.width); - const buf_height: u32 = @intCast(self.terminal_buffer.height); - // y is used as an iterator in the durformat, while cell_y gives us the correct placement for the cell (same for x) - for (0..self.frame_size[VEC_Y]) |y| { - const y_offset_i = @as(i32, @intCast(y)) + self.start_pos[VEC_Y]; - // we skip the pass if it falls outside of the draw window (ensure no int underflow) - const cell_y: u32 = if (y_offset_i >= 0 and y_offset_i < buf_height) @intCast(y_offset_i) else continue; + for (0..@intCast(self.dur_movie.lines)) |y| { + const cell_y = @as(i32, @intCast(y)) + self.start_pos[VEC_Y]; var iter = std.unicode.Utf8View.initUnchecked(current_frame.contents[y]).iterator(); - for (0..self.frame_size[VEC_X]) |x| { - const x_offset_i = @as(i32, @intCast(x)) + self.start_pos[VEC_X]; - // skip pass, same as y but also increment the codepoint iter to fetch correct values in later passes - const cell_x: u32 = if (x_offset_i >= 0 and x_offset_i < buf_width) @intCast(x_offset_i) else { - _ = iter.nextCodepoint().?; - continue; - }; + for (0..@intCast(self.dur_movie.columns)) |x| { + const cell_x = @as(i32, @intCast(x)) + self.start_pos[VEC_X]; const codepoint: u21 = iter.nextCodepoint().?; const color_map = current_frame.colorMap[x][y]; @@ -498,7 +467,7 @@ fn draw(self: *DurFile) void { const cell = Cell{ .ch = @intCast(codepoint), .fg = fg_color, .bg = bg_color }; - cell.put(cell_x, cell_y); + self.terminal_buffer.setCellBoundsChecked(cell_x, cell_y, cell); } } From e0f915d440ee177cdd75ef91e6893287ad07142a Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sun, 10 May 2026 13:55:19 +0200 Subject: [PATCH 17/77] Improve keyboard handling (closes #982) Signed-off-by: AnErrupTion --- ly-ui/src/keyboard.zig | 55 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/ly-ui/src/keyboard.zig b/ly-ui/src/keyboard.zig index 2e6e0e2..a90148b 100644 --- a/ly-ui/src/keyboard.zig +++ b/ly-ui/src/keyboard.zig @@ -171,6 +171,7 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { const code = if (tb_event.ch == 0 and tb_event.key < 128) tb_event.key else tb_event.ch; switch (code) { + // Non-standard control codes 0 => { key.ctrl = true; key.@"2" = true; @@ -342,7 +343,9 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key = std.mem.zeroes(Key); key._ = true; }, + // Standard ASCII characters 32 => { + key = std.mem.zeroes(Key); key.@" " = true; }, 33 => { @@ -370,6 +373,7 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.@"&" = true; }, 39 => { + key = std.mem.zeroes(Key); key.@"'" = true; }, 40 => { @@ -389,74 +393,86 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.@"+" = true; }, 44 => { + key = std.mem.zeroes(Key); key.@"," = true; }, 45 => { + key = std.mem.zeroes(Key); key.@"-" = true; }, 46 => { + key = std.mem.zeroes(Key); key.@"." = true; }, 47 => { + key = std.mem.zeroes(Key); key.@"/" = true; }, 48 => { + key = std.mem.zeroes(Key); key.@"0" = true; }, 49 => { + key = std.mem.zeroes(Key); key.@"1" = true; }, 50 => { + key = std.mem.zeroes(Key); key.@"2" = true; }, 51 => { + key = std.mem.zeroes(Key); key.@"3" = true; }, 52 => { + key = std.mem.zeroes(Key); key.@"4" = true; }, 53 => { + key = std.mem.zeroes(Key); key.@"5" = true; }, 54 => { + key = std.mem.zeroes(Key); key.@"6" = true; }, 55 => { + key = std.mem.zeroes(Key); key.@"7" = true; }, 56 => { + key = std.mem.zeroes(Key); key.@"8" = true; }, 57 => { + key = std.mem.zeroes(Key); key.@"9" = true; }, 58 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@":" = true; }, 59 => { + key = std.mem.zeroes(Key); key.@";" = true; }, 60 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@"<" = true; }, 61 => { + key = std.mem.zeroes(Key); key.@"=" = true; }, 62 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@">" = true; }, 63 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@"?" = true; }, 64 => { - key.shift = true; - key.@"2" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key.@"@" = true; }, @@ -565,12 +581,15 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.z = true; }, 91 => { + key = std.mem.zeroes(Key); key.@"[" = true; }, 92 => { + key = std.mem.zeroes(Key); key.@"\\" = true; }, 93 => { + key = std.mem.zeroes(Key); key.@"]" = true; }, 94 => { @@ -578,14 +597,11 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.@"^" = true; }, 95 => { - key.shift = true; - key.@"-" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key._ = true; }, 96 => { + key = std.mem.zeroes(Key); key.@"`" = true; }, 97 => { @@ -667,34 +683,21 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { key.z = true; }, 123 => { - key.shift = true; key.@"{" = true; }, 124 => { - key.shift = true; - key.@"\\" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key.@"|" = true; }, 125 => { - key.shift = true; + key = std.mem.zeroes(Key); key.@"}" = true; }, 126 => { - key.shift = true; - key.@"`" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key.@"~" = true; }, 127 => { - key.ctrl = true; - key.@"8" = true; - try keys.append(allocator, key); - key = std.mem.zeroes(Key); key.backspace = true; }, From 2a4139176482220f5c28ee25cee36d27b1fdad45 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 11 May 2026 21:00:52 +0200 Subject: [PATCH 18/77] Fix labels_max_length calculation (closes #984) Signed-off-by: AnErrupTion --- src/main.zig | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index 81c44b4..f9f4a51 100644 --- a/src/main.zig +++ b/src/main.zig @@ -359,7 +359,16 @@ pub fn main(init: std.process.Init) !void { // Initialize terminal buffer try state.log_file.info(state.io, "tui", "initializing terminal buffer", .{}); - state.labels_max_length = @max(TerminalBuffer.strWidth(state.lang.login), TerminalBuffer.strWidth(state.lang.password)); + var labels = [_][]const u8{ + state.lang.login, + state.lang.password, + state.lang.wayland, + state.lang.x11, + state.lang.shell, + state.lang.xinitrc, + state.lang.custom, + }; + state.labels_max_length = maxWidths(&labels); var seed: u64 = undefined; state.io.random(std.mem.asBytes(&seed)); // Get a random seed for the PRNG (used by animations) @@ -1312,6 +1321,16 @@ pub fn main(init: std.process.Init) !void { ); } +fn maxWidths(labels: [][]const u8) usize { + var max_width: usize = 0; + + for (labels) |label| { + max_width = @max(max_width, TerminalBuffer.strWidth(label)); + } + + return max_width; +} + fn uiErrorHandler(err: anyerror, ctx: *anyopaque) anyerror!void { var state: *UiState = @ptrCast(@alignCast(ctx)); From efa56ae770751db9ac3daa9e4af2d0539d836b6c Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 11 May 2026 21:03:01 +0200 Subject: [PATCH 19/77] Use $EXECUTABLE_NAME in kmscon service Signed-off-by: AnErrupTion --- res/ly-kmsconvt@.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/ly-kmsconvt@.service b/res/ly-kmsconvt@.service index 3e7d1fd..80eb1da 100644 --- a/res/ly-kmsconvt@.service +++ b/res/ly-kmsconvt@.service @@ -5,7 +5,7 @@ After=kmsconvt@%i.service Conflicts=kmsconvt@%i.service [Service] -ExecStart=$PREFIX_DIRECTORY/bin/kmscon --font-engine unifont --vt=%I --seats=seat0 --login -- $PREFIX_DIRECTORY/bin/ly --use-kmscon-vt +ExecStart=$PREFIX_DIRECTORY/bin/kmscon --font-engine unifont --vt=%I --seats=seat0 --login -- $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME --use-kmscon-vt StandardInput=tty UtmpIdentifier=%I TTYPath=/dev/%I From afb1dc62a0568743c9a7952623ec179128c73340 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 11 May 2026 21:15:18 +0200 Subject: [PATCH 20/77] Fix merge conflict issues Signed-off-by: AnErrupTion --- src/animations/DurFile.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/animations/DurFile.zig b/src/animations/DurFile.zig index a709e3a..7e56520 100644 --- a/src/animations/DurFile.zig +++ b/src/animations/DurFile.zig @@ -323,8 +323,8 @@ offset_alignment: DurOffsetAlignment, offset: IVec2, // if the user has an even number of columns or rows, we will default to the left or higher position (e.g. 4 columns center = .x..) -fn center(v: u32) i64 { - return @intCast((v / 2) + (v % 2)); +fn center(v: i64) i64 { + return @intCast(@divTrunc(v, 2) + @mod(v, 2)); } fn calc_start_position(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat, offset_alignment: DurOffsetAlignment, offset: IVec2) IVec2 { @@ -443,12 +443,12 @@ fn draw(self: *DurFile) void { const current_frame = self.dur_movie.frames.items[self.frames]; // y is used as an iterator in the durformat, while cell_y gives us the correct placement for the cell (same for x) - for (0..@intCast(self.dur_movie.lines)) |y| { + for (0..@intCast(self.dur_movie.lines.?)) |y| { const cell_y = @as(i32, @intCast(y)) + self.start_pos[VEC_Y]; var iter = std.unicode.Utf8View.initUnchecked(current_frame.contents[y]).iterator(); - for (0..@intCast(self.dur_movie.columns)) |x| { + for (0..@intCast(self.dur_movie.columns.?)) |x| { const cell_x = @as(i32, @intCast(x)) + self.start_pos[VEC_X]; const codepoint: u21 = iter.nextCodepoint().?; From 741e9e034571a2a7d84486877fd665dbb3c22a4a Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Tue, 12 May 2026 20:35:17 +0200 Subject: [PATCH 21/77] Use correct naming convention for functions in DurFile.zig Signed-off-by: AnErrupTion --- src/animations/DurFile.zig | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/animations/DurFile.zig b/src/animations/DurFile.zig index 969157b..5999dbf 100644 --- a/src/animations/DurFile.zig +++ b/src/animations/DurFile.zig @@ -19,7 +19,7 @@ const LogFile = ly_core.LogFile; const enums = @import("../enums.zig"); const DurOffsetAlignment = enums.DurOffsetAlignment; -fn read_decompress_file(allocator: Allocator, io: std.Io, file_path: []const u8) ![]u8 { +fn readDecompressFile(allocator: Allocator, io: std.Io, file_path: []const u8) ![]u8 { const file_buffer = std.Io.Dir.cwd().openFile(io, file_path, .{}) catch { return error.FileNotFound; }; @@ -113,7 +113,7 @@ const DurFormatRaw = struct { }; } - fn parse_dur_from_json(self: *DurFormatRaw, allocator: Allocator, dur_json_root: Json.Value) !void { + fn parseFromJson(self: *DurFormatRaw, allocator: Allocator, dur_json_root: Json.Value) !void { var dur_movie = if (dur_json_root.object.get("DurMovie")) |dm| dm.object else return error.NotValidFile; // Depending on the version, a dur file can have different json object names (ie: columns vs sizeX) @@ -160,14 +160,14 @@ const DurFormatRaw = struct { } } - pub fn create_from_file(self: *DurFormatRaw, allocator: Allocator, io: std.Io, file_path: []const u8) !void { - const file_decompressed = try read_decompress_file(allocator, io, file_path); + pub fn createFromFile(self: *DurFormatRaw, allocator: Allocator, io: std.Io, file_path: []const u8) !void { + const file_decompressed = try readDecompressFile(allocator, io, file_path); defer allocator.free(file_decompressed); const parsed = try Json.parseFromSlice(Json.Value, allocator, file_decompressed, .{}); defer parsed.deinit(); - try parse_dur_from_json(self, allocator, parsed.value); + try parseFromJson(self, allocator, parsed.value); } pub fn init(allocator: Allocator) DurFormatRaw { @@ -266,7 +266,7 @@ const durcolor_table_to_color16 = [17]u32{ 15, // 16 bright white }; -fn sixcube_to_channel(sixcube: u32) u32 { +fn sixCubeToChannel(sixcube: u32) u32 { // Although the range top for the extended range is 0xFF, 6 is not divisible into 0xFF, // so we use 0xF0 instead with a scaler const equal_divisions = 0xF0 / 6; @@ -277,7 +277,7 @@ fn sixcube_to_channel(sixcube: u32) u32 { return if (sixcube > 0) (sixcube * equal_divisions) + scaler else 0; } -fn convert_256_to_rgb(color_256: u32) u32 { +fn convert256ToRgb(color_256: u32) u32 { var rgb_color: u32 = 0; // 0 - 15 is the standard color range, map to array table @@ -293,9 +293,9 @@ fn convert_256_to_rgb(color_256: u32) u32 { // divide by 1 gets the height of the cube (divide 1 for clarity for what we are doing) // each channel can be 6 levels of brightness hence remander operation of 6 // finally bitshift to correct rgb channel (16 for red, 8 for green, 0 for blue) - rgb_color |= sixcube_to_channel(((color_256 - 16) / 36) % 6) << 16; - rgb_color |= sixcube_to_channel(((color_256 - 16) / 6) % 6) << 8; - rgb_color |= sixcube_to_channel(((color_256 - 16) / 1) % 6); + rgb_color |= sixCubeToChannel(((color_256 - 16) / 36) % 6) << 16; + rgb_color |= sixCubeToChannel(((color_256 - 16) / 6) % 6) << 8; + rgb_color |= sixCubeToChannel(((color_256 - 16) / 1) % 6); } // 232 - 255 is the grayscale range else { @@ -353,7 +353,7 @@ fn center(v: i64) i64 { return @intCast(@divTrunc(v, 2) + @mod(v, 2)); } -fn calc_start_position(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat, offset_alignment: DurOffsetAlignment, offset: IVec2) IVec2 { +fn calculateStartPos(terminal_buffer: *TerminalBuffer, dur_movie: *DurFormat, offset_alignment: DurOffsetAlignment, offset: IVec2) IVec2 { const buf_width: i64 = @intCast(terminal_buffer.width); const buf_height: i64 = @intCast(terminal_buffer.height); @@ -392,7 +392,7 @@ pub fn init( var dur_movie_raw: DurFormatRaw = .init(allocator); defer dur_movie_raw.deinit(); - dur_movie_raw.create_from_file(allocator, io, file_path) catch |err| switch (err) { + dur_movie_raw.createFromFile(allocator, io, file_path) catch |err| switch (err) { error.FileNotFound => { try log_file.err(io, "tui", "dur_file was not found at: {s}", .{file_path}); return err; @@ -464,7 +464,7 @@ pub fn init( const offset: IVec2 = .{ x_offset, y_offset }; - const start_pos = calc_start_position(terminal_buffer, &dur_movie, offset_alignment, offset); + const start_pos = calculateStartPos(terminal_buffer, &dur_movie, offset_alignment, offset); // Convert dur fps to frames per ms const frame_time: u32 = @trunc(1000 / dur_movie.framerate); @@ -512,7 +512,7 @@ fn deinit(self: *DurFile) void { fn realloc(self: *DurFile) !void { // when terminal size changes, we need to recalculate the start_pos based on the new size - self.start_pos = calc_start_position(self.terminal_buffer, &self.dur_movie, self.offset_alignment, self.offset); + self.start_pos = calculateStartPos(self.terminal_buffer, &self.dur_movie, self.offset_alignment, self.offset); } fn draw(self: *DurFile) void { @@ -540,8 +540,8 @@ fn draw(self: *DurFile) void { color_map_1 = durcolor_table_to_color16[color_map_1 + 1]; // Add 1, dur source stores it like this for some reason } - const fg_color = if (self.full_color) convert_256_to_rgb(color_map_0) else tb_color_16[color_map_0]; - const bg_color = if (self.full_color) convert_256_to_rgb(color_map_1) else tb_color_16[color_map_1]; + const fg_color = if (self.full_color) convert256ToRgb(color_map_0) else tb_color_16[color_map_0]; + const bg_color = if (self.full_color) convert256ToRgb(color_map_1) else tb_color_16[color_map_1]; const cell = Cell{ .ch = @intCast(codepoint), .fg = fg_color, .bg = bg_color }; From 9b1965a3d813ddd3c34e51a2772b58d82aab78fb Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 15 May 2026 21:42:13 +0200 Subject: [PATCH 22/77] Always build translate-c in Debug Signed-off-by: AnErrupTion --- ly-core/build.zig | 1 - ly-ui/build.zig | 1 - 2 files changed, 2 deletions(-) diff --git a/ly-core/build.zig b/ly-core/build.zig index f6574de..56dc4ec 100644 --- a/ly-core/build.zig +++ b/ly-core/build.zig @@ -16,7 +16,6 @@ pub fn build(b: *std.Build) void { const translate_c = b.dependency("translate_c", .{ .target = target, - .optimize = optimize, }); addCImport(b, mod, translate_c, target, optimize, "pam", "#include "); diff --git a/ly-ui/build.zig b/ly-ui/build.zig index 7397873..2e3ce6b 100644 --- a/ly-ui/build.zig +++ b/ly-ui/build.zig @@ -25,7 +25,6 @@ pub fn build(b: *std.Build) void { const translate_c_dep = b.dependency("translate_c", .{ .target = target, - .optimize = optimize, }); const termbox2: Translator = .init(translate_c_dep, .{ From afee1d91944851f2f9306ad22d55a331ab5bfb20 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 15 May 2026 21:46:20 +0200 Subject: [PATCH 23/77] Remove TODO and stop forcing LLVM usage (again) Signed-off-by: AnErrupTion --- build.zig | 1 - ly-core/src/interop.zig | 1 - 2 files changed, 2 deletions(-) diff --git a/build.zig b/build.zig index 45a548b..9e89029 100644 --- a/build.zig +++ b/build.zig @@ -69,7 +69,6 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, .link_libc = true, }), - .use_llvm = true, }); const ly_ui = b.dependency("ly_ui", .{ diff --git a/ly-core/src/interop.zig b/ly-core/src/interop.zig index f23583c..69e02ff 100644 --- a/ly-core/src/interop.zig +++ b/ly-core/src/interop.zig @@ -235,7 +235,6 @@ fn PlatformStruct() type { const platform_struct = PlatformStruct(); -// TODO 0.16.0: Can we get away with this? pub fn isError(result: anytype) bool { if (@typeInfo(@TypeOf(result)).int.signedness == .signed) { return result < 0; From 78794b3e10005291ffa9bde92e27568241bec8b7 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 15 May 2026 23:22:50 +0200 Subject: [PATCH 24/77] Stream dur reading instead of reading all at once Signed-off-by: AnErrupTion --- src/animations/DurFile.zig | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/animations/DurFile.zig b/src/animations/DurFile.zig index 5999dbf..ca3922c 100644 --- a/src/animations/DurFile.zig +++ b/src/animations/DurFile.zig @@ -19,25 +19,6 @@ const LogFile = ly_core.LogFile; const enums = @import("../enums.zig"); const DurOffsetAlignment = enums.DurOffsetAlignment; -fn readDecompressFile(allocator: Allocator, io: std.Io, file_path: []const u8) ![]u8 { - const file_buffer = std.Io.Dir.cwd().openFile(io, file_path, .{}) catch { - return error.FileNotFound; - }; - defer file_buffer.close(io); - - var file_reader_buffer: [4096]u8 = undefined; - var decompress_buffer: [flate.max_window_len]u8 = undefined; - - var file_reader = file_buffer.reader(io, &file_reader_buffer); - var decompress: flate.Decompress = .init(&file_reader.interface, .gzip, &decompress_buffer); - - const file_decompressed = decompress.reader.allocRemaining(allocator, .unlimited) catch { - return error.NotValidFile; - }; - - return file_decompressed; -} - const Frame = struct { frameNumber: i32, delay: f32, @@ -161,13 +142,22 @@ const DurFormatRaw = struct { } pub fn createFromFile(self: *DurFormatRaw, allocator: Allocator, io: std.Io, file_path: []const u8) !void { - const file_decompressed = try readDecompressFile(allocator, io, file_path); - defer allocator.free(file_decompressed); + const file = try std.Io.Dir.cwd().openFile(io, file_path, .{}); + defer file.close(io); - const parsed = try Json.parseFromSlice(Json.Value, allocator, file_decompressed, .{}); - defer parsed.deinit(); + var reader_buffer: [4096]u8 = undefined; + var decompress_buffer: [flate.max_window_len]u8 = undefined; - try parseFromJson(self, allocator, parsed.value); + var file_reader = file.reader(io, &reader_buffer); + var decompress: flate.Decompress = .init(&file_reader.interface, .gzip, &decompress_buffer); + + var json_reader = Json.Reader.init(allocator, &decompress.reader); + defer json_reader.deinit(); + + const json = try Json.parseFromTokenSource(Json.Value, allocator, &json_reader, .{}); + defer json.deinit(); + + try parseFromJson(self, allocator, json.value); } pub fn init(allocator: Allocator) DurFormatRaw { From 05c1d4becee7ca4812b2d2a395659d6bb0e2f3b5 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sat, 16 May 2026 10:33:06 +0200 Subject: [PATCH 25/77] Improve errors for lock state Signed-off-by: AnErrupTion --- src/main.zig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main.zig b/src/main.zig index 6413935..a2a8512 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1788,7 +1788,7 @@ fn updateNumlock(self: *Label, ptr: *anyopaque) !void { try state.log_file.err( state.io, "sys", - "failed to get lock state: {s}", + "failed to get lock state for numlock: {s}", .{@errorName(err)}, ); return; @@ -1802,8 +1802,17 @@ fn updateCapslock(self: *Label, ptr: *anyopaque) !void { const lock_state = interop.getLockState() catch |err| { self.update_fn = null; - try state.info_line.addMessage(state.lang.err_lock_state, state.config.error_bg, state.config.error_fg); - try state.log_file.err(state.io, "sys", "failed to get lock state: {s}", .{@errorName(err)}); + try state.info_line.addMessage( + state.lang.err_lock_state, + state.config.error_bg, + state.config.error_fg, + ); + try state.log_file.err( + state.io, + "sys", + "failed to get lock state for capslock: {s}", + .{@errorName(err)}, + ); return; }; From 4c066ce564f18080b38422b2a2f28261c87fc1ae Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sun, 17 May 2026 13:26:46 +0200 Subject: [PATCH 26/77] Handle termbox2 errors Signed-off-by: AnErrupTion --- ly-ui/src/Cell.zig | 4 +- ly-ui/src/TerminalBuffer.zig | 108 ++++++++++++++++++------------ ly-ui/src/components/BigLabel.zig | 2 +- ly-ui/src/components/Box.zig | 22 +++--- ly-ui/src/components/Label.zig | 4 +- ly-ui/src/components/Text.zig | 8 +-- ly-ui/src/components/generic.zig | 8 +-- src/animations/Cascade.zig | 6 +- src/animations/ColorMix.zig | 2 +- src/animations/Doom.zig | 6 +- src/animations/DurFile.zig | 2 +- src/animations/GameOfLife.zig | 2 +- src/animations/Matrix.zig | 4 +- src/components/InfoLine.zig | 6 +- src/components/Session.zig | 4 +- src/components/UserList.zig | 4 +- src/main.zig | 12 ++-- 17 files changed, 114 insertions(+), 90 deletions(-) diff --git a/ly-ui/src/Cell.zig b/ly-ui/src/Cell.zig index 35d0cf0..59eb4aa 100644 --- a/ly-ui/src/Cell.zig +++ b/ly-ui/src/Cell.zig @@ -14,8 +14,8 @@ pub fn init(ch: u32, fg: u32, bg: u32) Cell { }; } -pub fn put(self: Cell, x: usize, y: usize) void { +pub fn put(self: Cell, x: usize, y: usize) !void { if (self.ch == 0) return; - TerminalBuffer.setCell(x, y, self); + try TerminalBuffer.setCell(x, y, self); } diff --git a/ly-ui/src/TerminalBuffer.zig b/ly-ui/src/TerminalBuffer.zig index 1fd9999..d0b3e3d 100644 --- a/ly-ui/src/TerminalBuffer.zig +++ b/ly-ui/src/TerminalBuffer.zig @@ -103,24 +103,39 @@ pub fn init( random: Random, ) !TerminalBuffer { // Initialize termbox - _ = termbox.tb_init(); + if (termbox.tb_init() != 0) return error.TermboxInitFailed; if (options.full_color) { - _ = termbox.tb_set_output_mode(termbox.TB_OUTPUT_TRUECOLOR); - try log_file.info(io, "tui", "termbox2 set to 24-bit color output mode", .{}); + if (termbox.tb_set_output_mode(termbox.TB_OUTPUT_TRUECOLOR) != 0) { + return error.TermboxSetOutputModeFailed; + } + try log_file.info( + io, + "tui", + "termbox2 set to 24-bit color output mode", + .{}, + ); } else { - try log_file.info(io, "tui", "termbox2 set to eight-color output mode", .{}); + try log_file.info( + io, + "tui", + "termbox2 set to eight-color output mode", + .{}, + ); } - _ = termbox.tb_clear(); - // Let's take some precautions here and clear the back buffer as well - try clearBackBuffer(); + try clearScreen(true); - const width: usize = @intCast(termbox.tb_width()); - const height: usize = @intCast(termbox.tb_height()); + const width = getWidth(); + const height = getHeight(); - try log_file.info(io, "tui", "screen resolution is {d}x{d}", .{ width, height }); + try log_file.info( + io, + "tui", + "screen resolution is {d}x{d}", + .{ width, height }, + ); return .{ .log_file = log_file, @@ -163,7 +178,7 @@ pub fn init( pub fn deinit(self: *TerminalBuffer) void { self.keybinds.deinit(); - TerminalBuffer.shutdown(); + TerminalBuffer.shutdown() catch {}; } pub fn runEventLoop( @@ -238,7 +253,7 @@ pub fn runEventLoop( } } - TerminalBuffer.presentBuffer(); + try TerminalBuffer.presentBuffer(); } if (inactivity_event_fn) |inactivity_fn| { @@ -338,31 +353,35 @@ pub fn getHeight() usize { return @intCast(termbox.tb_height()); } -pub fn setCursor(x: usize, y: usize) void { - _ = termbox.tb_set_cursor(@intCast(x), @intCast(y)); +pub fn setCursor(x: usize, y: usize) !void { + if (termbox.tb_set_cursor(@intCast(x), @intCast(y)) != 0) { + return error.TermboxSetCursorFailed; + } } pub fn clearScreen(clear_back_buffer: bool) !void { - _ = termbox.tb_clear(); + if (termbox.tb_clear() != 0) return error.TermboxClearFailed; if (clear_back_buffer) try clearBackBuffer(); } -pub fn shutdown() void { - _ = termbox.tb_shutdown(); +pub fn shutdown() !void { + if (termbox.tb_shutdown() != 0) return error.TermboxShutdownFailed; } -pub fn presentBuffer() void { - _ = termbox.tb_present(); +pub fn presentBuffer() !void { + if (termbox.tb_present() != 0) return error.TermboxPresentFailed; } pub fn getCell(x: usize, y: usize) ?Cell { var maybe_cell: ?*termbox.tb_cell = undefined; - _ = termbox.tb_get_cell( + if (termbox.tb_get_cell( @intCast(x), @intCast(y), 1, &maybe_cell, - ); + ) != 0) { + return null; + } if (maybe_cell) |cell| { return Cell.init(cell.ch, cell.fg, cell.bg); @@ -371,29 +390,31 @@ pub fn getCell(x: usize, y: usize) ?Cell { return null; } -pub fn setCell(x: usize, y: usize, cell: Cell) void { - _ = termbox.tb_set_cell( +pub fn setCell(x: usize, y: usize, cell: Cell) !void { + if (termbox.tb_set_cell( @intCast(x), @intCast(y), cell.ch, cell.fg, cell.bg, - ); + ) != 0) { + return error.TermboxSetCellFailed; + } } -pub fn setCellBoundsChecked(self: *TerminalBuffer, x: isize, y: isize, cell: Cell) void { +pub fn setCellBoundsChecked(self: *TerminalBuffer, x: isize, y: isize, cell: Cell) !void { if (0 <= x and x < self.width and 0 <= y and y < self.height) { - cell.put(@intCast(x), @intCast(y)); + try cell.put(@intCast(x), @intCast(y)); } } pub fn reclaim(self: TerminalBuffer) !void { if (self.termios) |termios| { // Take back control of the TTY - _ = termbox.tb_init(); + if (termbox.tb_init() != 0) return error.TermboxReinitFailed; - if (self.full_color) { - _ = termbox.tb_set_output_mode(termbox.TB_OUTPUT_TRUECOLOR); + if (self.full_color and termbox.tb_set_output_mode(termbox.TB_OUTPUT_TRUECOLOR) != 0) { + return error.TermboxSetOutputModeFailed; } try std.posix.tcsetattr(std.posix.STDIN_FILENO, .FLUSH, termios); @@ -464,14 +485,14 @@ pub fn drawText( y: usize, fg: u32, bg: u32, -) void { - const yc: c_int = @intCast(y); +) !void { const utf8view = std.unicode.Utf8View.init(text) catch return; var utf8 = utf8view.iterator(); - var i: c_int = @intCast(x); - while (utf8.nextCodepoint()) |codepoint| : (i += termbox.tb_wcwidth(codepoint)) { - _ = termbox.tb_set_cell(i, yc, codepoint, fg, bg); + var i = x; + while (utf8.nextCodepoint()) |codepoint| : (i += @intCast(termbox.tb_wcwidth(codepoint))) { + const cell = Cell.init(codepoint, fg, bg); + try cell.put(i, y); } } @@ -482,15 +503,16 @@ pub fn drawConfinedText( max_length: usize, fg: u32, bg: u32, -) void { - const yc: c_int = @intCast(y); +) !void { const utf8view = std.unicode.Utf8View.init(text) catch return; var utf8 = utf8view.iterator(); - var i: c_int = @intCast(x); - while (utf8.nextCodepoint()) |codepoint| : (i += termbox.tb_wcwidth(codepoint)) { - if (i - @as(c_int, @intCast(x)) >= max_length) break; - _ = termbox.tb_set_cell(i, yc, codepoint, fg, bg); + var i = x; + while (utf8.nextCodepoint()) |codepoint| : (i += @intCast(termbox.tb_wcwidth(codepoint))) { + if (i - x >= max_length) break; + + const cell = Cell.init(codepoint, fg, bg); + try cell.put(i, y); } } @@ -501,9 +523,9 @@ pub fn drawCharMultiple( length: usize, fg: u32, bg: u32, -) void { +) !void { const cell = Cell.init(char, fg, bg); - for (0..length) |xx| cell.put(x + xx, y); + for (0..length) |xx| try cell.put(x + xx, y); } // Every codepoint is assumed to have a width of 1. @@ -521,6 +543,8 @@ pub fn strWidth(str: []const u8) usize { } fn clearBackBuffer() !void { + if (termbox.global.initialized == 0) return; + // Clear the TTY because termbox2 doesn't seem to do it properly const capability = termbox.global.caps[termbox.TB_CAP_CLEAR_SCREEN]; const capability_slice = std.mem.span(capability); diff --git a/ly-ui/src/components/BigLabel.zig b/ly-ui/src/components/BigLabel.zig index bd9af6e..cb2f6b5 100644 --- a/ly-ui/src/components/BigLabel.zig +++ b/ly-ui/src/components/BigLabel.zig @@ -207,7 +207,7 @@ fn alphaBlit(x: usize, y: usize, tb_width: usize, tb_height: usize, cells: [CHAR for (0..CHAR_HEIGHT) |yy| { for (0..CHAR_WIDTH) |xx| { const cell = cells[yy * CHAR_WIDTH + xx]; - cell.put(x + xx, y + yy); + cell.put(x + xx, y + yy) catch {}; } } } diff --git a/ly-ui/src/components/Box.zig b/ly-ui/src/components/Box.zig index 7c753ae..af3a687 100644 --- a/ly-ui/src/components/Box.zig +++ b/ly-ui/src/components/Box.zig @@ -129,29 +129,29 @@ fn draw(self: *Box) void { self.bg, ); - left_up.put(self.left_pos.x - 1, self.left_pos.y - 1); - right_up.put(self.right_pos.x, self.left_pos.y - 1); - left_down.put(self.left_pos.x - 1, self.right_pos.y); - right_down.put(self.right_pos.x, self.right_pos.y); + left_up.put(self.left_pos.x - 1, self.left_pos.y - 1) catch {}; + right_up.put(self.right_pos.x, self.left_pos.y - 1) catch {}; + left_down.put(self.left_pos.x - 1, self.right_pos.y) catch {}; + right_down.put(self.right_pos.x, self.right_pos.y) catch {}; for (0..self.width) |i| { - top.put(self.left_pos.x + i, self.left_pos.y - 1); - bottom.put(self.left_pos.x + i, self.right_pos.y); + top.put(self.left_pos.x + i, self.left_pos.y - 1) catch {}; + bottom.put(self.left_pos.x + i, self.right_pos.y) catch {}; } top.ch = self.buffer.box_chars.left; bottom.ch = self.buffer.box_chars.right; for (0..self.height) |i| { - top.put(self.left_pos.x - 1, self.left_pos.y + i); - bottom.put(self.right_pos.x, self.left_pos.y + i); + top.put(self.left_pos.x - 1, self.left_pos.y + i) catch {}; + bottom.put(self.right_pos.x, self.left_pos.y + i) catch {}; } } if (self.blank_box) { for (0..self.height) |y| { for (0..self.width) |x| { - self.buffer.blank_cell.put(self.left_pos.x + x, self.left_pos.y + y); + self.buffer.blank_cell.put(self.left_pos.x + x, self.left_pos.y + y) catch {}; } } } @@ -164,7 +164,7 @@ fn draw(self: *Box) void { self.width, self.title_fg, self.bg, - ); + ) catch {}; } if (self.bottom_title) |title| { @@ -175,7 +175,7 @@ fn draw(self: *Box) void { self.width, self.title_fg, self.bg, - ); + ) catch {}; } } diff --git a/ly-ui/src/components/Label.zig b/ly-ui/src/components/Label.zig index 9874fcb..d54cb9c 100644 --- a/ly-ui/src/components/Label.zig +++ b/ly-ui/src/components/Label.zig @@ -117,7 +117,7 @@ fn draw(self: *Label) void { width, self.fg, self.bg, - ); + ) catch {}; return; } @@ -127,7 +127,7 @@ fn draw(self: *Label) void { self.component_pos.y, self.fg, self.bg, - ); + ) catch {}; } fn update(self: *Label, ctx: *anyopaque) !void { diff --git a/ly-ui/src/components/Text.zig b/ly-ui/src/components/Text.zig index 4fc35bf..0ca5312 100644 --- a/ly-ui/src/components/Text.zig +++ b/ly-ui/src/components/Text.zig @@ -131,14 +131,14 @@ pub fn handle(self: *Text, maybe_key: ?keyboard.Key) !void { } if (self.masked and self.maybe_mask == null) { - TerminalBuffer.setCursor( + try TerminalBuffer.setCursor( self.component_pos.x, self.component_pos.y, ); return; } - TerminalBuffer.setCursor( + try TerminalBuffer.setCursor( self.component_pos.x + (self.cursor - self.visible_start), self.component_pos.y, ); @@ -159,7 +159,7 @@ fn draw(self: *Text) void { length, self.fg, self.bg, - ); + ) catch {}; } return; } @@ -182,7 +182,7 @@ fn draw(self: *Text) void { self.component_pos.y, self.fg, self.bg, - ); + ) catch {}; } fn goLeft(ptr: *anyopaque) !bool { diff --git a/ly-ui/src/components/generic.zig b/ly-ui/src/components/generic.zig index 0a76c4f..572fe3f 100644 --- a/ly-ui/src/components/generic.zig +++ b/ly-ui/src/components/generic.zig @@ -105,8 +105,8 @@ pub fn CyclableLabel(comptime ItemType: type, comptime ChangeItemType: type) typ self.current = self.list.items.len - 1; } - pub fn handle(self: *Self, _: ?keyboard.Key) void { - TerminalBuffer.setCursor( + pub fn handle(self: *Self, _: ?keyboard.Key) !void { + try TerminalBuffer.setCursor( self.component_pos.x + self.cursor + 2, self.component_pos.y, ); @@ -119,11 +119,11 @@ pub fn CyclableLabel(comptime ItemType: type, comptime ChangeItemType: type) typ var left_arrow = Cell.init('<', self.fg, self.bg); var right_arrow = Cell.init('>', self.fg, self.bg); - left_arrow.put(self.component_pos.x, self.component_pos.y); + left_arrow.put(self.component_pos.x, self.component_pos.y) catch {}; right_arrow.put( self.component_pos.x + self.width - 1, self.component_pos.y, - ); + ) catch {}; const current_item = self.list.items[self.current]; const x = self.component_pos.x + 2; diff --git a/src/animations/Cascade.zig b/src/animations/Cascade.zig index 587cd37..c9b7769 100644 --- a/src/animations/Cascade.zig +++ b/src/animations/Cascade.zig @@ -71,14 +71,14 @@ fn draw(self: *Cascade) void { if ((self.buffer.random.int(u16) % 10) > 7) continue; - cell.?.put(x, y); + cell.?.put(x, y) catch {}; var space = Cell.init( ' ', cell_under.?.fg, cell_under.?.bg, ); - space.put(x, y - 1); + space.put(x, y - 1) catch {}; } } @@ -87,6 +87,6 @@ fn draw(self: *Cascade) void { self.current_auth_fails.* = 0; } - TerminalBuffer.presentBuffer(); + TerminalBuffer.presentBuffer() catch {}; } } diff --git a/src/animations/ColorMix.zig b/src/animations/ColorMix.zig index 49c6238..e9063a3 100644 --- a/src/animations/ColorMix.zig +++ b/src/animations/ColorMix.zig @@ -114,7 +114,7 @@ fn draw(self: *ColorMix) void { } const cell = self.palette[@as(usize, @trunc(math.floor(length(uv) * 5.0))) % palette_len]; - cell.put(x, y); + cell.put(x, y) catch {}; } } } diff --git a/src/animations/Doom.zig b/src/animations/Doom.zig index 9b0abae..504831a 100644 --- a/src/animations/Doom.zig +++ b/src/animations/Doom.zig @@ -129,13 +129,13 @@ fn draw(self: *Doom) void { // Send known fire levels to terminal buffer const from_cell = self.fire[level_buf_from]; const to_cell = self.fire[level_buf_to]; - from_cell.put(x, y); - to_cell.put(to_x, to_y); + from_cell.put(x, y) catch {}; + to_cell.put(to_x, to_y) catch {}; } // Draw bottom line (fire source) const src_cell = self.fire[STEPS]; - src_cell.put(x, self.terminal_buffer.height - 1); + src_cell.put(x, self.terminal_buffer.height - 1) catch {}; } } diff --git a/src/animations/DurFile.zig b/src/animations/DurFile.zig index ca3922c..95677f8 100644 --- a/src/animations/DurFile.zig +++ b/src/animations/DurFile.zig @@ -535,7 +535,7 @@ fn draw(self: *DurFile) void { const cell = Cell{ .ch = @intCast(codepoint), .fg = fg_color, .bg = bg_color }; - self.terminal_buffer.setCellBoundsChecked(cell_x, cell_y, cell); + self.terminal_buffer.setCellBoundsChecked(cell_x, cell_y, cell) catch {}; } } diff --git a/src/animations/GameOfLife.zig b/src/animations/GameOfLife.zig index c100c52..6e9a16c 100644 --- a/src/animations/GameOfLife.zig +++ b/src/animations/GameOfLife.zig @@ -146,7 +146,7 @@ fn draw(self: *GameOfLife) void { const row_offset = y * self.width; for (0..self.width) |x| { const cell = if (self.current_grid[row_offset + x]) alive_cell else self.dead_cell; - cell.put(x, y); + cell.put(x, y) catch {}; } } } diff --git a/src/animations/Matrix.zig b/src/animations/Matrix.zig index e7af489..3d43118 100644 --- a/src/animations/Matrix.zig +++ b/src/animations/Matrix.zig @@ -200,9 +200,9 @@ fn draw(self: *Matrix) void { .bg = self.terminal_buffer.bg, }; - cell.put(x, y - 1); + cell.put(x, y - 1) catch {}; // Fill background in between columns - self.default_cell.put(x + 1, y - 1); + self.default_cell.put(x + 1, y - 1) catch {}; } } } diff --git a/src/components/InfoLine.zig b/src/components/InfoLine.zig index 97a8a73..45b5da3 100644 --- a/src/components/InfoLine.zig +++ b/src/components/InfoLine.zig @@ -84,7 +84,7 @@ pub fn clearRendered(self: InfoLine, allocator: Allocator) !void { @memset(spaces, ' '); - TerminalBuffer.drawText( + try TerminalBuffer.drawText( spaces, self.label.component_pos.x + 2, self.label.component_pos.y, @@ -98,7 +98,7 @@ fn draw(self: *InfoLine) void { } fn handle(self: *InfoLine, maybe_key: ?keyboard.Key) !void { - self.label.handle(maybe_key); + try self.label.handle(maybe_key); } fn drawItem(label: *MessageLabel, message: Message, x: usize, y: usize, width: usize) void { @@ -114,5 +114,5 @@ fn drawItem(label: *MessageLabel, message: Message, x: usize, y: usize, width: u width, message.fg, message.bg, - ); + ) catch {}; } diff --git a/src/components/Session.zig b/src/components/Session.zig index 1e975c6..6cb252a 100644 --- a/src/components/Session.zig +++ b/src/components/Session.zig @@ -87,7 +87,7 @@ fn draw(self: *Session) void { } fn handle(self: *Session, maybe_key: ?keyboard.Key) !void { - self.label.handle(maybe_key); + try self.label.handle(maybe_key); } fn addedSession(env: Env, user_list: *UserList) void { @@ -119,5 +119,5 @@ fn drawItem(label: *EnvironmentLabel, env: Env, x: usize, y: usize, width: usize width, label.fg, label.bg, - ); + ) catch {}; } diff --git a/src/components/UserList.zig b/src/components/UserList.zig index c407173..9f01bc5 100644 --- a/src/components/UserList.zig +++ b/src/components/UserList.zig @@ -118,7 +118,7 @@ fn draw(self: *UserList) void { } fn handle(self: *UserList, maybe_key: ?keyboard.Key) !void { - self.label.handle(maybe_key); + try self.label.handle(maybe_key); } fn usernameChanged(user: User, maybe_session: ?*Session) void { @@ -143,5 +143,5 @@ fn drawItem(label: *UserLabel, user: User, x: usize, y: usize, width: usize) voi width, label.fg, label.bg, - ); + ) catch {}; } diff --git a/src/main.zig b/src/main.zig index a2a8512..0f6f1e0 100644 --- a/src/main.zig +++ b/src/main.zig @@ -56,12 +56,12 @@ fn signalHandler(sig: std.posix.SIG) callconv(.c) void { _ = std.c.waitpid(session_pid, &status, 0); } - TerminalBuffer.shutdown(); + TerminalBuffer.shutdown() catch {}; std.c.exit(@intCast(@intFromEnum(sig))); } fn ttyControlTransferSignalHandler(_: std.posix.SIG) callconv(.c) void { - TerminalBuffer.shutdown(); + TerminalBuffer.shutdown() catch {}; } const CustomBindLabel = struct { @@ -1484,7 +1484,7 @@ fn authenticate(ptr: *anyopaque) !bool { ); }; state.info_line.label.draw(); - TerminalBuffer.presentBuffer(); + try TerminalBuffer.presentBuffer(); return false; } @@ -1507,7 +1507,7 @@ fn authenticate(ptr: *anyopaque) !bool { ); }; state.info_line.label.draw(); - TerminalBuffer.presentBuffer(); + try TerminalBuffer.presentBuffer(); if (state.config.save) save_last_settings: { // It isn't worth cluttering the code with precise error @@ -1660,8 +1660,8 @@ fn authenticate(ptr: *anyopaque) !bool { } // Restore the cursor - TerminalBuffer.setCursor(0, 0); - TerminalBuffer.presentBuffer(); + try TerminalBuffer.setCursor(0, 0); + try TerminalBuffer.presentBuffer(); return false; } From 0cd8b2ebfc564427f7bb90c9e8e3dd672cec99cc Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 18 May 2026 19:46:28 +0200 Subject: [PATCH 27/77] README: Add section for testing config changes (closes #994) Signed-off-by: AnErrupTion --- readme.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.md b/readme.md index 78ebffc..5cbe81d 100644 --- a/readme.md +++ b/readme.md @@ -95,6 +95,9 @@ $ zig build run > [!IMPORTANT] > While you can run Ly in a terminal emulator as root, it is **not** recommended. If you want to test Ly, please enable its service (as described below) and reboot your machine. +> [!NOTE] +> You can, however, test your configuration file changes like that. Note that you must do Ctrl+C in order to exit Ly. + The next sections will explain how to use Ly with a variety of init systems. Detailed explanation is only given for systemd, but should be applicable for all. > [!NOTE] From f03aca037952e9be481caefc989f97545a5e345f Mon Sep 17 00:00:00 2001 From: Louis Pate Date: Wed, 20 May 2026 20:17:11 +0200 Subject: [PATCH 28/77] Be specific about zig version in readme (#996) ## What are the changes about? There have been quite a few issues about the required zig version which have appeared on codeberg recently. Largely these issues are opened (like mine, #995) because individuals attempt to build using development versions of zig and not the tagged releases. The lack of a locked version (only a minimum) creates these issues. Barring a locking mechanism, which I do not feel is my place to implement, we should be clear to newer developers in Zig that you need this specific version, not a development/master versioned release. This is WIP mainly because I feel that a version file would be a better solution than a README note, and I don't have enough zig experience or knowledge of this repo to make a guess at what is best for this scenario. ## What existing issue does this resolve? N/A ## Pre-requisites - [x] I have tested & confirmed the changes work locally - [x] I have run `zig fmt` throughout my changes Co-authored-by: Louis Pate Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/996 Reviewed-by: AnErrupTion --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 5cbe81d..79c3a63 100644 --- a/readme.md +++ b/readme.md @@ -14,7 +14,7 @@ Join us on Matrix over at [#ly-dm:matrix.org](https://matrix.to/#/#ly-dm:matrix. ## Dependencies - Compile-time: - - zig 0.16.x + - zig 0.16.x (you must use a __release version__ of zig; check that `zig version` does not have a `-dev*` suffix) - libc From 0cee1c039a3a8ecaeb2868f44e91b9c3baedfd76 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 22 May 2026 17:15:17 +0200 Subject: [PATCH 29/77] ly-kmsconvt: Remove usage of gone --seats argument Signed-off-by: AnErrupTion --- res/ly-kmsconvt@.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/ly-kmsconvt@.service b/res/ly-kmsconvt@.service index 80eb1da..6e50b8a 100644 --- a/res/ly-kmsconvt@.service +++ b/res/ly-kmsconvt@.service @@ -5,7 +5,7 @@ After=kmsconvt@%i.service Conflicts=kmsconvt@%i.service [Service] -ExecStart=$PREFIX_DIRECTORY/bin/kmscon --font-engine unifont --vt=%I --seats=seat0 --login -- $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME --use-kmscon-vt +ExecStart=$PREFIX_DIRECTORY/bin/kmscon --font-engine unifont --vt=%I --login -- $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME --use-kmscon-vt StandardInput=tty UtmpIdentifier=%I TTYPath=/dev/%I From 9d8ccf6709f61266ad8d181c13d922770b773f57 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sat, 23 May 2026 12:31:05 +0200 Subject: [PATCH 30/77] Fix termbox already being initialised when reclaiming Signed-off-by: AnErrupTion --- ly-ui/src/TerminalBuffer.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ly-ui/src/TerminalBuffer.zig b/ly-ui/src/TerminalBuffer.zig index d0b3e3d..7d115eb 100644 --- a/ly-ui/src/TerminalBuffer.zig +++ b/ly-ui/src/TerminalBuffer.zig @@ -411,7 +411,8 @@ pub fn setCellBoundsChecked(self: *TerminalBuffer, x: isize, y: isize, cell: Cel pub fn reclaim(self: TerminalBuffer) !void { if (self.termios) |termios| { // Take back control of the TTY - if (termbox.tb_init() != 0) return error.TermboxReinitFailed; + const err = termbox.tb_init(); + if (err != 0 and err != termbox.TB_ERR_INIT_ALREADY) return error.TermboxReinitFailed; if (self.full_color and termbox.tb_set_output_mode(termbox.TB_OUTPUT_TRUECOLOR) != 0) { return error.TermboxSetOutputModeFailed; From 0ac11065f4df9f6b9aedf112376be7e880b1a1d5 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sat, 30 May 2026 12:17:06 +0200 Subject: [PATCH 31/77] ly-kmsconvt: Set TERM=linux Signed-off-by: AnErrupTion --- res/ly-kmsconvt@.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/ly-kmsconvt@.service b/res/ly-kmsconvt@.service index 6e50b8a..85b0f05 100644 --- a/res/ly-kmsconvt@.service +++ b/res/ly-kmsconvt@.service @@ -5,7 +5,7 @@ After=kmsconvt@%i.service Conflicts=kmsconvt@%i.service [Service] -ExecStart=$PREFIX_DIRECTORY/bin/kmscon --font-engine unifont --vt=%I --login -- $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME --use-kmscon-vt +ExecStart=$PREFIX_DIRECTORY/bin/kmscon --term=linux --font-engine unifont --vt=%I --login -- $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME --use-kmscon-vt StandardInput=tty UtmpIdentifier=%I TTYPath=/dev/%I From 35be66e66fa333598ea6373293c737df238f2d55 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sat, 30 May 2026 12:17:25 +0200 Subject: [PATCH 32/77] termbox2: Log init errors Signed-off-by: AnErrupTion --- ly-ui/src/TerminalBuffer.zig | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ly-ui/src/TerminalBuffer.zig b/ly-ui/src/TerminalBuffer.zig index 7d115eb..9dfa1f3 100644 --- a/ly-ui/src/TerminalBuffer.zig +++ b/ly-ui/src/TerminalBuffer.zig @@ -103,10 +103,26 @@ pub fn init( random: Random, ) !TerminalBuffer { // Initialize termbox - if (termbox.tb_init() != 0) return error.TermboxInitFailed; + var err = termbox.tb_init(); + if (err != 0) { + try log_file.err( + io, + "tui", + "failed to initialise termbox2: {s}, term: {s}", + .{ termbox.tb_strerror(err), std.c.getenv("TERM").? }, + ); + return error.TermboxInitFailed; + } if (options.full_color) { - if (termbox.tb_set_output_mode(termbox.TB_OUTPUT_TRUECOLOR) != 0) { + err = termbox.tb_set_output_mode(termbox.TB_OUTPUT_TRUECOLOR); + if (err != 0) { + try log_file.err( + io, + "tui", + "failed to set termbox2 output mode to 24-bit color: {s}", + .{termbox.tb_strerror(err)}, + ); return error.TermboxSetOutputModeFailed; } try log_file.info( From ace79f76b5a832dfeffa294d2016ddac8fbb27b2 Mon Sep 17 00:00:00 2001 From: Wicin-134 Date: Sat, 6 Jun 2026 11:48:31 +0200 Subject: [PATCH 33/77] Overhaul language files (#997) - Added sr_Cyrl.ini as new Cyrillic variant for the Serbian Language - Added zh_TW.ini (Traditional Chinese) - Completed ALL missing keys in EVERY translation Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/997 Reviewed-by: AnErrupTion --- res/lang/ar.ini | 42 +++++++------- res/lang/cat.ini | 52 +++++++++--------- res/lang/cs.ini | 76 ++++++++++++------------- res/lang/de.ini | 44 +++++++-------- res/lang/eo.ini | 8 +-- res/lang/es.ini | 62 ++++++++++----------- res/lang/it.ini | 76 ++++++++++++------------- res/lang/ja_JP.ini | 44 +++++++-------- res/lang/ku.ini | 8 +-- res/lang/lv.ini | 24 ++++---- res/lang/pl.ini | 24 ++++---- res/lang/pt.ini | 76 ++++++++++++------------- res/lang/pt_BR.ini | 76 ++++++++++++------------- res/lang/ro.ini | 108 ++++++++++++++++++------------------ res/lang/ru.ini | 24 ++++---- res/lang/sr.ini | 128 +++++++++++++++++++++---------------------- res/lang/sr_Cyrl.ini | 82 +++++++++++++++++++++++++++ res/lang/sv.ini | 10 ++-- res/lang/tr.ini | 66 +++++++++++----------- res/lang/uk.ini | 76 ++++++++++++------------- res/lang/zh_CN.ini | 78 +++++++++++++------------- res/lang/zh_TW.ini | 82 +++++++++++++++++++++++++++ 22 files changed, 715 insertions(+), 551 deletions(-) create mode 100644 res/lang/sr_Cyrl.ini create mode 100644 res/lang/zh_TW.ini diff --git a/res/lang/ar.ini b/res/lang/ar.ini index d8cbecf..fd51b51 100644 --- a/res/lang/ar.ini +++ b/res/lang/ar.ini @@ -2,29 +2,29 @@ authenticating = جاري المصادقة... brightness_down = خفض السطوع brightness_up = رفع السطوع capslock = capslock - - - - +custom = مخصص +custom_info_err_output_long = الإخراج طويل جداً +custom_info_err_no_output = لا يوجد إخراج +custom_info_err_no_output_error = ، خطأ محتمل err_alloc = فشل في تخصيص الذاكرة - - +err_args = تعذر تحليل وسيطات سطر الأوامر +err_autologin_session = لم يتم العثور على جلسة تسجيل الدخول التلقائي err_bounds = out-of-bounds index err_brightness_change = فشل في تغيير سطوع الشاشة err_chdir = فشل في فتح مجلد المنزل - +err_clock_too_long = نص الساعة طويل جداً err_config = فشل في تفسير ملف الإعدادات - +err_crawl = فشل الزحف في أدلة الجلسة err_dgn_oob = رسالة سجل (Log) err_domain = اسم نطاق غير صالح err_empty_password = لا يُسمح بكلمة مرور فارغة err_envlist = فشل في جلب قائمة المتغيرات البيئية - - +err_get_active_tty = فشل الحصول على tty النشط +err_hibernate = فشل تنفيذ أمر الإسبات err_hostname = فشل في جلب اسم المضيف (Hostname) - - - +err_inactivity = فشل تنفيذ أمر عدم النشاط +err_lock_state = فشل الحصول على حالة القفل +err_log = فشل فتح ملف السجل err_mlock = فشل في تأمين ذاكرة كلمة المرور (mlock) err_null = مؤشر فارغ (Null pointer) err_numlock = فشل في ضبط Num Lock @@ -50,12 +50,12 @@ err_perm_group = فشل في تخفيض صلاحيات المجموعة (Group p err_perm_user = فشل في تخفيض صلاحيات المستخدم (User permissions) err_pwnam = فشل في جلب معلومات المستخدم err_sleep = فشل في تنفيذ أمر sleep - - - +err_start = فشل تنفيذ أمر البدء +err_battery = فشل تحميل حالة البطارية +err_switch_tty = فشل تبديل tty err_tty_ctrl = فشل في نقل تحكم الطرفية (TTY) - - +err_no_users = لم يتم العثور على مستخدمين +err_uid_range = فشل الحصول الديناميكي على نطاق uid err_user_gid = فشل في تعيين معرّف المجموعة (GID) للمستخدم err_user_init = فشل في تهيئة بيانات المستخدم err_user_uid = فشل في تعيين معرّف المستخدم (UID) @@ -63,11 +63,11 @@ err_xauth = فشل في تنفيذ أمر xauth err_xcb_conn = فشل في الاتصال بمكتبة XCB err_xsessions_dir = فشل في العثور على مجلد Xsessions err_xsessions_open = فشل في فتح مجلد Xsessions - +hibernate = إسبات insert = ادخال login = تسجيل الدخول logout = تم تسجيل خروجك -no_x11_support = تم تعطيل دعم x11 اثناء وقت الـ compile +no_x11_support = دعم x11 معطّل في وقت الترجمة normal = عادي numlock = numlock other = اخر @@ -76,7 +76,7 @@ restart = اعادة التشغيل shell = shell shutdown = ايقاف التشغيل sleep = وضع السكون - +toggle_password = إظهار/إخفاء كلمة المرور wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/cat.ini b/res/lang/cat.ini index 152cb96..3bf271b 100644 --- a/res/lang/cat.ini +++ b/res/lang/cat.ini @@ -2,29 +2,29 @@ authenticating = autenticant... brightness_down = abaixar brillantor brightness_up = apujar brillantor capslock = Bloq Majús - - - - +custom = personalitzat +custom_info_err_output_long = sortida massa llarga +custom_info_err_no_output = sense sortida +custom_info_err_no_output_error = , possible error err_alloc = assignació de memòria fallida - - +err_args = no s'han pogut analitzar els arguments de la línia d'ordres +err_autologin_session = no s'ha trobat la sessió d'inici de sessió automàtic err_bounds = índex fora de límits err_brightness_change = error en canviar la brillantor err_chdir = error en obrir la carpeta home - - - +err_clock_too_long = la cadena del rellotge és massa llarga +err_config = no s'ha pogut analitzar el fitxer de configuració +err_crawl = no s'han pogut explorar els directoris de sessió err_dgn_oob = missatge de registre err_domain = domini invàlid - +err_empty_password = no es permet la contrasenya buida err_envlist = error en obtenir l'envlist - - +err_get_active_tty = no s'ha pogut obtenir el tty actiu +err_hibernate = no s'ha pogut executar l'ordre d'hibernació err_hostname = error en obtenir el nom de l'amfitrió - - - +err_inactivity = no s'ha pogut executar l'ordre d'inactivitat +err_lock_state = no s'ha pogut obtenir l'estat de bloqueig +err_log = no s'ha pogut obrir el fitxer de registre err_mlock = error en bloquejar la memòria de clau err_null = punter nul err_numlock = error en establir el Bloq num @@ -49,13 +49,13 @@ err_perm_dir = error en canviar el directori actual err_perm_group = error en degradar els permisos de grup err_perm_user = error en degradar els permisos de l'usuari err_pwnam = error en obtenir la informació de l'usuari - - - - - - - +err_sleep = no s'ha pogut executar l'ordre de suspensió +err_start = no s'ha pogut executar l'ordre d'inici +err_battery = no s'ha pogut carregar l'estat de la bateria +err_switch_tty = no s'ha pogut canviar de tty +err_tty_ctrl = ha fallat la transferència del control tty +err_no_users = no s'han trobat usuaris +err_uid_range = no s'ha pogut obtenir dinàmicament el rang d'uid err_user_gid = error en establir el GID de l'usuari err_user_init = error en inicialitzar usuari err_user_uid = error en establir l'UID de l'usuari @@ -63,20 +63,20 @@ err_xauth = error en la comanda xauth err_xcb_conn = error en la connexió xcb err_xsessions_dir = error en trobar la carpeta de sessions err_xsessions_open = error en obrir la carpeta de sessions - +hibernate = hibernar insert = inserir login = iniciar sessió logout = sessió tancada -no_x11_support = el suport per x11 ha estat desactivat en la compilació +no_x11_support = suport x11 desactivat en temps de compilació normal = normal numlock = Bloq Num - +other = altres password = Clau restart = reiniciar shell = shell shutdown = aturar sleep = suspendre - +toggle_password = mostrar/amagar contrasenya wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/cs.ini b/res/lang/cs.ini index da0bce2..4f9456c 100644 --- a/res/lang/cs.ini +++ b/res/lang/cs.ini @@ -1,33 +1,33 @@ - - - +authenticating = ověřování... +brightness_down = snížit jas +brightness_up = zvýšit jas capslock = capslock - - - - +custom = vlastní +custom_info_err_output_long = výstup je příliš dlouhý +custom_info_err_no_output = žádný výstup +custom_info_err_no_output_error = , možná chyba err_alloc = alokace paměti selhala - - +err_args = nelze analyzovat argumenty příkazového řádku +err_autologin_session = relace automatického přihlášení nebyla nalezena err_bounds = index je mimo hranice pole - +err_brightness_change = nepodařilo se změnit jas err_chdir = nelze otevřít domovský adresář - - - +err_clock_too_long = řetězec hodin je příliš dlouhý +err_config = nelze analyzovat konfigurační soubor +err_crawl = nepodařilo se prohledat adresáře relací err_dgn_oob = zpráva protokolu err_domain = neplatná doména - - - - +err_empty_password = prázdné heslo není povoleno +err_envlist = nepodařilo se získat seznam proměnných prostředí +err_get_active_tty = nepodařilo se získat aktivní tty +err_hibernate = nepodařilo se spustit příkaz hibernace err_hostname = nelze získat název hostitele - - - +err_inactivity = nepodařilo se spustit příkaz nečinnosti +err_lock_state = nepodařilo se získat stav zámku +err_log = nepodařilo se otevřít soubor protokolu err_mlock = uzamčení paměti hesel selhalo err_null = nulový ukazatel - +err_numlock = nepodařilo se nastavit numlock err_pam = pam transakce selhala err_pam_abort = pam transakce přerušena err_pam_acct_expired = platnost účtu vypršela @@ -49,34 +49,34 @@ err_perm_dir = nepodařilo se změnit adresář err_perm_group = nepodařilo se snížit skupinová oprávnění err_perm_user = nepodařilo se snížit uživatelská oprávnění err_pwnam = nelze získat informace o uživateli - - - - - - - +err_sleep = nepodařilo se spustit příkaz spánku +err_start = nepodařilo se spustit příkaz spuštění +err_battery = nepodařilo se načíst stav baterie +err_switch_tty = nepodařilo se přepnout tty +err_tty_ctrl = přenos řízení tty selhal +err_no_users = nebyli nalezeni žádní uživatelé +err_uid_range = nepodařilo se dynamicky získat rozsah uid err_user_gid = nastavení GID uživatele selhalo err_user_init = inicializace uživatele selhala err_user_uid = nastavení UID uživateli selhalo - - +err_xauth = příkaz xauth selhal +err_xcb_conn = připojení xcb selhalo err_xsessions_dir = nepodařilo se najít složku relací err_xsessions_open = nepodařilo se otevřít složku relací - - +hibernate = hibernace +insert = vložit login = uživatel logout = odhlášen - - +no_x11_support = podpora x11 zakázána při kompilaci +normal = normální numlock = numlock - +other = jiné password = heslo restart = restartovat shell = příkazový řádek shutdown = vypnout - - +sleep = uspat +toggle_password = zobrazit/skrýt heslo wayland = wayland - +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/de.ini b/res/lang/de.ini index f869dcb..ca3a0ef 100644 --- a/res/lang/de.ini +++ b/res/lang/de.ini @@ -2,29 +2,29 @@ authenticating = authentifizieren... brightness_down = Helligkeit- brightness_up = Helligkeit+ capslock = Feststelltaste - - - - +custom = benutzerdefiniert +custom_info_err_output_long = Ausgabe zu lang +custom_info_err_no_output = keine Ausgabe +custom_info_err_no_output_error = , möglicher Fehler err_alloc = Speicherzuweisung fehlgeschlagen - - +err_args = Kommandozeilenargumente konnten nicht verarbeitet werden +err_autologin_session = Autologin-Sitzung nicht gefunden err_bounds = Index ausserhalb des Bereichs err_brightness_change = Helligkeitsänderung fehlgeschlagen err_chdir = Fehler beim Oeffnen des Home-Ordners - +err_clock_too_long = Uhrzeitzeichenkette zu lang err_config = Fehler beim Verarbeiten der Konfigurationsdatei - +err_crawl = Sitzungsverzeichnisse konnten nicht durchsucht werden err_dgn_oob = Diagnose-Nachricht err_domain = Ungueltige Domain err_empty_password = Leeres Passwort nicht zugelassen err_envlist = Fehler beim Abrufen der Umgebungs-Variablen - - +err_get_active_tty = Aktives tty konnte nicht ermittelt werden +err_hibernate = Ruhezustand-Befehl konnte nicht ausgeführt werden err_hostname = Abrufen des Hostnames fehlgeschlagen - - - +err_inactivity = Inaktivitätsbefehl konnte nicht ausgeführt werden +err_lock_state = Sperrstatus konnte nicht ermittelt werden +err_log = Protokolldatei konnte nicht geöffnet werden err_mlock = Sperren des Passwortspeichers fehlgeschlagen err_null = Null Pointer err_numlock = Numlock konnte nicht aktiviert werden @@ -50,12 +50,12 @@ err_perm_group = Fehler beim Heruntersetzen der Gruppenberechtigungen err_perm_user = Fehler beim Heruntersetzen der Nutzerberechtigungen err_pwnam = Abrufen der Benutzerinformationen fehlgeschlagen err_sleep = Sleep-Befehl fehlgeschlagen - - - +err_start = Startbefehl konnte nicht ausgeführt werden +err_battery = Akkustand konnte nicht geladen werden +err_switch_tty = tty konnte nicht gewechselt werden err_tty_ctrl = Fehler bei der TTY-Uebergabe - - +err_no_users = Keine Benutzer gefunden +err_uid_range = uid-Bereich konnte nicht dynamisch ermittelt werden err_user_gid = Fehler beim Setzen der Gruppen-ID err_user_init = Nutzer-Initialisierung fehlgeschlagen err_user_uid = Setzen der Benutzer-ID fehlgeschlagen @@ -63,11 +63,11 @@ err_xauth = Xauth-Befehl fehlgeschlagen err_xcb_conn = xcb-Verbindung fehlgeschlagen err_xsessions_dir = Fehler beim Finden des Sitzungsordners err_xsessions_open = Fehler beim Oeffnen des Sitzungsordners - +hibernate = Ruhezustand insert = Einfügen login = Nutzer logout = Abmelden -no_x11_support = X11-Support bei Kompilierung deaktiviert +no_x11_support = x11-Unterstützung zur Kompilierzeit deaktiviert normal = Normal numlock = Numlock other = Andere @@ -76,7 +76,7 @@ restart = Neustarten shell = Shell shutdown = Herunterfahren sleep = Sleep - +toggle_password = Passwort anzeigen/verbergen wayland = wayland -x11 = X11 +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/eo.ini b/res/lang/eo.ini index 8463432..c8cbb96 100644 --- a/res/lang/eo.ini +++ b/res/lang/eo.ini @@ -3,9 +3,9 @@ brightness_down = malpliigi helecon brightness_up = pliigi helecon capslock = majuskla baskulo custom = propra - - - +custom_info_err_output_long = eligo tro longa +custom_info_err_no_output = neniu eligo +custom_info_err_no_output_error = , ebla eraro err_alloc = malsukcesis memorasignon err_args = ne povas analizi argumentojn de komanda linio err_autologin_session = aŭtomatan ensalutan seancon ne trovis @@ -76,7 +76,7 @@ restart = restartigi shell = ŝelo shutdown = malŝalti sleep = memordormi - +toggle_password = montri/kaŝi pasvorton wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/es.ini b/res/lang/es.ini index 38c2b9d..f587fe7 100644 --- a/res/lang/es.ini +++ b/res/lang/es.ini @@ -2,32 +2,32 @@ authenticating = autenticando... brightness_down = bajar brillo brightness_up = subir brillo capslock = Bloq Mayús - - - - +custom = personalizado +custom_info_err_output_long = salida demasiado larga +custom_info_err_no_output = sin salida +custom_info_err_no_output_error = , posible error err_alloc = asignación de memoria fallida - - +err_args = no se pudieron analizar los argumentos de la línea de comandos +err_autologin_session = no se encontró la sesión de inicio de sesión automático err_bounds = índice fuera de límites - +err_brightness_change = no se pudo cambiar el brillo err_chdir = error al abrir la carpeta home - - - +err_clock_too_long = la cadena del reloj es demasiado larga +err_config = no se pudo analizar el archivo de configuración +err_crawl = no se pudieron explorar los directorios de sesión err_dgn_oob = mensaje de registro err_domain = dominio inválido - - - - +err_empty_password = no se permite contraseña vacía +err_envlist = no se pudo obtener la lista de variables de entorno +err_get_active_tty = no se pudo obtener el tty activo +err_hibernate = no se pudo ejecutar el comando de hibernación err_hostname = error al obtener el nombre de host - - - +err_inactivity = no se pudo ejecutar el comando de inactividad +err_lock_state = no se pudo obtener el estado de bloqueo +err_log = no se pudo abrir el archivo de registro err_mlock = error al bloquear la contraseña de memoria err_null = puntero nulo - +err_numlock = no se pudo configurar numlock err_pam = error en la transacción pam err_pam_abort = transacción pam abortada err_pam_acct_expired = cuenta expirada @@ -49,25 +49,25 @@ err_perm_dir = error al cambiar el directorio actual err_perm_group = error al degradar los permisos del grupo err_perm_user = error al degradar los permisos del usuario err_pwnam = error al obtener la información del usuario - - - - - - - +err_sleep = no se pudo ejecutar el comando de suspensión +err_start = no se pudo ejecutar el comando de inicio +err_battery = no se pudo cargar el estado de la batería +err_switch_tty = no se pudo cambiar de tty +err_tty_ctrl = falló la transferencia de control tty +err_no_users = no se encontraron usuarios +err_uid_range = no se pudo obtener dinámicamente el rango de uid err_user_gid = error al establecer el GID del usuario err_user_init = error al inicializar usuario err_user_uid = error al establecer el UID del usuario - - +err_xauth = falló el comando xauth +err_xcb_conn = falló la conexión xcb err_xsessions_dir = error al buscar la carpeta de sesiones err_xsessions_open = error al abrir la carpeta de sesiones - +hibernate = hibernar insert = insertar login = usuario logout = cerrar sesión -no_x11_support = soporte para x11 deshabilitado en tiempo de compilación +no_x11_support = soporte x11 desactivado en tiempo de compilación normal = normal numlock = Bloq Num other = otro @@ -76,7 +76,7 @@ restart = reiniciar shell = shell shutdown = apagar sleep = suspender - +toggle_password = mostrar/ocultar contraseña wayland = wayland - +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/it.ini b/res/lang/it.ini index e8af2a6..9c9679d 100644 --- a/res/lang/it.ini +++ b/res/lang/it.ini @@ -1,33 +1,33 @@ - - - +authenticating = autenticazione in corso... +brightness_down = diminuisci luminosità +brightness_up = aumenta luminosità capslock = capslock - - - - +custom = personalizzato +custom_info_err_output_long = output troppo lungo +custom_info_err_no_output = nessun output +custom_info_err_no_output_error = , possibile errore err_alloc = impossibile allocare memoria - - +err_args = impossibile analizzare gli argomenti della riga di comando +err_autologin_session = sessione di accesso automatico non trovata err_bounds = indice fuori limite - +err_brightness_change = impossibile modificare la luminosità err_chdir = impossibile aprire home directory - - - +err_clock_too_long = stringa dell'orologio troppo lunga +err_config = impossibile analizzare il file di configurazione +err_crawl = impossibile esplorare le directory delle sessioni err_dgn_oob = messaggio log err_domain = dominio non valido - - - - +err_empty_password = password vuota non consentita +err_envlist = impossibile ottenere la lista delle variabili d'ambiente +err_get_active_tty = impossibile ottenere il tty attivo +err_hibernate = impossibile eseguire il comando di ibernazione err_hostname = impossibile ottenere hostname - - - +err_inactivity = impossibile eseguire il comando di inattività +err_lock_state = impossibile ottenere lo stato di blocco +err_log = impossibile aprire il file di log err_mlock = impossibile ottenere lock per la password in memoria err_null = puntatore nullo - +err_numlock = impossibile impostare il numlock err_pam = transazione PAM fallita err_pam_abort = transazione PAM interrotta err_pam_acct_expired = account scaduto @@ -49,34 +49,34 @@ err_perm_dir = impossibile cambiare directory corrente err_perm_group = impossibile ridurre permessi gruppo err_perm_user = impossibile ridurre permessi utente err_pwnam = impossibile ottenere dati utente - - - - - - - +err_sleep = impossibile eseguire il comando di sospensione +err_start = impossibile eseguire il comando di avvio +err_battery = impossibile caricare lo stato della batteria +err_switch_tty = impossibile cambiare tty +err_tty_ctrl = trasferimento del controllo tty fallito +err_no_users = nessun utente trovato +err_uid_range = impossibile ottenere dinamicamente l'intervallo uid err_user_gid = impossibile impostare GID utente err_user_init = impossibile inizializzare utente err_user_uid = impossible impostare UID utente - - +err_xauth = comando xauth fallito +err_xcb_conn = connessione xcb fallita err_xsessions_dir = impossibile localizzare cartella sessioni err_xsessions_open = impossibile aprire cartella sessioni - - +hibernate = ibernazione +insert = inserisci login = username logout = scollegato - - +no_x11_support = supporto x11 disabilitato in fase di compilazione +normal = normale numlock = numlock - +other = altro password = password restart = riavvio shell = shell shutdown = arresto - - +sleep = sospendi +toggle_password = mostra/nascondi password wayland = wayland - +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/ja_JP.ini b/res/lang/ja_JP.ini index 309ff39..a14feab 100644 --- a/res/lang/ja_JP.ini +++ b/res/lang/ja_JP.ini @@ -2,29 +2,29 @@ authenticating = 認証中... brightness_down = 明るさを下げる brightness_up = 明るさを上げる capslock = CapsLock - - - - +custom = カスタム +custom_info_err_output_long = 出力が長すぎます +custom_info_err_no_output = 出力なし +custom_info_err_no_output_error = 、エラーの可能性あり err_alloc = メモリ割り当て失敗 - - +err_args = コマンドライン引数を解析できません +err_autologin_session = 自動ログインセッションが見つかりません err_bounds = 境界外インデックス err_brightness_change = 明るさの変更に失敗しました err_chdir = ホームフォルダを開けませんでした - +err_clock_too_long = 時計の文字列が長すぎます err_config = 設定ファイルを解析できません - +err_crawl = セッションディレクトリのクロールに失敗しました err_dgn_oob = ログメッセージ err_domain = 無効なドメイン err_empty_password = 空のパスワードは許可されていません err_envlist = 環境変数リストの取得に失敗しました - - +err_get_active_tty = アクティブなttyの取得に失敗しました +err_hibernate = 休止状態コマンドの実行に失敗しました err_hostname = ホスト名の取得に失敗しました - - - +err_inactivity = 無操作コマンドの実行に失敗しました +err_lock_state = ロック状態の取得に失敗しました +err_log = ログファイルを開けませんでした err_mlock = パスワードメモリのロックに失敗しました err_null = ヌルポインタ err_numlock = NumLockの設定に失敗しました @@ -50,12 +50,12 @@ err_perm_group = グループ権限のダウングレードに失敗しました err_perm_user = ユーザー権限のダウングレードに失敗しました err_pwnam = ユーザー情報の取得に失敗しました err_sleep = スリープコマンドの実行に失敗しました - - - +err_start = 起動コマンドの実行に失敗しました +err_battery = バッテリー状態の読み込みに失敗しました +err_switch_tty = ttyの切り替えに失敗しました err_tty_ctrl = TTY制御の転送に失敗しました - - +err_no_users = ユーザーが見つかりません +err_uid_range = uidの範囲を動的に取得できませんでした err_user_gid = ユーザーGIDの設定に失敗しました err_user_init = ユーザーの初期化に失敗しました err_user_uid = ユーザーUIDの設定に失敗しました @@ -63,11 +63,11 @@ err_xauth = xauthコマンドの実行に失敗しました err_xcb_conn = XCB接続に失敗しました err_xsessions_dir = セッションフォルダが見つかりませんでした err_xsessions_open = セッションフォルダを開けませんでした - +hibernate = 休止状態 insert = 挿入 login = ログイン logout = ログアウト済み -no_x11_support = X11サポートはコンパイル時に無効化されています +no_x11_support = x11サポートはコンパイル時に無効化されています normal = 通常 numlock = NumLock other = その他 @@ -76,7 +76,7 @@ restart = 再起動 shell = シェル shutdown = シャットダウン sleep = スリープ - +toggle_password = パスワードの表示/非表示 wayland = Wayland -x11 = X11 +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/ku.ini b/res/lang/ku.ini index 5775274..0c39030 100644 --- a/res/lang/ku.ini +++ b/res/lang/ku.ini @@ -3,9 +3,9 @@ brightness_down = ronahiyê kêm bike brightness_up = ronahiyê bilind bike capslock = tîpên girdek (capslock) custom = kesane - - - +custom_info_err_output_long = encam pir dirêj e +custom_info_err_no_output = encam tune +custom_info_err_no_output_error = , xeletiya mimkun err_alloc = veqetandina bîrê têk çû err_args = argumanên rêzika fermanê nehatin analîzkirin err_autologin_session = danişîna têketina xweber nehate dîtin @@ -76,7 +76,7 @@ restart = ji nû ve bide destpêkirin shell = shell shutdown = vemirîne sleep = têxîne xewê - +toggle_password = şîfre nîşan bide/veşêre wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/lv.ini b/res/lang/lv.ini index a1a3fa9..8f54d89 100644 --- a/res/lang/lv.ini +++ b/res/lang/lv.ini @@ -3,26 +3,26 @@ brightness_down = samazināt spilgtumu brightness_up = palielināt spilgtumu capslock = caps lock custom = pielāgots - - - +custom_info_err_output_long = izvade pārāk gara +custom_info_err_no_output = nav izvades +custom_info_err_no_output_error = , iespējama kļūda err_alloc = neizdevās atmiņas piešķiršana - - +err_args = nevar parsēt komandrindas argumentus +err_autologin_session = automātiskās pieteikšanās sesija nav atrasta err_bounds = indekss ārpus robežām err_brightness_change = neizdevās mainīt spilgtumu err_chdir = neizdevās atvērt mājas mapi err_clock_too_long = pulksteņa virkne pārāk gara err_config = neizdevās parsēt konfigurācijas failu - +err_crawl = neizdevās pārlūkot sesiju direktorijus err_dgn_oob = žurnāla ziņojums err_domain = nederīgs domēns err_empty_password = tukša parole nav atļauta err_envlist = neizdevās iegūt vides mainīgo sarakstu err_get_active_tty = neizdevās iegūt aktīvo tty - +err_hibernate = neizdevās izpildīt hibernācijas komandu err_hostname = neizdevās iegūt hostname - +err_inactivity = neizdevās izpildīt neaktivitātes komandu err_lock_state = neizdevās iegūt bloķēšanas stāvokli err_log = neizdevās atvērt žurnāla failu err_mlock = neizdevās bloķēt paroles atmiņu @@ -50,12 +50,12 @@ err_perm_group = neizdevās pazemināt grupas atļaujas err_perm_user = neizdevās pazemināt lietotāja atļaujas err_pwnam = neizdevās iegūt lietotāja informāciju err_sleep = neizdevās izpildīt miega komandu - +err_start = neizdevās izpildīt startēšanas komandu err_battery = neizdevās ielādēt akumulatora stāvokli err_switch_tty = neizdevās pārslēgt tty err_tty_ctrl = tty vadības nodošana neizdevās err_no_users = lietotāji nav atrasti - +err_uid_range = neizdevās dinamiski iegūt uid diapazonu err_user_gid = neizdevās iestatīt lietotāja GID err_user_init = neizdevās inicializēt lietotāju err_user_uid = neizdevās iestatīt lietotāja UID @@ -63,7 +63,7 @@ err_xauth = xauth komanda neizdevās err_xcb_conn = xcb savienojums neizdevās err_xsessions_dir = neizdevās atrast sesiju mapi err_xsessions_open = neizdevās atvērt sesiju mapi - +hibernate = hibernācija insert = ievietot login = lietotājs logout = iziet @@ -76,7 +76,7 @@ restart = restartēt shell = terminālis shutdown = izslēgt sleep = snauda - +toggle_password = rādīt/slēpt paroli wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/pl.ini b/res/lang/pl.ini index 4c521e4..536680d 100644 --- a/res/lang/pl.ini +++ b/res/lang/pl.ini @@ -3,26 +3,26 @@ brightness_down = zmniejsz jasność brightness_up = zwiększ jasność capslock = capslock custom = własny - - - +custom_info_err_output_long = wyjście zbyt długie +custom_info_err_no_output = brak wyjścia +custom_info_err_no_output_error = , możliwy błąd err_alloc = nieudana alokacja pamięci - +err_args = nie można przetworzyć argumentów wiersza poleceń err_autologin_session = nie znaleziono sesji autologowania err_bounds = indeks poza zakresem err_brightness_change = nie udało się zmienić jasności err_chdir = nie udało się otworzyć folderu domowego err_clock_too_long = ciąg znaków zegara jest za długi err_config = nie można przetworzyć pliku konfiguracyjnego - +err_crawl = nie udało się przeszukać katalogów sesji err_dgn_oob = wiadomość loga err_domain = niepoprawna domena err_empty_password = puste hasło jest niedozwolone err_envlist = nie udało się pobrać listy zmiennych środowiskowych err_get_active_tty = nie udało się uzyskać aktywnego tty - +err_hibernate = nie udało się wykonać polecenia hibernacji err_hostname = nie udało się uzyskać nazwy hosta - +err_inactivity = nie udało się wykonać polecenia nieaktywności err_lock_state = nie udało się uzyskać stanu blokady err_log = nie udało się otworzyć pliku logu err_mlock = nie udało się zablokować pamięci haseł @@ -50,12 +50,12 @@ err_perm_group = nie udało się obniżyć uprawnień grupy err_perm_user = nie udało się obniżyć uprawnień użytkownika err_pwnam = nie udało się uzyskać informacji o użytkowniku err_sleep = nie udało się wykonać polecenia sleep - +err_start = nie udało się wykonać polecenia startowego err_battery = nie udało się sprawdzić statusu baterii err_switch_tty = nie można przełączyć tty err_tty_ctrl = nie udało się przekazać kontroli tty err_no_users = nie znaleziono żadnego użytkownika - +err_uid_range = nie udało się dynamicznie pobrać zakresu uid err_user_gid = nie udało się ustawić GID użytkownika err_user_init = nie udało się zainicjalizować użytkownika err_user_uid = nie udało się ustawić UID użytkownika @@ -63,11 +63,11 @@ err_xauth = polecenie xauth nie powiodło się err_xcb_conn = połączenie xcb nie powiodło się err_xsessions_dir = nie udało się znaleźć folderu sesji err_xsessions_open = nie udało się otworzyć folderu sesji - +hibernate = hibernuj insert = wstaw login = login logout = wylogowano -no_x11_support = wsparcie X11 wyłączone podczas kompilacji +no_x11_support = obsługa x11 wyłączona podczas kompilacji normal = normalny numlock = numlock other = inny @@ -76,7 +76,7 @@ restart = uruchom ponownie shell = powłoka shutdown = wyłącz sleep = uśpij - +toggle_password = Pokaż/ukryj hasło wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/pt.ini b/res/lang/pt.ini index 0b13276..204a9f1 100644 --- a/res/lang/pt.ini +++ b/res/lang/pt.ini @@ -1,33 +1,33 @@ - - - +authenticating = a autenticar... +brightness_down = diminuir brilho +brightness_up = aumentar brilho capslock = capslock - - - - +custom = personalizado +custom_info_err_output_long = saída demasiado longa +custom_info_err_no_output = sem saída +custom_info_err_no_output_error = , possível erro err_alloc = erro na atribuição de memória - - +err_args = não foi possível analisar os argumentos da linha de comandos +err_autologin_session = sessão de início de sessão automático não encontrada err_bounds = índice fora de limites - +err_brightness_change = não foi possível alterar o brilho err_chdir = erro ao abrir a pasta home - - - +err_clock_too_long = a cadeia de caracteres do relógio é demasiado longa +err_config = não foi possível analisar o ficheiro de configuração +err_crawl = não foi possível explorar os diretórios de sessão err_dgn_oob = mensagem de registo err_domain = domínio inválido - - - - +err_empty_password = palavra-passe vazia não é permitida +err_envlist = não foi possível obter a lista de variáveis de ambiente +err_get_active_tty = não foi possível obter o tty ativo +err_hibernate = não foi possível executar o comando de hibernação err_hostname = erro ao obter o nome do host - - - +err_inactivity = não foi possível executar o comando de inatividade +err_lock_state = não foi possível obter o estado de bloqueio +err_log = não foi possível abrir o ficheiro de registo err_mlock = erro de bloqueio de memória err_null = ponteiro nulo - +err_numlock = não foi possível definir o numlock err_pam = erro na transação pam err_pam_abort = transação pam abortada err_pam_acct_expired = conta expirada @@ -49,34 +49,34 @@ err_perm_dir = erro ao alterar o diretório atual err_perm_group = erro ao reduzir as permissões do grupo err_perm_user = erro ao reduzir as permissões do utilizador err_pwnam = erro ao obter informação do utilizador - - - - - - - +err_sleep = não foi possível executar o comando de suspensão +err_start = não foi possível executar o comando de início +err_battery = não foi possível carregar o estado da bateria +err_switch_tty = não foi possível mudar de tty +err_tty_ctrl = falhou a transferência de controlo do tty +err_no_users = nenhum utilizador encontrado +err_uid_range = não foi possível obter dinamicamente o intervalo de uid err_user_gid = erro ao definir o GID do utilizador err_user_init = erro ao iniciar o utilizador err_user_uid = erro ao definir o UID do utilizador - - +err_xauth = o comando xauth falhou +err_xcb_conn = a ligação xcb falhou err_xsessions_dir = erro ao localizar a pasta das sessões err_xsessions_open = erro ao abrir a pasta das sessões - - +hibernate = hibernar +insert = inserir login = iniciar sessão logout = terminar sessão - - +no_x11_support = suporte a x11 desativado em tempo de compilação +normal = normal numlock = numlock - +other = outro password = palavra-passe restart = reiniciar shell = shell shutdown = encerrar - - +sleep = suspender +toggle_password = mostrar/ocultar palavra-passe wayland = wayland - +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/pt_BR.ini b/res/lang/pt_BR.ini index ca96a3e..1ccc4c4 100644 --- a/res/lang/pt_BR.ini +++ b/res/lang/pt_BR.ini @@ -1,33 +1,33 @@ - - - +authenticating = autenticando... +brightness_down = diminuir brilho +brightness_up = aumentar brilho capslock = caixa alta - - - - +custom = personalizado +custom_info_err_output_long = saída muito longa +custom_info_err_no_output = sem saída +custom_info_err_no_output_error = , possível erro err_alloc = alocação de memória malsucedida - - +err_args = não foi possível analisar os argumentos da linha de comando +err_autologin_session = sessão de login automático não encontrada err_bounds = índice fora de limites - +err_brightness_change = não foi possível alterar o brilho err_chdir = não foi possível abrir o diretório home - - - +err_clock_too_long = a string do relógio é muito longa +err_config = não foi possível analisar o arquivo de configuração +err_crawl = não foi possível explorar os diretórios de sessão err_dgn_oob = mensagem de log err_domain = domínio inválido - - - - +err_empty_password = senha vazia não é permitida +err_envlist = não foi possível obter a lista de variáveis de ambiente +err_get_active_tty = não foi possível obter o tty ativo +err_hibernate = não foi possível executar o comando de hibernação err_hostname = não foi possível obter o nome do host - - - +err_inactivity = não foi possível executar o comando de inatividade +err_lock_state = não foi possível obter o estado de bloqueio +err_log = não foi possível abrir o arquivo de log err_mlock = bloqueio da memória de senha malsucedido err_null = ponteiro nulo - +err_numlock = não foi possível definir o numlock err_pam = transação pam malsucedida err_pam_abort = transação pam abortada err_pam_acct_expired = conta expirada @@ -49,34 +49,34 @@ err_perm_dir = não foi possível alterar o diretório atual err_perm_group = não foi possível reduzir as permissões de grupo err_perm_user = não foi possível reduzir as permissões de usuário err_pwnam = não foi possível obter informações do usuário - - - - - - - +err_sleep = não foi possível executar o comando de suspensão +err_start = não foi possível executar o comando de início +err_battery = não foi possível carregar o status da bateria +err_switch_tty = não foi possível mudar de tty +err_tty_ctrl = falhou a transferência de controle do tty +err_no_users = nenhum usuário encontrado +err_uid_range = não foi possível obter dinamicamente o intervalo de uid err_user_gid = não foi possível definir o GID do usuário err_user_init = não foi possível iniciar o usuário err_user_uid = não foi possível definir o UID do usuário - - +err_xauth = o comando xauth falhou +err_xcb_conn = a conexão xcb falhou err_xsessions_dir = não foi possível encontrar a pasta das sessões err_xsessions_open = não foi possível abrir a pasta das sessões - - +hibernate = hibernar +insert = inserir login = conectar logout = desconectado - - +no_x11_support = suporte a x11 desativado em tempo de compilação +normal = normal numlock = numlock - +other = outro password = senha restart = reiniciar shell = shell shutdown = desligar - - +sleep = suspender +toggle_password = mostrar/ocultar senha wayland = wayland - +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/ro.ini b/res/lang/ro.ini index 0bf92f2..3b771a8 100644 --- a/res/lang/ro.ini +++ b/res/lang/ro.ini @@ -1,34 +1,34 @@ - - - +authenticating = autentificare... +brightness_down = scade luminozitatea +brightness_up = crește luminozitatea capslock = capslock - - - - - - - - - - - - - - - - - - - - - - - - - - - +custom = personalizat +custom_info_err_output_long = ieșire prea lungă +custom_info_err_no_output = fără ieșire +custom_info_err_no_output_error = , posibil eroare +err_alloc = alocare de memorie eșuată +err_args = imposibil de analizat argumentele liniei de comandă +err_autologin_session = sesiunea de autentificare automată nu a fost găsită +err_bounds = index în afara limitelor +err_brightness_change = imposibil de schimbat luminozitatea +err_chdir = imposibil de deschis folderul de acasă +err_clock_too_long = șirul de ceas este prea lung +err_config = imposibil de analizat fișierul de configurare +err_crawl = imposibil de explorat directoarele de sesiune +err_dgn_oob = mesaj jurnal +err_domain = domeniu invalid +err_empty_password = parola goală nu este permisă +err_envlist = imposibil de obținut lista de variabile de mediu +err_get_active_tty = imposibil de obținut tty-ul activ +err_hibernate = imposibil de executat comanda de hibernare +err_hostname = imposibil de obținut numele gazdei +err_inactivity = imposibil de executat comanda de inactivitate +err_lock_state = imposibil de obținut starea de blocare +err_log = imposibil de deschis fișierul jurnal +err_mlock = imposibil de blocat memoria parolei +err_null = pointer nul +err_numlock = imposibil de setat numlock +err_pam = tranzacție pam eșuată err_pam_abort = tranzacţie pam anulată err_pam_acct_expired = cont expirat err_pam_auth = eroare de autentificare @@ -44,39 +44,39 @@ err_pam_perm_denied = acces interzis err_pam_session = eroare de sesiune err_pam_sys = eroare de sistem err_pam_user_unknown = utilizator necunoscut - +err_path = imposibil de setat calea err_perm_dir = nu s-a putut schimba dosarul (folder-ul) curent err_perm_group = nu s-a putut face downgrade permisiunilor de grup err_perm_user = nu s-a putut face downgrade permisiunilor de utilizator - - - - - - - - - - - - - - - - - +err_pwnam = imposibil de obținut informații despre utilizator +err_sleep = imposibil de executat comanda de repaus +err_start = imposibil de executat comanda de pornire +err_battery = imposibil de încărcat starea bateriei +err_switch_tty = imposibil de comutat tty +err_tty_ctrl = transferul controlului tty a eșuat +err_no_users = niciun utilizator găsit +err_uid_range = imposibil de obținut dinamic intervalul uid +err_user_gid = imposibil de setat GID-ul utilizatorului +err_user_init = imposibil de inițializa utilizatorul +err_user_uid = imposibil de setat UID-ul utilizatorului +err_xauth = comanda xauth a eșuat +err_xcb_conn = conexiunea xcb a eșuat +err_xsessions_dir = imposibil de găsit folderul de sesiuni +err_xsessions_open = imposibil de deschis folderul de sesiuni +hibernate = hibernare +insert = inserare login = utilizator logout = opreşte sesiunea - - +no_x11_support = suportul x11 dezactivat la compilare +normal = normal numlock = numlock - +other = altul password = parolă restart = resetează shell = shell shutdown = opreşte sistemul - - +sleep = repaus +toggle_password = afișare/ascundere parolă wayland = wayland - +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/ru.ini b/res/lang/ru.ini index 23cec27..4d2b94d 100644 --- a/res/lang/ru.ini +++ b/res/lang/ru.ini @@ -3,26 +3,26 @@ brightness_down = уменьшить яркость brightness_up = увеличить яркость capslock = capslock custom = пользовательский - - - +custom_info_err_output_long = вывод слишком длинный +custom_info_err_no_output = нет вывода +custom_info_err_no_output_error = , возможная ошибка err_alloc = не удалось выделить память - +err_args = не удалось разобрать аргументы командной строки err_autologin_session = не найдена сессия с автологином err_bounds = за пределами индекса err_brightness_change = не удалось изменить яркость err_chdir = не удалось открыть домашнюю папку err_clock_too_long = строка часов слишком длинная err_config = не удалось разобрать файл конфигурации - +err_crawl = не удалось просканировать каталоги сессий err_dgn_oob = отладочное сообщение (log) err_domain = неверный домен err_empty_password = пустой пароль не допустим err_envlist = не удалось получить список переменных среды err_get_active_tty = не удалось получить активный tty - +err_hibernate = не удалось выполнить команду гибернации err_hostname = не удалось получить имя хоста - +err_inactivity = не удалось выполнить команду бездействия err_lock_state = не удалось получить состояние lock err_log = не удалось открыть файл log err_mlock = сбой блокировки памяти @@ -50,12 +50,12 @@ err_perm_group = не удалось понизить права доступа err_perm_user = не удалось понизить права доступа пользователя err_pwnam = не удалось получить информацию о пользователе err_sleep = не удалось выполнить команду sleep - +err_start = не удалось выполнить команду запуска err_battery = не удалось получить статус батареи err_switch_tty = не удалось переключить tty err_tty_ctrl = передача управления tty не удалась err_no_users = пользователи не найдены - +err_uid_range = не удалось динамически получить диапазон uid err_user_gid = не удалось установить GID пользователя err_user_init = не удалось инициализировать пользователя err_user_uid = не удалось установить UID пользователя @@ -63,11 +63,11 @@ err_xauth = команда xauth не выполнена err_xcb_conn = ошибка подключения xcb err_xsessions_dir = не удалось найти сессионную папку err_xsessions_open = не удалось открыть сессионную папку - +hibernate = гибернация insert = вставка login = логин logout = вышел из системы -no_x11_support = поддержка x11 отключена во время компиляции +no_x11_support = поддержка x11 отключена при компиляции normal = обычный numlock = numlock other = прочие @@ -76,7 +76,7 @@ restart = перезагрузить shell = оболочка shutdown = выключить sleep = сон - +toggle_password = показать/скрыть пароль wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/sr.ini b/res/lang/sr.ini index d0ad85a..a2678bf 100644 --- a/res/lang/sr.ini +++ b/res/lang/sr.ini @@ -1,82 +1,82 @@ - - - +authenticating = autentifikacija... +brightness_down = smanji osvetljenost +brightness_up = povećaj osvetljenost capslock = capslock - - - - -err_alloc = neuspijesna alokacija memorije - - +custom = prilagođeno +custom_info_err_output_long = izlaz predugačak +custom_info_err_no_output = nema izlaza +custom_info_err_no_output_error = , moguća greška +err_alloc = neuspješna alokacija memorije +err_args = nije moguće raščlaniti argumente komandne linije +err_autologin_session = sesija automatske prijave nije pronađena err_bounds = izvan granica indeksa - -err_chdir = neuspijesno otvaranje home foldera - - - +err_brightness_change = nije uspela promena osvetljenosti +err_chdir = neuspješno otvaranje home foldera +err_clock_too_long = niska sata je preduga +err_config = nije moguće raščlaniti konfiguracioni fajl +err_crawl = nije uspelo skeniranje direktorijuma sesija err_dgn_oob = log poruka -err_domain = nevazeci domen - - - - -err_hostname = neuspijesno trazenje hostname-a - - - -err_mlock = neuspijesno zakljucavanje memorije lozinke -err_null = null pokazivac - -err_pam = pam transakcija neuspijesna +err_domain = nevažeći domen +err_empty_password = prazna lozinka nije dozvoljena +err_envlist = nije uspelo dobijanje liste promenljivih okruženja +err_get_active_tty = nije uspelo dobijanje aktivnog tty +err_hibernate = nije uspelo izvršavanje komande hibernacije +err_hostname = neuspješno traženje hostname-a +err_inactivity = nije uspelo izvršavanje komande neaktivnosti +err_lock_state = nije uspelo dobijanje stanja zaključavanja +err_log = nije uspelo otvaranje fajla dnevnika +err_mlock = neuspješno zaključavanje memorije lozinke +err_null = null pokazivač +err_numlock = nije uspelo postavljanje numlock +err_pam = pam transakcija neuspješna err_pam_abort = pam transakcija prekinuta err_pam_acct_expired = nalog istekao -err_pam_auth = greska pri autentikaciji -err_pam_authinfo_unavail = neuspjelo uzimanje informacija o korisniku +err_pam_auth = greška pri autentikaciji +err_pam_authinfo_unavail = neuspješno uzimanje informacija o korisniku err_pam_authok_reqd = token istekao -err_pam_buf = greska bafera memorije -err_pam_cred_err = neuspjelo postavljanje kredencijala +err_pam_buf = greška bafera memorije +err_pam_cred_err = neuspješno postavljanje kredencijala err_pam_cred_expired = kredencijali istekli err_pam_cred_insufficient = nedovoljni kredencijali -err_pam_cred_unavail = neuspjelo uzimanje kredencijala -err_pam_maxtries = dostignut maksimalan broj pokusaja -err_pam_perm_denied = nedozovoljeno -err_pam_session = greska sesije -err_pam_sys = greska sistema +err_pam_cred_unavail = neuspješno uzimanje kredencijala +err_pam_maxtries = dostignut maksimalan broj pokušaja +err_pam_perm_denied = nedozvoljeno +err_pam_session = greška sesije +err_pam_sys = greška sistema err_pam_user_unknown = nepoznat korisnik -err_path = neuspjelo postavljanje path-a -err_perm_dir = neuspjelo mijenjanje foldera -err_perm_group = neuspjesno snizavanje dozvola grupe -err_perm_user = neuspijesno snizavanje dozvola korisnika -err_pwnam = neuspijesno skupljanje informacija o korisniku - - - - - - - -err_user_gid = neuspijesno postavljanje korisničkog GID-a -err_user_init = neuspijensa inicijalizacija korisnika -err_user_uid = neuspijesno postavljanje UID-a korisnika - - -err_xsessions_dir = neuspijesno pronalazenje foldera sesija -err_xsessions_open = neuspijesno otvaranje foldera sesija - - +err_path = neuspješno postavljanje path-a +err_perm_dir = neuspješno mijenjanje foldera +err_perm_group = neuspješno snižavanje dozvola grupe +err_perm_user = neuspješno snižavanje dozvola korisnika +err_pwnam = neuspješno skupljanje informacija o korisniku +err_sleep = nije uspelo izvršavanje komande spavanja +err_start = nije uspelo izvršavanje komande pokretanja +err_battery = nije uspelo učitavanje statusa baterije +err_switch_tty = nije uspelo prebacivanje tty +err_tty_ctrl = prenos kontrole tty nije uspeo +err_no_users = nisu pronađeni korisnici +err_uid_range = nije uspelo dinamičko dobijanje opsega uid +err_user_gid = neuspješno postavljanje korisničkog GID-a +err_user_init = neuspješna inicijalizacija korisnika +err_user_uid = neuspješno postavljanje UID-a korisnika +err_xauth = komanda xauth nije uspela +err_xcb_conn = xcb veza nije uspela +err_xsessions_dir = neuspješno pronalaženje foldera sesija +err_xsessions_open = neuspješno otvaranje foldera sesija +hibernate = hibernacija +insert = umetni login = korisnik logout = izlogovan - - +no_x11_support = x11 podrška onemogućena tokom prevođenja +normal = normalno numlock = numlock - +other = ostalo password = lozinka restart = ponovo pokreni shell = shell shutdown = ugasi - - +sleep = uspavaj +toggle_password = prikaži/sakrij lozinku wayland = wayland - +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/sr_Cyrl.ini b/res/lang/sr_Cyrl.ini new file mode 100644 index 0000000..6222b3d --- /dev/null +++ b/res/lang/sr_Cyrl.ini @@ -0,0 +1,82 @@ +authenticating = аутентификација... +brightness_down = смањи осветљеност +brightness_up = повећај осветљеност +capslock = capslock +custom = прилагођено +custom_info_err_output_long = излаз предугачак +custom_info_err_no_output = нема излаза +custom_info_err_no_output_error = , могућа грешка +err_alloc = неуспешна алокација меморије +err_args = није могуће рашчланити аргументе командне линије +err_autologin_session = сесија аутоматске пријаве није пронађена +err_bounds = изван граница индекса +err_brightness_change = није успела промена осветљености +err_chdir = неуспешно отварање home фолдера +err_clock_too_long = ниска сата је предуга +err_config = није могуће рашчланити конфигурациони фајл +err_crawl = није успело скенирање директоријума сесија +err_dgn_oob = лог порука +err_domain = неважећи домен +err_empty_password = празна лозинка није дозвољена +err_envlist = није успело добијање листе променљивих окружења +err_get_active_tty = није успело добијање активног tty +err_hibernate = није успело извршавање команде хибернације +err_hostname = неуспешно тражење hostname-а +err_inactivity = није успело извршавање команде неактивности +err_lock_state = није успело добијање стања закључавања +err_log = није успело отварање фајла дневника +err_mlock = неуспешно закључавање меморије лозинке +err_null = null показивач +err_numlock = није успело постављање numlock +err_pam = pam трансакција неуспешна +err_pam_abort = pam трансакција прекинута +err_pam_acct_expired = налог истекао +err_pam_auth = грешка при аутентикацији +err_pam_authinfo_unavail = неуспешно узимање информација о кориснику +err_pam_authok_reqd = токен истекао +err_pam_buf = грешка бафера меморије +err_pam_cred_err = неуспешно постављање акредитива +err_pam_cred_expired = акредитиви истекли +err_pam_cred_insufficient = недовољни акредитиви +err_pam_cred_unavail = неуспешно узимање акредитива +err_pam_maxtries = достигнут максималан број покушаја +err_pam_perm_denied = недозвољено +err_pam_session = грешка сесије +err_pam_sys = грешка система +err_pam_user_unknown = непознат корисник +err_path = неуспешно постављање путање +err_perm_dir = неуспешно мењање фолдера +err_perm_group = неуспешно снижавање дозвола групе +err_perm_user = неуспешно снижавање дозвола корисника +err_pwnam = неуспешно прикупљање информација о кориснику +err_sleep = није успело извршавање команде спавања +err_start = није успело извршавање команде покретања +err_battery = није успело учитавање статуса батерије +err_switch_tty = није успело пребацивање tty +err_tty_ctrl = пренос контроле tty није успео +err_no_users = нису пронађени корисници +err_uid_range = није успело динамичко добијање опсега uid +err_user_gid = неуспешно постављање корисничког GID-а +err_user_init = неуспешна иницијализација корисника +err_user_uid = неуспешно постављање UID-а корисника +err_xauth = команда xauth није успела +err_xcb_conn = xcb веза није успела +err_xsessions_dir = неуспешно проналажење фолдера сесија +err_xsessions_open = неуспешно отварање фолдера сесија +hibernate = хибернација +insert = уметни +login = корисник +logout = одјављен +no_x11_support = x11 подршка онемогућена током превођења +normal = нормално +numlock = numlock +other = остало +password = лозинка +restart = поново покрени +shell = shell +shutdown = угаси +sleep = успавај +toggle_password = прикажи/сакриј лозинку +wayland = wayland +x11 = x11 +xinitrc = xinitrc diff --git a/res/lang/sv.ini b/res/lang/sv.ini index adec801..45e36d4 100644 --- a/res/lang/sv.ini +++ b/res/lang/sv.ini @@ -3,9 +3,9 @@ brightness_down = minska ljusstyrka brightness_up = öka ljusstyrka capslock = capslock custom = anpassad - - - +custom_info_err_output_long = utdata för lång +custom_info_err_no_output = ingen utdata +custom_info_err_no_output_error = , möjligt fel err_alloc = minnesallokering misslyckades err_args = tolkning av kommandoargument misslyckades err_autologin_session = autologin-session hittades inte @@ -26,7 +26,7 @@ err_inactivity = inaktivitetslägets kommando misslyckades err_lock_state = hämtning av låsningsstatus misslyckades err_log = öppning av loggfil misslyckades err_mlock = låsning av lösenordsminne misslyckades -err_null = null pointer +err_null = nullpekare err_numlock = inställning av numlock misslyckades err_pam = pam-transaktion misslyckades err_pam_abort = pam-transaktion avbröts @@ -76,7 +76,7 @@ restart = starta om shell = shell shutdown = stäng av sleep = viloläge - +toggle_password = visa/dölj lösenord wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/tr.ini b/res/lang/tr.ini index 4ee5960..414f4d5 100644 --- a/res/lang/tr.ini +++ b/res/lang/tr.ini @@ -1,33 +1,33 @@ - +authenticating = kimlik doğrulanıyor... brightness_down = parlakligi azalt brightness_up = parlakligi arttir capslock = capslock - - - - +custom = özel +custom_info_err_output_long = çıktı çok uzun +custom_info_err_no_output = çıktı yok +custom_info_err_no_output_error = , olası hata err_alloc = basarisiz bellek ayirma - - +err_args = komut satırı argümanları ayrıştırılamıyor +err_autologin_session = otomatik oturum açma oturumu bulunamadı err_bounds = sinirlarin disinda dizin - +err_brightness_change = parlaklık değiştirilemedi err_chdir = ev klasoru acilamadi - - - +err_clock_too_long = saat dizesi çok uzun +err_config = yapılandırma dosyası ayrıştırılamıyor +err_crawl = oturum dizinleri taranamadı err_dgn_oob = log mesaji err_domain = gecersiz etki alani - - - - +err_empty_password = boş parola kullanılamaz +err_envlist = ortam değişkenleri listesi alınamadı +err_get_active_tty = aktif tty alınamadı +err_hibernate = hazırda bekletme komutu çalıştırılamadı err_hostname = ana bilgisayar adi alinamadi - - - +err_inactivity = hareketsizlik komutu çalıştırılamadı +err_lock_state = kilit durumu alınamadı +err_log = günlük dosyası açılamadı err_mlock = parola bellegi kilitlenemedi err_null = bos isaretci hatasi - +err_numlock = numlock ayarlanamadı err_pam = pam islemi basarisiz oldu err_pam_abort = pam islemi durduruldu err_pam_acct_expired = hesabin suresi dolmus @@ -49,26 +49,26 @@ err_perm_dir = gecerli dizin degistirilemedi err_perm_group = grup izinleri dusurulemedi err_perm_user = kullanici izinleri dusurulemedi err_pwnam = kullanici bilgileri alinamadi - - - - - - - +err_sleep = uyku komutu çalıştırılamadı +err_start = başlatma komutu çalıştırılamadı +err_battery = pil durumu yüklenemedi +err_switch_tty = tty değiştirilemedi +err_tty_ctrl = tty kontrol aktarımı başarısız oldu +err_no_users = kullanıcı bulunamadı +err_uid_range = uid aralığı dinamik olarak alınamadı err_user_gid = kullanici icin GID ayarlanamadi err_user_init = kullanici oturumu baslatilamadi err_user_uid = kullanici icin UID ayarlanamadi - - +err_xauth = xauth komutu başarısız oldu +err_xcb_conn = xcb bağlantısı başarısız oldu err_xsessions_dir = oturumlar klasoru bulunamadi err_xsessions_open = oturumlar klasoru acilamadi hibernate = askiya al - +insert = ekle login = kullanici logout = oturumdan cikis yapildi - - +no_x11_support = x11 desteği derleme zamanında devre dışı bırakıldı +normal = normal numlock = numlock other = baska password = sifre @@ -76,7 +76,7 @@ restart = yeniden baslat shell = shell shutdown = makineyi kapat sleep = uykuya al - +toggle_password = parolayı göster/gizle wayland = wayland - +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/uk.ini b/res/lang/uk.ini index 7b47f8a..6baa469 100644 --- a/res/lang/uk.ini +++ b/res/lang/uk.ini @@ -1,33 +1,33 @@ - - - +authenticating = автентифікація... +brightness_down = зменшити яскравість +brightness_up = збільшити яскравість capslock = capslock - - - - +custom = власний +custom_info_err_output_long = вивід занадто довгий +custom_info_err_no_output = немає виводу +custom_info_err_no_output_error = , можлива помилка err_alloc = невдале виділення пам'яті - - +err_args = не вдалося розібрати аргументи командного рядка +err_autologin_session = сеанс автоматичного входу не знайдено err_bounds = поза межами індексу - +err_brightness_change = не вдалося змінити яскравість err_chdir = не вдалося відкрити домашній каталог - - - +err_clock_too_long = рядок годинника занадто довгий +err_config = не вдалося розібрати файл конфігурації +err_crawl = не вдалося сканувати каталоги сесій err_dgn_oob = повідомлення журналу (log) err_domain = недійсний домен - - - - +err_empty_password = порожній пароль не дозволено +err_envlist = не вдалося отримати список змінних середовища +err_get_active_tty = не вдалося отримати активний tty +err_hibernate = не вдалося виконати команду гібернації err_hostname = не вдалося отримати ім'я хосту - - - +err_inactivity = не вдалося виконати команду неактивності +err_lock_state = не вдалося отримати стан блокування +err_log = не вдалося відкрити файл журналу err_mlock = збій блокування пам'яті err_null = нульовий вказівник - +err_numlock = не вдалося встановити numlock err_pam = невдала pam транзакція err_pam_abort = pam транзакція перервана err_pam_acct_expired = термін дії акаунту вичерпано @@ -49,34 +49,34 @@ err_perm_dir = не вдалося змінити поточний катало err_perm_group = не вдалося понизити права доступу групи err_perm_user = не вдалося понизити права доступу користувача err_pwnam = не вдалося отримати дані користувача - - - - - - - +err_sleep = не вдалося виконати команду сну +err_start = не вдалося виконати команду запуску +err_battery = не вдалося завантажити стан акумулятора +err_switch_tty = не вдалося переключити tty +err_tty_ctrl = передача керування tty не вдалася +err_no_users = користувачів не знайдено +err_uid_range = не вдалося динамічно отримати діапазон uid err_user_gid = не вдалося змінити GID користувача err_user_init = не вдалося ініціалізувати користувача err_user_uid = не вдалося змінити UID користувача - - +err_xauth = команда xauth не вдалася +err_xcb_conn = з'єднання xcb не вдалося err_xsessions_dir = не вдалося знайти каталог сесій err_xsessions_open = не вдалося відкрити каталог сесій - - +hibernate = гібернація +insert = вставити login = логін logout = вийти - - +no_x11_support = підтримку x11 вимкнено під час компіляції +normal = нормальний numlock = numlock - +other = інший password = пароль restart = перезавантажити shell = оболонка shutdown = вимкнути - - +sleep = сплячий режим +toggle_password = показати/приховати пароль wayland = wayland - +x11 = x11 xinitrc = xinitrc diff --git a/res/lang/zh_CN.ini b/res/lang/zh_CN.ini index d2af6c3..4562624 100644 --- a/res/lang/zh_CN.ini +++ b/res/lang/zh_CN.ini @@ -1,33 +1,33 @@ - - - +authenticating = 正在认证... +brightness_down = 降低亮度 +brightness_up = 提高亮度 capslock = 大写锁定 - - - - +custom = 自定义 +custom_info_err_output_long = 输出过长 +custom_info_err_no_output = 无输出 +custom_info_err_no_output_error = ,可能有错误 err_alloc = 内存分配失败 - - +err_args = 无法解析命令行参数 +err_autologin_session = 未找到自动登录会话 err_bounds = 索引越界 - +err_brightness_change = 无法更改亮度 err_chdir = 无法打开home文件夹 - - - +err_clock_too_long = 时钟字符串过长 +err_config = 无法解析配置文件 +err_crawl = 无法扫描会话目录 err_dgn_oob = 日志消息 err_domain = 无效的域 - - - - +err_empty_password = 不允许空密码 +err_envlist = 无法获取环境变量列表 +err_get_active_tty = 无法获取当前活动的tty +err_hibernate = 无法执行休眠命令 err_hostname = 获取主机名失败 - - - +err_inactivity = 无法执行非活动命令 +err_lock_state = 无法获取锁定状态 +err_log = 无法打开日志文件 err_mlock = 锁定密码存储器失败 err_null = 空指针 - +err_numlock = 无法设置numlock err_pam = PAM事件失败 err_pam_abort = PAM事务已中止 err_pam_acct_expired = 帐户已过期 @@ -49,34 +49,34 @@ err_perm_dir = 更改当前目录失败 err_perm_group = 组权限降级失败 err_perm_user = 用户权限降级失败 err_pwnam = 获取用户信息失败 - - - - - - - +err_sleep = 无法执行睡眠命令 +err_start = 无法执行启动命令 +err_battery = 无法加载电池状态 +err_switch_tty = 无法切换tty +err_tty_ctrl = tty控制转移失败 +err_no_users = 未找到用户 +err_uid_range = 无法动态获取uid范围 err_user_gid = 设置用户GID失败 err_user_init = 初始化用户失败 err_user_uid = 设置用户UID失败 - - +err_xauth = xauth命令失败 +err_xcb_conn = xcb连接失败 err_xsessions_dir = 找不到会话文件夹 err_xsessions_open = 无法打开会话文件夹 - - +hibernate = 休眠 +insert = 插入 login = 登录 logout = 注销 - - +no_x11_support = x11支持在编译时被禁用 +normal = 正常 numlock = 数字锁定 - +other = 其他 password = 密码 - +restart = 重启 shell = shell - - - +shutdown = 关机 +sleep = 睡眠 +toggle_password = 显示/隐藏密码 wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/zh_TW.ini b/res/lang/zh_TW.ini new file mode 100644 index 0000000..50d5f68 --- /dev/null +++ b/res/lang/zh_TW.ini @@ -0,0 +1,82 @@ +authenticating = 正在驗證... +brightness_down = 降低亮度 +brightness_up = 提高亮度 +capslock = 大寫鎖定 +custom = 自訂 +custom_info_err_output_long = 輸出過長 +custom_info_err_no_output = 無輸出 +custom_info_err_no_output_error = ,可能有錯誤 +err_alloc = 記憶體配置失敗 +err_args = 無法解析命令列參數 +err_autologin_session = 找不到自動登入工作階段 +err_bounds = 索引超出範圍 +err_brightness_change = 無法變更亮度 +err_chdir = 無法開啟家目錄 +err_clock_too_long = 時鐘字串過長 +err_config = 無法解析設定檔 +err_crawl = 無法掃描工作階段目錄 +err_dgn_oob = 日誌訊息 +err_domain = 無效的網域 +err_empty_password = 不允許空密碼 +err_envlist = 無法取得環境變數清單 +err_get_active_tty = 無法取得目前使用中的 tty +err_hibernate = 無法執行休眠命令 +err_hostname = 取得主機名稱失敗 +err_inactivity = 無法執行閒置命令 +err_lock_state = 無法取得鎖定狀態 +err_log = 無法開啟日誌檔案 +err_mlock = 鎖定密碼記憶體失敗 +err_null = 空指標 +err_numlock = 無法設定 numlock +err_pam = PAM 交易失敗 +err_pam_abort = PAM 交易已中止 +err_pam_acct_expired = 帳號已過期 +err_pam_auth = 驗證錯誤 +err_pam_authinfo_unavail = 取得使用者資訊失敗 +err_pam_authok_reqd = 金鑰已過期 +err_pam_buf = 記憶體緩衝區錯誤 +err_pam_cred_err = 設定憑證失敗 +err_pam_cred_expired = 憑證已過期 +err_pam_cred_insufficient = 憑證不足 +err_pam_cred_unavail = 無法取得憑證 +err_pam_maxtries = 已達到最大嘗試次數限制 +err_pam_perm_denied = 拒絕存取 +err_pam_session = 工作階段錯誤 +err_pam_sys = 系統錯誤 +err_pam_user_unknown = 未知的使用者 +err_path = 無法設定路徑 +err_perm_dir = 變更目前目錄失敗 +err_perm_group = 群組權限降級失敗 +err_perm_user = 使用者權限降級失敗 +err_pwnam = 取得使用者資訊失敗 +err_sleep = 無法執行睡眠命令 +err_start = 無法執行啟動命令 +err_battery = 無法載入電池狀態 +err_switch_tty = 無法切換 tty +err_tty_ctrl = tty 控制權移轉失敗 +err_no_users = 找不到使用者 +err_uid_range = 無法動態取得 uid 範圍 +err_user_gid = 設定使用者 GID 失敗 +err_user_init = 初始化使用者失敗 +err_user_uid = 設定使用者 UID 失敗 +err_xauth = xauth 命令失敗 +err_xcb_conn = xcb 連線失敗 +err_xsessions_dir = 找不到工作階段資料夾 +err_xsessions_open = 無法開啟工作階段資料夾 +hibernate = 休眠 +insert = 插入 +login = 登入 +logout = 登出 +no_x11_support = x11 支援已在編譯時停用 +normal = 正常 +numlock = 數字鎖定 +other = 其他 +password = 密碼 +restart = 重新啟動 +shell = shell +shutdown = 關機 +sleep = 睡眠 +toggle_password = 顯示/隱藏密碼 +wayland = wayland +x11 = x11 +xinitrc = xinitrc From 32436d438e82a4195a15758fc3ae6218d4815e5f Mon Sep 17 00:00:00 2001 From: koru Date: Sat, 6 Jun 2026 11:54:29 +0200 Subject: [PATCH 34/77] Update `err_crawl` for Russian lang (#1011) See: https://codeberg.org/fairyglade/ly/pulls/997#issuecomment-15674144 Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/1011 Reviewed-by: AnErrupTion --- res/lang/ru.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/lang/ru.ini b/res/lang/ru.ini index 4d2b94d..014c170 100644 --- a/res/lang/ru.ini +++ b/res/lang/ru.ini @@ -14,7 +14,7 @@ err_brightness_change = не удалось изменить яркость err_chdir = не удалось открыть домашнюю папку err_clock_too_long = строка часов слишком длинная err_config = не удалось разобрать файл конфигурации -err_crawl = не удалось просканировать каталоги сессий +err_crawl = не удалось просканировать каталоги сессии err_dgn_oob = отладочное сообщение (log) err_domain = неверный домен err_empty_password = пустой пароль не допустим From 5b8ebeba6ebbad84923b12f5690f735d68330b8d Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Wed, 10 Jun 2026 14:45:48 +0200 Subject: [PATCH 35/77] Create CONTRIBUTING.md Signed-off-by: AnErrupTion --- CONTRIBUTING.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..eddaffb --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Contributing to Ly + +To contribute to Ly, you have to open a pull request on [Codeberg](https://codeberg.org/fairyglade/ly), as [GitHub](https://github.com/fairyglade/ly) is just a mirror. However, you also have to respect the following rules, otherwise your PR may end up being rejected: + +## AI usage + +While we cannot control your usage of any LLM whatsoever, we do heavily discourage their use for environmental, ethical & moral reasons that you can learn more about on the Internet. However, if you do end up still using them, here are a couple rules you **must absolutely** respect for your PR not to get instantly shot down. Of course, it goes without saying that **all** the other rules in the other sections below **must** be adhered to, even more so when AI is used. + +1. **Communicate through you**, not the AI; as in, responses to reviews or other comments in the PR must be written by you and not an LLM. If English isn't your native language and you have a lot of trouble speaking it, you _may_ use AI, but responses must not be your typical, alienating AI-generated text: https://github.com/realrossmanngroup/no_ai_slop_writing_rules +2. Control the code, as in, **don't vibecode**, especially if you don't know Zig. Don't waste the maintainers's time, and **heavily test your code**, as AI-generated code is typically more error-prone in subtle ways (even if they can be better than humans in some other aspects). Finally, don't generate any "summary" or whatever the AI may come up with during the process. **If you cannot understand the generated code, do not contribute it**. Maintainers are busy and are often simple volunteers, so the less work they have to do, the better. +3. **Be transparent about AI usage**. Precise what AI model was used in the process, and preferably, how you went about creating your changes (i.e. how did you use AI to make the pull request). The more honest you are about it, the more likely your PR will be accepted and merged into the code base. + +If all the above rules are respected, your changes have much more likely to be accepted into the code base. + +## Code style + +You must follow Zig's [style guide](https://ziglang.org/documentation/master/#Style-Guide). In most cases, all you'll have to do is run `zig fmt` after you have completed your changes, though it does not fix everything, notably variable, function & field naming, as well as the maximum length of aline. + +For the former, please refer to the aforementioned style guide in that case. For the latter, you must respect a maximum line length of **80 characters**. For function calls with many parameters or anything similar that may overflow this limit, consider adding a trailing comma to the list so that `zig fmt` can split it into multiple lines. Ideally, few or no lines end up having to get soft wrapped by an editor having this limit set. + +## Commit names & descriptions + +1. **Commit names must be descriptive**, resorting to the commit description if they are too long. In such cases, the commit name **must** be shortened while still making sense. With that said, no particular convention (emojis, prefixes & suffixes, etc.) is mandated for them, and you are free to adopt any one you think is best or that you are used to. +2. **Do not force push**, as PRs will get squashed into a single commit anyway. This erases history and makes it impossible to see the changes done over time and by a particular commit. +3. While not a requirement per se, **consider signing your commits** with an SSH or GPG key for security purposes. This ensures to a lesser extent that you are the person who you claim to be, and reduces the potential amount of malicious contributions that could infiltrate the code base. + +## Additional requirements + +Other requirements (such as testing your code) for merging the changes will be available when you open your pull request via the template (which you **must** use), however, these are not stated here because they may not be mandatory in some cases (e.g. if the changes are still work-in-progress), so they may temporarily be ommitted for a certain period of time until the changes are fully ready to be reviewed, for instance. From d8c3aec6685e8d9f0aed25846d34ece830f2988a Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Wed, 10 Jun 2026 14:49:39 +0200 Subject: [PATCH 36/77] Update PR template to reflect new contributing guidelines Signed-off-by: AnErrupTion --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 45044a3..a32f0c2 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -9,4 +9,4 @@ _Replace this with a reference to an existing issue, or N/A if there is none_ ## Pre-requisites - [ ] I have tested & confirmed the changes work locally -- [ ] I have run `zig fmt` throughout my changes +- [ ] I have read and fully adhere to the rules set in the contributing guidelines found in `CONTRIBUTING.md` From a07ca88c743f5f30bb207695e47b5c98cb1a85aa Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Thu, 11 Jun 2026 20:35:42 +0200 Subject: [PATCH 37/77] build.zig: Fix new locales not being installed Signed-off-by: AnErrupTion --- build.zig | 5 +++++ CONTRIBUTING.md => contributing.md | 0 2 files changed, 5 insertions(+) rename CONTRIBUTING.md => contributing.md (100%) diff --git a/build.zig b/build.zig index 9e89029..21c56b4 100644 --- a/build.zig +++ b/build.zig @@ -203,14 +203,17 @@ fn install_ly(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap, ins const languages = [_][]const u8{ "ar.ini", + "bg.ini", "cat.ini", "cs.ini", "de.ini", "en.ini", + "eo.ini", "es.ini", "fr.ini", "it.ini", "ja_JP.ini", + "ku.ini", "lv.ini", "pl.ini", "pt.ini", @@ -218,10 +221,12 @@ fn install_ly(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap, ins "ro.ini", "ru.ini", "sr.ini", + "sr_Cyrl.ini", "sv.ini", "tr.ini", "uk.ini", "zh_CN.ini", + "zh_TW.ini", }; inline for (languages) |language| { diff --git a/CONTRIBUTING.md b/contributing.md similarity index 100% rename from CONTRIBUTING.md rename to contributing.md From 008d413295ff56a0a6491fc83c6939e530bc5398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Fri, 12 Jun 2026 12:09:37 +0200 Subject: [PATCH 38/77] Fix user detection if /etc/login.defs does not contain both UID_MIN and UID_MAX (#1014) ## What are the changes about? I modified getUserIdRange(), so it checks if either of UID_MIN and UID_MAX is set in /etc/login.defs. If any, but not both, is not set, it uses fallback value. I don't know zig build system, so I added ugly fallback values passthrough. ## What existing issue does this resolve? #1013 ## Pre-requisites - [X] I have tested & confirmed the changes work locally - [X] I have read and fully adhere to the rules set in the contributing guidelines found in `CONTRIBUTING.md` Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/1014 Reviewed-by: AnErrupTion --- build.zig | 2 ++ ly-core/build.zig | 7 +++++++ ly-core/src/interop.zig | 20 ++++++++++++++++---- ly-ui/build.zig | 5 +++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index 21c56b4..2de19f7 100644 --- a/build.zig +++ b/build.zig @@ -75,6 +75,8 @@ pub fn build(b: *std.Build) !void { .target = target, .optimize = optimize, .enable_x11_support = enable_x11_support, + .fallback_uid_min = fallback_uid_min, + .fallback_uid_max = fallback_uid_max }); exe.root_module.addImport("ly-ui", ly_ui.module("ly-ui")); diff --git a/ly-core/build.zig b/ly-core/build.zig index 56dc4ec..cf0dbf8 100644 --- a/ly-core/build.zig +++ b/ly-core/build.zig @@ -11,6 +11,13 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); + const fallback_uid_min = b.option(std.posix.uid_t, "fallback_uid_min", "Set the fallback minimum UID (default is 1000). This value gets embedded into the binary").?; + const fallback_uid_max = b.option(std.posix.uid_t, "fallback_uid_max", "Set the fallback maximum UID (default is 60000). This value gets embedded into the binary").?; + const build_options = b.addOptions(); + build_options.addOption(std.posix.uid_t, "fallback_uid_min", fallback_uid_min); + build_options.addOption(std.posix.uid_t, "fallback_uid_max", fallback_uid_max); + mod.addOptions("build_options", build_options); + const zigini = b.dependency("zigini", .{ .target = target, .optimize = optimize }); mod.addImport("zigini", zigini.module("zigini")); diff --git a/ly-core/src/interop.zig b/ly-core/src/interop.zig index 69e02ff..7d09381 100644 --- a/ly-core/src/interop.zig +++ b/ly-core/src/interop.zig @@ -1,5 +1,6 @@ const std = @import("std"); const builtin = @import("builtin"); +const build_options = @import("build_options"); const UidRange = @import("UidRange.zig"); const pwd = @import("pwd"); const stdlib = @import("stdlib"); @@ -145,21 +146,32 @@ fn PlatformStruct() type { var iterator = std.mem.splitScalar(u8, login_defs_buffer, '\n'); var uid_range = UidRange{}; - var nameFound = false; + var uid_min_Found = false; + var uid_max_Found = false; while (iterator.next()) |line| { const trimmed_line = std.mem.trim(u8, line, " \n\r\t"); if (std.mem.startsWith(u8, trimmed_line, "UID_MIN")) { uid_range.uid_min = try parseValue(std.posix.uid_t, "UID_MIN", trimmed_line); - nameFound = true; + uid_min_Found = true; } else if (std.mem.startsWith(u8, trimmed_line, "UID_MAX")) { uid_range.uid_max = try parseValue(std.posix.uid_t, "UID_MAX", trimmed_line); - nameFound = true; + uid_max_Found = true; } } - if (!nameFound) return error.UidNameNotFound; + if (!(uid_min_Found or uid_max_Found)) { + return error.UidNameNotFound; + } + + if (!uid_min_Found) { + uid_range.uid_min = build_options.fallback_uid_min; + } + + if (!uid_max_Found) { + uid_range.uid_max = build_options.fallback_uid_max; + } return uid_range; } diff --git a/ly-ui/build.zig b/ly-ui/build.zig index 2e3ce6b..0ab5b70 100644 --- a/ly-ui/build.zig +++ b/ly-ui/build.zig @@ -11,10 +11,15 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); + const fallback_uid_min = b.option(std.posix.uid_t, "fallback_uid_min", "Set the fallback minimum UID (default is 1000). This value gets embedded into the binary"); + const fallback_uid_max = b.option(std.posix.uid_t, "fallback_uid_max", "Set the fallback maximum UID (default is 60000). This value gets embedded into the binary"); + const ly_core = b.dependency("ly_core", .{ .target = target, .optimize = optimize, .enable_x11_support = enable_x11_support, + .fallback_uid_min = fallback_uid_min, + .fallback_uid_max = fallback_uid_max }); mod.addImport("ly-core", ly_core.module("ly-core")); From f683a82f562fb20dd19776e21669e5a9f6c8d010 Mon Sep 17 00:00:00 2001 From: oliebe Date: Sun, 14 Jun 2026 21:03:41 +0200 Subject: [PATCH 39/77] Fix small typos in readme.md (#1017) ## What are the changes about? I fixed some incorrect inflections and typos in the readme ## What existing issue does this resolve? N/A ## Pre-requisites - [x] I have tested & confirmed the changes work locally - [x] I have read and fully adhere to the rules set in the contributing guidelines found in `CONTRIBUTING.md` Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/1017 Reviewed-by: AnErrupTion --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 79c3a63..4d11596 100644 --- a/readme.md +++ b/readme.md @@ -217,7 +217,7 @@ ttyv1 "/usr/libexec/getty Ly" xterm on secure ### Updating -You can also install Ly without overrding the current configuration file. This is called **updating**. To update, simply run: +You can also install Ly without overriding the current configuration file. This is called **updating**. To update, simply run: ``` # zig build installnoconf @@ -241,7 +241,7 @@ Use the Up/Down arrow keys to change the current field, and the Left/Right arrow ## A note on .xinitrc -If your `.xinitrc` file doesn't work ,make sure it is executable and includes a shebang. This file is supposed to be a shell script! Quoting from `xinit`'s man page: +If your `.xinitrc` file doesn't work, make sure it is executable and includes a shebang. This file is supposed to be a shell script! Quoting from `xinit`'s man page: > If no specific client program is given on the command line, xinit will look for a file in the user's home directory called .xinitrc to run as a shell script to start up client programs. @@ -253,7 +253,7 @@ A typical shebang for a shell script looks like this: ## Tips -- The numlock and capslock state is printed in the top-right corner. +- The numlock and capslock states are printed in the top-right corner. - Use the F1 and F2 keys to respectively shutdown and reboot. From ed783b5a2392102daee66946211601f4471d15c8 Mon Sep 17 00:00:00 2001 From: Yuri dos Santos Date: Sun, 14 Jun 2026 21:59:15 +0200 Subject: [PATCH 40/77] Minor pt_BR translation correction to sound more natural (#1018) ## What are the changes about? Changed two sentences to sound more natural to Brazilian Portuguese speakers. - Token to masculine adj. Token is often (if not always) described as masculine subject (e.g [Wikipedia](https://pt.wikipedia.org/wiki/Token_(an%C3%A1lise_l%C3%A9xica))) - Moved sentence to be written using "falhou" always in the end of a phrase to follow the same pattern as the other similar sentences. Also, using "falhou" at the beginning of the sentence is not wrong, but sounds a bit weird and it's not common in formal texts ## What existing issue does this resolve? Just translation related issues ## Pre-requisites - [x] I have tested & confirmed the changes work locally - [x] I have read and fully adhere to the rules set in the contributing guidelines found in `CONTRIBUTING.md` Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/1018 Reviewed-by: AnErrupTion --- res/lang/pt_BR.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/lang/pt_BR.ini b/res/lang/pt_BR.ini index 1ccc4c4..af8c970 100644 --- a/res/lang/pt_BR.ini +++ b/res/lang/pt_BR.ini @@ -33,7 +33,7 @@ err_pam_abort = transação pam abortada err_pam_acct_expired = conta expirada err_pam_auth = erro de autenticação err_pam_authinfo_unavail = não foi possível obter informações do usuário -err_pam_authok_reqd = token expirada +err_pam_authok_reqd = token expirado err_pam_buf = erro de buffer de memória err_pam_cred_err = erro para definir credenciais err_pam_cred_expired = credenciais expiradas @@ -53,7 +53,7 @@ err_sleep = não foi possível executar o comando de suspensão err_start = não foi possível executar o comando de início err_battery = não foi possível carregar o status da bateria err_switch_tty = não foi possível mudar de tty -err_tty_ctrl = falhou a transferência de controle do tty +err_tty_ctrl = a transferência de controle do tty falhou err_no_users = nenhum usuário encontrado err_uid_range = não foi possível obter dinamicamente o intervalo de uid err_user_gid = não foi possível definir o GID do usuário From aa00f7c8c7437a3bc2a9dc7d474985d28e68f509 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 15 Jun 2026 16:53:24 +0200 Subject: [PATCH 41/77] Replace ArrayListUnmanaged with ArrayList Signed-off-by: AnErrupTion --- ly-ui/src/components/Text.zig | 2 +- ly-ui/src/components/generic.zig | 2 +- src/components/UserList.zig | 2 +- src/main.zig | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ly-ui/src/components/Text.zig b/ly-ui/src/components/Text.zig index 0ca5312..b4aad21 100644 --- a/ly-ui/src/components/Text.zig +++ b/ly-ui/src/components/Text.zig @@ -6,7 +6,7 @@ const TerminalBuffer = @import("../TerminalBuffer.zig"); const Position = @import("../Position.zig"); const Widget = @import("../Widget.zig"); -const DynamicString = std.ArrayListUnmanaged(u8); +const DynamicString = std.ArrayList(u8); const Text = @This(); diff --git a/ly-ui/src/components/generic.zig b/ly-ui/src/components/generic.zig index 572fe3f..2d0b3c4 100644 --- a/ly-ui/src/components/generic.zig +++ b/ly-ui/src/components/generic.zig @@ -8,7 +8,7 @@ const Position = @import("../Position.zig"); pub fn CyclableLabel(comptime ItemType: type, comptime ChangeItemType: type) type { return struct { const Allocator = std.mem.Allocator; - const ItemList = std.ArrayListUnmanaged(ItemType); + const ItemList = std.ArrayList(ItemType); const DrawItemFn = *const fn (*Self, ItemType, usize, usize, usize) void; const ChangeItemFn = *const fn (ItemType, ?ChangeItemType) void; diff --git a/src/components/UserList.zig b/src/components/UserList.zig index 9f01bc5..1be513c 100644 --- a/src/components/UserList.zig +++ b/src/components/UserList.zig @@ -10,7 +10,7 @@ const CyclableLabel = ly_ui.CyclableLabel; const Session = @import("Session.zig"); const SavedUsers = @import("../config/SavedUsers.zig"); -const StringList = std.ArrayListUnmanaged([]const u8); +const StringList = std.ArrayList([]const u8); pub const User = struct { name: []const u8, session_index: *usize, diff --git a/src/main.zig b/src/main.zig index 0f6f1e0..b739442 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,6 +1,6 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const StringList = std.ArrayListUnmanaged([]const u8); +const StringList = std.ArrayList([]const u8); const temporary_allocator = std.heap.page_allocator; const builtin = @import("builtin"); const build_options = @import("build_options"); From a801d1a5696a73a2535b26010162dd2cc2bd8638 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Wed, 17 Jun 2026 22:23:12 +0200 Subject: [PATCH 42/77] Clean up save code Signed-off-by: AnErrupTion --- src/main.zig | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main.zig b/src/main.zig index b739442..887ec41 100644 --- a/src/main.zig +++ b/src/main.zig @@ -235,11 +235,7 @@ pub fn main(init: std.process.Init) !void { } // Load configuration file - var save_path_alloc = false; - - state.save_path = build_options.config_directory ++ "/ly/save.txt"; - state.old_save_path = build_options.config_directory ++ "/ly/save.ini"; - defer if (save_path_alloc) { + defer if (state.config.save) { state.allocator.free(state.save_path); state.allocator.free(state.old_save_path); }; @@ -284,7 +280,6 @@ pub fn main(init: std.process.Init) !void { if (state.config.save) { state.save_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "save.txt" }); state.old_save_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "save.ini" }); - save_path_alloc = true; } if (config_parser.maybe_load_error == null) { From e13856387464b01d411c1e72dd6e1c75a31a037f Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Thu, 18 Jun 2026 19:51:18 +0200 Subject: [PATCH 43/77] README: Specify Alpine for /etc/inittab Signed-off-by: AnErrupTion --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 4d11596..620929e 100644 --- a/readme.md +++ b/readme.md @@ -14,7 +14,7 @@ Join us on Matrix over at [#ly-dm:matrix.org](https://matrix.to/#/#ly-dm:matrix. ## Dependencies - Compile-time: - - zig 0.16.x (you must use a __release version__ of zig; check that `zig version` does not have a `-dev*` suffix) + - zig 0.16.x (you must use a **release version** of zig; check that `zig version` does not have a `-dev*` suffix) - libc @@ -151,7 +151,7 @@ On non-systemd systems, you can change the TTY Ly will run on by editing the cor ``` > [!NOTE] -> On Gentoo specifically, you also **must** comment out the appropriate line for the TTY in /etc/inittab. +> On Gentoo, Alpine and potentially others, you also **must** comment out the appropriate line for the TTY in /etc/inittab. ### runit From e833c4bc1d639979c7970918b6a426cd367a9ac2 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Thu, 18 Jun 2026 20:16:25 +0200 Subject: [PATCH 44/77] auth: Create XDG_RUNTIME_DIR if /run/user/UID exists Signed-off-by: AnErrupTion --- src/auth.zig | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/auth.zig b/src/auth.zig index 6a97fff..7a3c033 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -179,7 +179,7 @@ fn startSession( // Reset the XDG environment variables try log_file.info(io, "auth/env", "resetting xdg environment variables", .{}); try setXdgEnv(allocator, tty_str, current_environment); - try setXdgRuntimeDir(allocator); + try setXdgRuntimeDir(allocator, io); // Set the PAM variables const pam_env_vars: ?[*:null]?[*:0]u8 = interop.pam.pam_getenvlist(handle); @@ -247,18 +247,20 @@ fn setXdgEnv(allocator: std.mem.Allocator, tty_str: []u8, environment: Environme try interop.setEnvironmentVariable(allocator, "XDG_VTNR", tty_str, false); } -fn setXdgRuntimeDir(allocator: std.mem.Allocator) !void { - // The "/run/user/%d" directory is not available on FreeBSD. It is much - // better to stick to the defaults and let applications using - // XDG_RUNTIME_DIR to fall back to directories inside user's home - // directory. - if (builtin.os.tag != .freebsd) { - const uid = std.posix.system.getuid(); - var uid_buffer: [32]u8 = undefined; // No UID can be larger than this - const uid_str = try std.fmt.bufPrint(&uid_buffer, "/run/user/{d}", .{uid}); +fn setXdgRuntimeDir(allocator: std.mem.Allocator, io: std.Io) !void { + // The "/run/user/%d" directory is not available on some operating systems, + // like FreeBSD and Alpine + const uid = std.posix.system.getuid(); + var uid_buffer: [32]u8 = undefined; // No UID can be larger than this + const uid_str = try std.fmt.bufPrint(&uid_buffer, "/run/user/{d}", .{uid}); - try interop.setEnvironmentVariable(allocator, "XDG_RUNTIME_DIR", uid_str, false); - } + var xdg_dir = std.Io.Dir.openDirAbsolute(io, uid_str, .{}) catch |err| { + if (err == error.FileNotFound) return; + return err; + }; + xdg_dir.close(io); + + try interop.setEnvironmentVariable(allocator, "XDG_RUNTIME_DIR", uid_str, false); } fn loginConv( @@ -390,7 +392,7 @@ fn createXauthFile(log_file: *LogFile, io: std.Io, pwd: []const u8, buffer: []u8 const xauthority: []u8 = try std.fmt.bufPrint(buffer, "{s}/{s}", .{ trimmed_xauth_dir, xauth_file }); - std.Io.Dir.cwd().createDirPath(io, trimmed_xauth_dir) catch {}; + try std.Io.Dir.cwd().createDirPath(io, trimmed_xauth_dir); try log_file.info(io, "auth/x11", "creating xauth file: {s}", .{xauthority}); From eeccb7421b5b23eda5a5a1bc03bbebcf65ae003f Mon Sep 17 00:00:00 2001 From: RadsammyT Date: Fri, 19 Jun 2026 20:05:00 +0200 Subject: [PATCH 45/77] feat: LuaJIT Animations (#1001) ## What are the changes about? TL;DR: ![ly_meme](/attachments/f4c3a93b-6ede-42ab-a351-292e2105d4e2) Slaps the entire LuaJIT runtime onto Ly, allowing for the creation of custom dynamic animations like GameOfLife, ColorWave, Doom, etc. This PR adds the [ziglua](https://github.com/natecraddock/ziglua?ref=zig-0.16) dependency for its zig bindings and considerable buildtime config (mainly lua version selection). ### Example ```lua ly.frame_delay = 5 local timer = 0 local clock = os.clock() local clock_diff = 0 function draw() timer = timer + 1 byte = string.byte(' ') clock_diff = os.clock() - clock clock = os.clock() timer = timer + clock_diff for x = 0, ly.width-1 do for y = 0, ly.height-1 do local xc = 0xFF if x < 255 then xc = ((x + math.floor(timer / 2)) * 3) % 255 else xc = 0 end local yc = 0xFF if y < 255 then yc = ((y) * 3) % 255 else yc = 0 end ly.putCell(byte, xc, bit.bor(xc, yc), x, y) end end end ``` ### The API The API that Ly gives to the user is minimal. A table is globally available, named `ly`, which provides the following: | Member | Purpose | |---------|---------| | `ly.width` & `ly.height` | Respective Width/Height from the `TerminalBuffer` | | `ly.putCell(byte, fg, bg, x, y)` | Literally `Cell.init(byte, fg, bg).put(x, y)`.| | `ly.clock()` | The current real-time, in microseconds. | ### Error Handling On a Lua Error, Ly won't quit but will instead paint the entire background red. The lua error in question can be found in the Ly log file and on-screen. ```log 2026-05-19 16:13:40 [err/Lua] Error (Cannot call draw()): attempt to call a nil value 2026-05-19 11:05:51 [err/Lua] Lua Error: ...dsammyt/programming/probe/ly/scratch/testConfig/test.lua:30: bad argument #1 to 'ipairs' (table expected, got number) ``` ## Pre-requisites - [X] I have tested & confirmed the changes work locally - [X] I have run `zig fmt` throughout my changes Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/1001 Reviewed-by: AnErrupTion --- build.zig | 11 +- build.zig.zon | 4 + res/config.ini | 4 + res/example.lua | 119 ++++++++++++++++ src/animations/Lua.zig | 302 +++++++++++++++++++++++++++++++++++++++++ src/config/Config.zig | 1 + src/enums.zig | 1 + src/main.zig | 18 +++ 8 files changed, 459 insertions(+), 1 deletion(-) create mode 100644 res/example.lua create mode 100644 src/animations/Lua.zig diff --git a/build.zig b/build.zig index 2de19f7..a3a5f22 100644 --- a/build.zig +++ b/build.zig @@ -71,12 +71,19 @@ pub fn build(b: *std.Build) !void { }), }); + const zlua = b.dependency("zlua", .{ + .target = target, + .optimize = optimize, + .lang = .luajit, + }); + exe.root_module.addImport("zlua", zlua.module("zlua")); + const ly_ui = b.dependency("ly_ui", .{ .target = target, .optimize = optimize, .enable_x11_support = enable_x11_support, .fallback_uid_min = fallback_uid_min, - .fallback_uid_max = fallback_uid_max + .fallback_uid_max = fallback_uid_max, }); exe.root_module.addImport("ly-ui", ly_ui.module("ly-ui")); @@ -189,6 +196,8 @@ fn install_ly(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap, ins try installText(io, patched_setup, config_dir, ly_config_directory, "setup.sh", .{ .permissions = .fromMode(0o755) }); try installFile(io, "res/example.dur", config_dir, ly_config_directory, "example.dur", .{ .permissions = .fromMode(0o755) }); + + try installFile(io, "res/example.lua", config_dir, ly_config_directory, "example.lua", .{ .permissions = .fromMode(0o755) }); } { diff --git a/build.zig.zon b/build.zig.zon index 3c091cb..1d19b69 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -11,6 +11,10 @@ .url = "git+https://github.com/Hejsil/zig-clap#fc1e5cc3f6d9d3001112385ee6256d694e959d2f", .hash = "clap-0.11.0-oBajB7foAQC3Iyn4IVCkUdYaOVVng5IZkSncySTjNig1", }, + .zlua = .{ + .url = "git+https://github.com/natecraddock/ziglua?ref=zig-0.16#8f271c82baa5fc43aa02a72f6da020c2025d9436", + .hash = "zlua-0.1.0-hGRpC2aABQD4D9PBVH3wAW8k32-I4969MRQ0CpOwoley", + }, }, .paths = .{ "build.zig", diff --git a/res/config.ini b/res/config.ini index a290773..169f5ea 100644 --- a/res/config.ini +++ b/res/config.ini @@ -25,6 +25,7 @@ allow_empty_password = true # colormix -> Color mixing shader # gameoflife -> John Conway's Game of Life # dur_file -> .dur file format (https://github.com/cmang/durdraw/tree/master) +# lua -> user-made animation written in LuaJIT animation = none # Delay between each animation frame in milliseconds @@ -298,6 +299,9 @@ login_defs_path = /etc/login.defs # no need to add `exec "$@"` at the end logout_cmd = null +# The file pointing to the Lua file to be used when using the Lua animation option +lua_animation_file = $CONFIG_DIRECTORY/ly/example.lua + # General log file path # If null, syslog will be used instead ly_log = /var/log/ly.log diff --git a/res/example.lua b/res/example.lua new file mode 100644 index 0000000..7309da6 --- /dev/null +++ b/res/example.lua @@ -0,0 +1,119 @@ +-- [[ +-- This is an example of using LuaJIT to create a custom animation in Ly, in this case +-- bouncing squares that change colors. +-- +-- You are given the following `ly` table: +-- { +-- height: number -- The height of the terminal +-- width: number -- The width of the terminal +-- putCell(byte, fg, bg, x, y) -- Draw a cell. +-- All arguments to this function are integers, and +-- must be in the unsigned 32-bit integer range: 0 to 2^32-1. +-- If an argument cannot be converted to this range, it will throw +-- an error. +-- +-- For reference, the XY coordinates (0,0) draw a cell on the top-left +-- of the terminal, where the positive-X axis moves right and the +-- positive-Y axis moves down. +-- +-- For arguments fg and bg: they are colors in the format +-- 0xSSRRGGBB, where SS is for styling. See your +-- config.ini for more details. +-- +-- For the byte argument, you may use string.byte to fill this argument. +-- +-- putCell(byte, fg, bg, x, y, w, h) -- Draw a rectangle. +-- Arguments are the same as putCell except for w and h, which are also +-- unsigned integers. The rectangle will be drawn from the top-left, with +-- argument w extending it to the right and argument h extending downwards. +-- +-- +-- putLabel(str, fg, bg, x, y) -- Draw text in argument str. See putCell() +-- for info on the rest of the arguments. +-- +-- clock() -- The time, in microseconds. +-- } +-- +-- A function named `draw()` must be declared in the script. This is ran every +-- frame. +-- +-- In addition to the base library, you are also given the following standard +-- libraries: +-- bit (A library exclusive to LuaJIT, see https://bitop.luajit.org/api.html) +-- math +-- string +-- table +-- +-- The std libraries io and debug are NOT included. +-- +-- ]] + +-- You should probably copy FPS and FPS_COUNT into any future LuaJIT animations +-- you create. +local FPS_COUNT = 40 +local function FPS() + return (1/FPS_COUNT)*1000000 +end + + +local SQUARE_WIDTH = 10 +local SQUARE_HEIGHT = 5 + +local SQUARE_COUNT = 25 + +local squares = {} + +for i = 1, SQUARE_COUNT do + local vx = 1 + local vy = 1 + if math.random(1, 2) == 2 then vx = -vx end + if math.random(1, 2) == 2 then vy = -vy end + squares[#squares+1] = { + x = math.random(1, ly.width - SQUARE_WIDTH), + y = math.random(1, ly.height - SQUARE_HEIGHT), + vx = vx, + vy = vy, + color = math.random(0xFFFFFF) + } +end + +local timer = ly.clock() +local perf = ly.clock() + +function draw() + -- Rather than progressing the animation by frame, do it based on + -- seconds, via ly.clock(). In this timeframe, you can update the animation + -- state. + -- DO NOT DRAW CELLS IN THIS TIMEFRAME. You will get flickering. + + -- if this check passes, we can update the animation + if timer + FPS() < ly.clock() then + for i, v in ipairs(squares) do + v.x = v.x + v.vx + v.y = v.y + v.vy + if v.x == 0 then + v.vx = 1; v.color = math.random(0xFFFFFF) + end + if v.x + SQUARE_WIDTH >= ly.width-1 then + v.vx = -1; v.color = math.random(0xFFFFFF) + end + if v.y == 0 then + v.vy = 1; v.color = math.random(0xFFFFFF) + end + if v.y + SQUARE_HEIGHT >= ly.height-1 then + v.vy = -1; v.color = math.random(0xFFFFFF) + end + end + timer = ly.clock() + end + + + for i, v in ipairs(squares) do + ly.putRect(string.byte(' '), 0, v.color, v.x, v.y, SQUARE_WIDTH, SQUARE_HEIGHT) + end + + local new_perf = ly.clock() + local str = "FT: "..((new_perf - perf) / 1000).."ms" + ly.putLabel(str , 0x00FFFFFF, 0, (ly.width/2) - (string.len(str)/2), ly.height-1) + perf = new_perf +end diff --git a/src/animations/Lua.zig b/src/animations/Lua.zig new file mode 100644 index 0000000..d212e03 --- /dev/null +++ b/src/animations/Lua.zig @@ -0,0 +1,302 @@ +const std = @import("std"); +const ly_ui = @import("ly-ui"); +const LogFile = ly_ui.ly_core.LogFile; +const Widget = ly_ui.Widget; +const TerminalBuffer = ly_ui.TerminalBuffer; +const Cell = ly_ui.Cell; +const Allocator = std.mem.Allocator; +const InfoLine = @import("../components/InfoLine.zig"); +const Lang = @import("../config/Lang.zig"); + +const zlua = @import("zlua"); + +const ly_lua = @embedFile("ly.lua"); + +const Lua = @This(); + +allocator: Allocator, +instance: ?Widget = null, +lua: *zlua.Lua, +log: *LogFile, +terminal_buffer: *TerminalBuffer, +width: usize, +height: usize, +margin: usize, +io: std.Io, +animation_delay: u16, + +info_line: *InfoLine, +fg: u32, +bg: u32, + +lang: Lang, +full_color: bool, + +lua_error: bool = false, +lua_error_logged: bool = false, +lua_str: ?[:0]const u8 = null, + +pub fn init( + io: std.Io, + alloc: Allocator, + log: *LogFile, + buf: *TerminalBuffer, + file: []const u8, + margin: u8, + animation_delay: u16, + info_line: *InfoLine, + fg: u32, + bg: u32, + lang: Lang, + full_color: bool, +) !Lua { + var self: Lua = .{ + .lua = try zlua.Lua.init(alloc), + .allocator = alloc, + .terminal_buffer = buf, + .instance = null, + .log = log, + .width = 0, + .height = 0, + .margin = margin, + .io = io, + .animation_delay = animation_delay, + .info_line = info_line, + .fg = fg, + .bg = bg, + .lang = lang, + .full_color = full_color, + }; + + // exclude IO and debug libraries + self.lua.openBase(); + self.lua.openBit(); + self.lua.openMath(); + self.lua.openString(); + self.lua.openTable(); + + file_loading: { + const zf = std.mem.concatWithSentinel(alloc, u8, &[1][]const u8{file}, 0) catch |e| { + try self.log.err(self.io, "lua", "failed to allocate file path: {}", .{e}); + self.lua_str = "failed to allocate file path!"; + self.info_line.addMessage(lang.err_alloc, self.bg, self.fg) catch {}; + return e; + }; + defer alloc.free(zf); + + // create the ly table + self.lua.newTable(); + self.lua.setGlobal("ly"); + + // create ly.width and ly.height from TerminalBuffer width/height + self.propagateTerminalBounds(); + + _ = self.lua.getGlobal("ly"); + _ = self.lua.pushString("clock"); + self.lua.pushFunction(luaLyClock); + self.lua.setTable(-3); + _ = self.lua.pushString("putCell"); + self.lua.pushFunction(luaPutCell); + self.lua.setTable(-3); + _ = self.lua.pushString("putLabel"); + self.lua.pushFunction(luaPutLabel); + self.lua.setTable(-3); + _ = self.lua.pushString("putRect"); + self.lua.pushFunction(luaPutRect); + self.lua.setTable(-3); + self.lua.setGlobal("ly"); + + self.lua.doFile(zf) catch { + const errorStr = self.lua.toString(-1) catch unreachable; + self.lua_str = try self.allocator.dupeSentinel(u8, errorStr, 0); + try self.log.err(self.io, "lua", "lua error: {s}", .{errorStr}); + self.lua_error = true; + break :file_loading; + }; + } + + return self; +} + +fn draw(self: *Lua) void { + self.propagateTerminalBounds(); + if (self.lua_error) { + // Ly's Red Screen of Omega-Death:tm: + const RED: u32 = if (self.full_color) TerminalBuffer.Color.TRUE_RED else TerminalBuffer.Color.ECOL_RED; + const cell = Cell.init(0x2588, RED, RED); + for (0..self.terminal_buffer.height) |y| + for (0..self.terminal_buffer.width) |x| + cell.put(x, y) catch {}; + if (self.lua_str) |str| + for (str, 0..) |c, i| { + Cell.init(c, 0x00FFFFFF, 0).put( + @divFloor(self.width, 2) - @divFloor(str.len, 2) + i, + self.margin + 5, + ) catch {}; + }; + if (!self.lua_error_logged) { + self.info_line.addMessage("lua animation failed", self.bg, self.fg) catch {}; + self.lua_error_logged = true; + } + return; + } + + _ = self.lua.getGlobal("draw"); + self.lua.protectedCall(.{}) catch { + const errorStr = self.lua.toString(-1) catch unreachable; + self.lua_str = std.mem.concatWithSentinel( + self.allocator, + u8, + &.{ "cannot call draw(): ", errorStr }, + 0, + ) catch unreachable; + self.log.err(self.io, "lua", "error (cannot call draw()): {s}", .{errorStr}) catch unreachable; + self.lua_error = true; + }; +} + +fn calculateTimeout(self: *Lua, _: *anyopaque) !?usize { + return self.animation_delay; +} + +fn deinit(self: *Lua) void { + if (self.lua_str) |str| self.allocator.free(str); + self.lua.deinit(); +} + +pub fn widget(self: *Lua) *Widget { + if (self.instance) |*inst| return inst; + self.instance = Widget.init( + "Lua", + null, + self, + deinit, + null, + draw, + null, + null, + calculateTimeout, + ); + return &self.instance.?; +} + +fn propagateTerminalBounds(self: *Lua) void { + if (self.terminal_buffer.height == self.height and + self.terminal_buffer.width == self.width) + return; + self.width = self.terminal_buffer.width; + self.height = self.terminal_buffer.height; + _ = self.lua.getGlobal("ly"); + _ = self.lua.pushString("width"); + self.lua.pushInteger(@intCast(self.terminal_buffer.width)); + self.lua.setTable(-3); + _ = self.lua.pushString("height"); + self.lua.pushInteger(@intCast(self.terminal_buffer.height)); + self.lua.setTable(-3); + self.lua.setGlobal("ly"); +} + +fn luaLyClock(state: ?*zlua.LuaState) callconv(.c) c_int { + var threaded = std.Io.Threaded.init_single_threaded; + const lua: *zlua.Lua = @ptrCast(@alignCast(state orelse unreachable)); + lua.pushInteger(std.Io.Timestamp.now(threaded.io(), .real).toMicroseconds()); + return 1; +} + +fn luaPutCell(state: ?*zlua.LuaState) callconv(.c) c_int { + const lua: *zlua.Lua = @ptrCast(@alignCast(state orelse unreachable)); + const MSG = "ly.putCell: cannot convert %s-typed "; + const byte = lua.toNumeric(u32, 1) catch { + const t = lua.typeName(lua.typeOf(1)); + lua.raiseErrorStr(MSG ++ "byte to u32", .{t.ptr}); + }; + const fg = lua.toNumeric(u32, 2) catch { + const t = lua.typeName(lua.typeOf(2)); + lua.raiseErrorStr(MSG ++ "fg to u32", .{t.ptr}); + }; + const bg = lua.toNumeric(u32, 3) catch { + const t = lua.typeName(lua.typeOf(3)); + lua.raiseErrorStr(MSG ++ "bg to u32", .{t.ptr}); + }; + const x = lua.toNumeric(usize, 4) catch { + const t = lua.typeName(lua.typeOf(4)); + lua.raiseErrorStr(MSG ++ "x to usize", .{t.ptr}); + }; + const y = lua.toNumeric(usize, 5) catch { + const t = lua.typeName(lua.typeOf(5)); + lua.raiseErrorStr(MSG ++ "y to usize", .{t.ptr}); + }; + TerminalBuffer.setCell(x, y, .{ + .fg = fg, + .bg = bg, + .ch = byte, + }) catch {}; + return 0; +} + +fn luaPutRect(state: ?*zlua.LuaState) callconv(.c) c_int { + const lua: *zlua.Lua = @ptrCast(@alignCast(state orelse unreachable)); + const MSG = "ly.putRect: cannot convert %s-typed "; + const byte = lua.toNumeric(u32, 1) catch { + const t = lua.typeName(lua.typeOf(1)); + lua.raiseErrorStr(MSG ++ "byte to u32", .{t.ptr}); + }; + const fg = lua.toNumeric(u32, 2) catch { + const t = lua.typeName(lua.typeOf(2)); + lua.raiseErrorStr(MSG ++ "fg to u32", .{t.ptr}); + }; + const bg = lua.toNumeric(u32, 3) catch { + const t = lua.typeName(lua.typeOf(3)); + lua.raiseErrorStr(MSG ++ "bg to u32", .{t.ptr}); + }; + const x = lua.toNumeric(usize, 4) catch { + const t = lua.typeName(lua.typeOf(4)); + lua.raiseErrorStr(MSG ++ "x to usize", .{t.ptr}); + }; + const y = lua.toNumeric(usize, 5) catch { + const t = lua.typeName(lua.typeOf(5)); + lua.raiseErrorStr(MSG ++ "y to usize", .{t.ptr}); + }; + const w = lua.toNumeric(usize, 6) catch { + const t = lua.typeName(lua.typeOf(5)); + lua.raiseErrorStr(MSG ++ "w to usize", .{t.ptr}); + }; + const h = lua.toNumeric(usize, 7) catch { + const t = lua.typeName(lua.typeOf(5)); + lua.raiseErrorStr(MSG ++ "h to usize", .{t.ptr}); + }; + for (0..w) |wx| for (0..h) |hy| + TerminalBuffer.setCell(x + wx, y + hy, .{ + .fg = fg, + .bg = bg, + .ch = byte, + }) catch {}; + return 0; +} + +fn luaPutLabel(state: ?*zlua.LuaState) callconv(.c) c_int { + const lua: *zlua.Lua = @ptrCast(@alignCast(state orelse unreachable)); + const MSG = "ly.putLabel: cannot convert %s-typed "; + const str = lua.toString(1) catch { + const t = lua.typeName(lua.typeOf(2)); + lua.raiseErrorStr(MSG ++ "str to string", .{t.ptr}); + }; + const fg = lua.toNumeric(u32, 2) catch { + const t = lua.typeName(lua.typeOf(2)); + lua.raiseErrorStr(MSG ++ "fg to u32", .{t.ptr}); + }; + const bg = lua.toNumeric(u32, 3) catch { + const t = lua.typeName(lua.typeOf(3)); + lua.raiseErrorStr(MSG ++ "bg to u32", .{t.ptr}); + }; + const x = lua.toNumeric(usize, 4) catch { + const t = lua.typeName(lua.typeOf(4)); + lua.raiseErrorStr(MSG ++ "x to usize", .{t.ptr}); + }; + const y = lua.toNumeric(usize, 5) catch { + const t = lua.typeName(lua.typeOf(5)); + lua.raiseErrorStr(MSG ++ "y to usize", .{t.ptr}); + }; + TerminalBuffer.drawText(str, x, y, fg, bg) catch {}; + return 0; +} diff --git a/src/config/Config.zig b/src/config/Config.zig index a592faa..b7b258b 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -74,6 +74,7 @@ lang: []const u8 = "en", login_cmd: ?[]const u8 = null, login_defs_path: []const u8 = "/etc/login.defs", logout_cmd: ?[]const u8 = null, +lua_animation_file: []const u8 = build_options.config_directory ++ "/ly/example.lua", ly_log: ?[]const u8 = "/var/log/ly.log", margin_box_h: u8 = 2, margin_box_v: u8 = 1, diff --git a/src/enums.zig b/src/enums.zig index 47771da..ff69f84 100644 --- a/src/enums.zig +++ b/src/enums.zig @@ -7,6 +7,7 @@ pub const Animation = enum { colormix, gameoflife, dur_file, + lua, }; pub const DisplayServer = enum { diff --git a/src/main.zig b/src/main.zig index 887ec41..41ba15d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -29,6 +29,7 @@ const Doom = @import("animations/Doom.zig"); const DurFile = @import("animations/DurFile.zig"); const GameOfLife = @import("animations/GameOfLife.zig"); const Matrix = @import("animations/Matrix.zig"); +const Lua = @import("animations/Lua.zig"); const auth = @import("auth.zig"); const InfoLine = @import("components/InfoLine.zig"); const Session = @import("components/Session.zig"); @@ -1093,6 +1094,23 @@ pub fn main(init: std.process.Init) !void { ); animation = dur.widget(); }, + .lua => { + var lua = try Lua.init( + state.io, + state.allocator, + &state.log_file, + &state.buffer, + state.config.lua_animation_file, + state.config.edge_margin, + state.config.animation_frame_delay, + &state.info_line, + state.config.error_fg, + state.config.error_bg, + state.lang, + state.config.full_color, + ); + animation = lua.widget(); + }, } defer if (animation) |a| a.deinit(); From 4d882f7997102b9b3f34154367587a04faad1e11 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 19 Jun 2026 20:18:45 +0200 Subject: [PATCH 46/77] Fix example.lua doc + add ly-community in README Signed-off-by: AnErrupTion --- readme.md | 4 +++ res/example.lua | 96 ++++++++++++++++++++++++------------------------- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/readme.md b/readme.md index 620929e..d5ea1fc 100644 --- a/readme.md +++ b/readme.md @@ -56,6 +56,10 @@ Join us on Matrix over at [#ly-dm:matrix.org](https://matrix.to/#/#ly-dm:matrix. [![Packaging status](https://repology.org/badge/vertical-allrepos/ly-display-manager.svg?exclude_unsupported=1)](https://repology.org/project/ly-display-manager/versions) +## Custom animations & user scripts + +If you want to pimp your Ly installation even further than what the traditional configuration file allows you to, a [community repository](https://codeberg.org/fairyglade/ly-community) exists containing custom animations & scripts, so go check it out! + ## Support Every environment that works on other login managers also should work on Ly. diff --git a/res/example.lua b/res/example.lua index 7309da6..81f9bc9 100644 --- a/res/example.lua +++ b/res/example.lua @@ -6,13 +6,13 @@ -- { -- height: number -- The height of the terminal -- width: number -- The width of the terminal --- putCell(byte, fg, bg, x, y) -- Draw a cell. --- All arguments to this function are integers, and +-- putCell(byte, fg, bg, x, y) -- Draw a cell. +-- All arguments to this function are integers, and -- must be in the unsigned 32-bit integer range: 0 to 2^32-1. -- If an argument cannot be converted to this range, it will throw -- an error. -- --- For reference, the XY coordinates (0,0) draw a cell on the top-left +-- For reference, the XY coordinates (0,0) draw a cell on the top-left -- of the terminal, where the positive-X axis moves right and the -- positive-Y axis moves down. -- @@ -22,7 +22,7 @@ -- -- For the byte argument, you may use string.byte to fill this argument. -- --- putCell(byte, fg, bg, x, y, w, h) -- Draw a rectangle. +-- putRect(byte, fg, bg, x, y, w, h) -- Draw a rectangle. -- Arguments are the same as putCell except for w and h, which are also -- unsigned integers. The rectangle will be drawn from the top-left, with -- argument w extending it to the right and argument h extending downwards. @@ -45,14 +45,14 @@ -- table -- -- The std libraries io and debug are NOT included. --- +-- -- ]] -- You should probably copy FPS and FPS_COUNT into any future LuaJIT animations -- you create. local FPS_COUNT = 40 local function FPS() - return (1/FPS_COUNT)*1000000 + return (1 / FPS_COUNT) * 1000000 end @@ -64,56 +64,56 @@ local SQUARE_COUNT = 25 local squares = {} for i = 1, SQUARE_COUNT do - local vx = 1 - local vy = 1 - if math.random(1, 2) == 2 then vx = -vx end - if math.random(1, 2) == 2 then vy = -vy end - squares[#squares+1] = { - x = math.random(1, ly.width - SQUARE_WIDTH), - y = math.random(1, ly.height - SQUARE_HEIGHT), - vx = vx, - vy = vy, - color = math.random(0xFFFFFF) - } + local vx = 1 + local vy = 1 + if math.random(1, 2) == 2 then vx = -vx end + if math.random(1, 2) == 2 then vy = -vy end + squares[#squares + 1] = { + x = math.random(1, ly.width - SQUARE_WIDTH), + y = math.random(1, ly.height - SQUARE_HEIGHT), + vx = vx, + vy = vy, + color = math.random(0xFFFFFF) + } end local timer = ly.clock() local perf = ly.clock() function draw() - -- Rather than progressing the animation by frame, do it based on - -- seconds, via ly.clock(). In this timeframe, you can update the animation - -- state. - -- DO NOT DRAW CELLS IN THIS TIMEFRAME. You will get flickering. + -- Rather than progressing the animation by frame, do it based on + -- seconds, via ly.clock(). In this timeframe, you can update the animation + -- state. + -- DO NOT DRAW CELLS IN THIS TIMEFRAME. You will get flickering. - -- if this check passes, we can update the animation - if timer + FPS() < ly.clock() then - for i, v in ipairs(squares) do - v.x = v.x + v.vx - v.y = v.y + v.vy - if v.x == 0 then - v.vx = 1; v.color = math.random(0xFFFFFF) - end - if v.x + SQUARE_WIDTH >= ly.width-1 then - v.vx = -1; v.color = math.random(0xFFFFFF) - end - if v.y == 0 then - v.vy = 1; v.color = math.random(0xFFFFFF) - end - if v.y + SQUARE_HEIGHT >= ly.height-1 then - v.vy = -1; v.color = math.random(0xFFFFFF) - end - end - timer = ly.clock() - end + -- if this check passes, we can update the animation + if timer + FPS() < ly.clock() then + for i, v in ipairs(squares) do + v.x = v.x + v.vx + v.y = v.y + v.vy + if v.x == 0 then + v.vx = 1; v.color = math.random(0xFFFFFF) + end + if v.x + SQUARE_WIDTH >= ly.width - 1 then + v.vx = -1; v.color = math.random(0xFFFFFF) + end + if v.y == 0 then + v.vy = 1; v.color = math.random(0xFFFFFF) + end + if v.y + SQUARE_HEIGHT >= ly.height - 1 then + v.vy = -1; v.color = math.random(0xFFFFFF) + end + end + timer = ly.clock() + end - for i, v in ipairs(squares) do - ly.putRect(string.byte(' '), 0, v.color, v.x, v.y, SQUARE_WIDTH, SQUARE_HEIGHT) - end + for i, v in ipairs(squares) do + ly.putRect(string.byte(' '), 0, v.color, v.x, v.y, SQUARE_WIDTH, SQUARE_HEIGHT) + end - local new_perf = ly.clock() - local str = "FT: "..((new_perf - perf) / 1000).."ms" - ly.putLabel(str , 0x00FFFFFF, 0, (ly.width/2) - (string.len(str)/2), ly.height-1) - perf = new_perf + local new_perf = ly.clock() + local str = "FT: " .. ((new_perf - perf) / 1000) .. "ms" + ly.putLabel(str, 0x00FFFFFF, 0, (ly.width / 2) - (string.len(str) / 2), ly.height - 1) + perf = new_perf end From 8f4ca8d3f0b4cfbc6e6aa063ece1a4f0c4c6f218 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 3 Jul 2026 18:33:58 +0200 Subject: [PATCH 47/77] Autologin: Don't draw info line (closes #1002) Signed-off-by: AnErrupTion --- src/main.zig | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/main.zig b/src/main.zig index 41ba15d..0e57d41 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1483,6 +1483,32 @@ fn authenticate(ptr: *anyopaque) !bool { state.config.error_bg, state.config.error_fg, ); + if (!state.is_autologin) { + state.info_line.clearRendered(state.allocator) catch |err| { + try state.info_line.addMessage( + state.lang.err_alloc, + state.config.error_bg, + state.config.error_fg, + ); + try state.log_file.err( + state.io, + "tui", + "failed to clear info line: {s}", + .{@errorName(err)}, + ); + }; + state.info_line.label.draw(); + try TerminalBuffer.presentBuffer(); + } + return false; + } + + try state.info_line.addMessage( + state.lang.authenticating, + state.config.bg, + state.config.fg, + ); + if (!state.is_autologin) { state.info_line.clearRendered(state.allocator) catch |err| { try state.info_line.addMessage( state.lang.err_alloc, @@ -1498,30 +1524,8 @@ fn authenticate(ptr: *anyopaque) !bool { }; state.info_line.label.draw(); try TerminalBuffer.presentBuffer(); - return false; } - try state.info_line.addMessage( - state.lang.authenticating, - state.config.bg, - state.config.fg, - ); - state.info_line.clearRendered(state.allocator) catch |err| { - try state.info_line.addMessage( - state.lang.err_alloc, - state.config.error_bg, - state.config.error_fg, - ); - try state.log_file.err( - state.io, - "tui", - "failed to clear info line: {s}", - .{@errorName(err)}, - ); - }; - state.info_line.label.draw(); - try TerminalBuffer.presentBuffer(); - if (state.config.save) save_last_settings: { // It isn't worth cluttering the code with precise error // handling, so let's just report a generic error message, From 63f0f4931c31d3e7ed4c381a5201c313d568e634 Mon Sep 17 00:00:00 2001 From: Tim132 Date: Fri, 3 Jul 2026 18:37:40 +0200 Subject: [PATCH 48/77] Fix authentication error with ly-freebsd-autologin (#1020) ## What are the changes about? Remove the line "auth include login" from ly-freebsd-autologin ## What existing issue does this resolve? The autologin at the beginning and further logins with password always failed with this message in the log: "failed to authenticate: PamAuthError". When I removed the line "auth include login" from ly-freebsd-autologin, autologin and login worked great. ## Pre-requisites - [X] I have tested & confirmed the changes work locally - [X] I have read and fully adhere to the rules set in the contributing guidelines found in `CONTRIBUTING.md` Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/1020 Reviewed-by: AnErrupTion --- res/pam.d/ly-freebsd-autologin | 1 - 1 file changed, 1 deletion(-) diff --git a/res/pam.d/ly-freebsd-autologin b/res/pam.d/ly-freebsd-autologin index e2448ad..b6f56e3 100644 --- a/res/pam.d/ly-freebsd-autologin +++ b/res/pam.d/ly-freebsd-autologin @@ -3,7 +3,6 @@ # OpenPAM (used in FreeBSD) doesn't support prepending "-" for ignoring missing # modules. auth required pam_permit.so -auth include login account include login password include login session include login From 1d272ff74fd2f34fee61eee61a4c781e4b1622e8 Mon Sep 17 00:00:00 2001 From: dumbsplash Date: Sun, 5 Jul 2026 20:59:40 +0200 Subject: [PATCH 49/77] Updated readme to address SELinux problems (closes #494) (#1019) PR is an edit of the repo readme. See commit message. Co-authored-by: AnErrupTion Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/1019 Reviewed-by: AnErrupTion --- readme.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index d5ea1fc..33ef70b 100644 --- a/readme.md +++ b/readme.md @@ -39,13 +39,38 @@ Join us on Matrix over at [#ly-dm:matrix.org](https://matrix.to/#/#ly-dm:matrix. ### Fedora -> [!WARNING] -> You may encounter issues with SELinux on Fedora. It is recommended to add a rule for Ly as it currently does not ship one. - ``` # dnf install kernel-devel pam-devel libxcb-devel zig xorg-x11-xauth xorg-x11-server brightnessctl ``` +> [!WARNING] +> Distributions using SELinux such as Fedora and openSUSE Tumbleweed may encounter issues. If you encounter such issues, such as session launch failures, proceed with the following steps: +> +> ``` +> # ausearch -m avc -ts recent +> ``` +> +> If SELinux is denying process context transition, you will see this output: +> +> ``` +> denied { transition } for pid=XXXX comm="ly" path="/usr/bin/bash" +> scontext=system_u:system_r:unconfined_service_t:s0 +> tcontext=unconfined_u:unconfined_r:unconfined_t:s0 +> tclass=process permissive=0 +> ``` +> +> Pipe this output into `audit2allow` to generate a security module package. This will persist regardless of changes to filesystem permissions: +> +> ``` +> # ausearch -m avc -ts recent | audit2allow -M ly-local +> ``` +> +> ``` +> # semodule -i ly-local.pp +> ``` +> +> *This fix has been confirmed on Fedora 39 and 44 and openSUSE Tumbleweed. (#494)* + ### FreeBSD ``` From cf731dbce13bd5c07c58086b9cbcec14acf4af48 Mon Sep 17 00:00:00 2001 From: Lars Engels Date: Sun, 5 Jul 2026 21:19:30 +0200 Subject: [PATCH 50/77] Add battery capacity support on FreeBSD (#988) ## What are the changes about? So far ly only supported showing battery capacity on Linux. This adds support for FreeBSD as well using `sysctlbyname()` instead of reading from `/sys/...` ## What existing issue does this resolve? No battery shown on FreeBSD. _Replace this with a reference to an existing issue, or N/A if there is none_ ## Pre-requisites - [x] I have tested & confirmed the changes work locally - [x] I have run `zig fmt` throughout my changes Co-authored-by: AnErrupTion Co-authored-by: AnErrupTion Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/988 Reviewed-by: AnErrupTion --- ly-core/build.zig | 1 + ly-core/src/interop.zig | 3 +++ res/config.ini | 1 + src/main.zig | 33 ++++++++++++++++++++++++--------- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ly-core/build.zig b/ly-core/build.zig index cf0dbf8..75ecb3f 100644 --- a/ly-core/build.zig +++ b/ly-core/build.zig @@ -51,6 +51,7 @@ pub fn build(b: *std.Build) void { } else if (target.result.os.tag == .freebsd) { addCImport(b, mod, translate_c, target, optimize, "kbio", "#include "); addCImport(b, mod, translate_c, target, optimize, "consio", "#include "); + addCImport(b, mod, translate_c, target, optimize, "sysctl", "#include "); } const mod_tests = b.addTest(.{ diff --git a/ly-core/src/interop.zig b/ly-core/src/interop.zig index 7d09381..736d8ca 100644 --- a/ly-core/src/interop.zig +++ b/ly-core/src/interop.zig @@ -14,6 +14,9 @@ pub const utmp = @import("utmp"); // Exists for X11 support only pub const xcb = @import("xcb"); +// FreeBSD only +pub const sysctl = @import("sysctl"); + pub const TimeOfDay = struct { seconds: i64, microseconds: i64, diff --git a/res/config.ini b/res/config.ini index 169f5ea..4269e7f 100644 --- a/res/config.ini +++ b/res/config.ini @@ -50,6 +50,7 @@ auth_fails = 10 # Identifier for battery whose charge to display at top left # Primary battery is usually BAT0 or BAT1 # If set to null, battery status won't be shown +# Unused on FreeBSD (a sysctl is used there) battery_id = null # Automatic login configuration diff --git a/src/main.zig b/src/main.zig index 0e57d41..91f3af8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2340,19 +2340,34 @@ fn adjustBrightness(io: std.Io, cmd: []const u8) !void { } fn getBatteryPercentage(io: std.Io, battery_id: []const u8) !u8 { - const path = try std.fmt.allocPrint(temporary_allocator, "/sys/class/power_supply/{s}/capacity", .{battery_id}); - defer temporary_allocator.free(path); + if (builtin.os.tag == .freebsd) { + // battery_id is unused on FreeBSD; sysctl exposes a single aggregate value. + // For multi-battery systems the MIB would be hw.acpi.battery.N.life, + // but hw.acpi.battery.life is the standard single-battery interface. + var capacity: c_int = -1; + var size: usize = @sizeOf(c_int); - const battery_file = try std.Io.Dir.cwd().openFile(io, path, .{}); - defer battery_file.close(io); + const ret = interop.sysctl.sysctlbyname("hw.acpi.battery.life", &capacity, &size, null, 0); - var buffer: [8]u8 = undefined; - const bytes_read = try battery_file.readStreaming(io, &.{&buffer}); - const capacity_str = buffer[0..bytes_read]; + if (ret != 0) return error.SysctlFailed; + if (capacity < 0 or capacity > 100) return error.InvalidBatteryCapacity; - const trimmed = std.mem.trimEnd(u8, capacity_str, "\n\r"); + return @intCast(capacity); + } else { + const path = try std.fmt.allocPrint(temporary_allocator, "/sys/class/power_supply/{s}/capacity", .{battery_id}); + defer temporary_allocator.free(path); - return try std.fmt.parseInt(u8, trimmed, 10); + const battery_file = try std.Io.Dir.cwd().openFile(io, path, .{}); + defer battery_file.close(io); + + var buffer: [8]u8 = undefined; + const bytes_read = try battery_file.readStreaming(io, &.{&buffer}); + const capacity_str = buffer[0..bytes_read]; + + const trimmed = std.mem.trimEnd(u8, capacity_str, "\n\r"); + + return try std.fmt.parseInt(u8, trimmed, 10); + } } fn getAuthErrorMsg(err: anyerror, lang: Lang) []const u8 { From 006749b2ecb706826da1c62efd0a741b2440ea96 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sun, 5 Jul 2026 21:20:02 +0200 Subject: [PATCH 51/77] Format README Signed-off-by: AnErrupTion --- readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index 33ef70b..8c554fd 100644 --- a/readme.md +++ b/readme.md @@ -45,31 +45,31 @@ Join us on Matrix over at [#ly-dm:matrix.org](https://matrix.to/#/#ly-dm:matrix. > [!WARNING] > Distributions using SELinux such as Fedora and openSUSE Tumbleweed may encounter issues. If you encounter such issues, such as session launch failures, proceed with the following steps: -> +> > ``` > # ausearch -m avc -ts recent > ``` > > If SELinux is denying process context transition, you will see this output: -> +> > ``` > denied { transition } for pid=XXXX comm="ly" path="/usr/bin/bash" > scontext=system_u:system_r:unconfined_service_t:s0 > tcontext=unconfined_u:unconfined_r:unconfined_t:s0 > tclass=process permissive=0 > ``` -> +> > Pipe this output into `audit2allow` to generate a security module package. This will persist regardless of changes to filesystem permissions: -> +> > ``` > # ausearch -m avc -ts recent | audit2allow -M ly-local > ``` -> +> > ``` > # semodule -i ly-local.pp > ``` -> -> *This fix has been confirmed on Fedora 39 and 44 and openSUSE Tumbleweed. (#494)* +> +> _This fix has been confirmed on Fedora 39 and 44 and openSUSE Tumbleweed. (#494)_ ### FreeBSD From 25fad28c341d5385b8ecdd74ef4667e79f6a4b12 Mon Sep 17 00:00:00 2001 From: HigherOrderLogic Date: Sun, 5 Jul 2026 22:43:15 +0200 Subject: [PATCH 52/77] Add `type_username` option (closes #891) (#1012) ## What are the changes about? Add an option to allow user manually input username, instead of selecting from a list of discovered users. I have not tested the changes yet since I wasnt able to get it build locally. Will try to resolve this asap. ## What existing issue does this resolve? #891 ## Pre-requisites - [ ] I have tested & confirmed the changes work locally - [x] I have run `zig fmt` throughout my changes Co-authored-by: HigherOrderLogic <73709188+HigherOrderLogic@users.noreply.github.com> Co-authored-by: AnErrupTion Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/1012 Reviewed-by: AnErrupTion --- ly-ui/src/components/Text.zig | 4 + res/config.ini | 4 + src/components/Session.zig | 14 ++-- src/config/Config.zig | 1 + src/main.zig | 137 +++++++++++++++++++++++++--------- 5 files changed, 119 insertions(+), 41 deletions(-) diff --git a/ly-ui/src/components/Text.zig b/ly-ui/src/components/Text.zig index b4aad21..875021a 100644 --- a/ly-ui/src/components/Text.zig +++ b/ly-ui/src/components/Text.zig @@ -144,6 +144,10 @@ pub fn handle(self: *Text, maybe_key: ?keyboard.Key) !void { ); } +pub fn writeText(self: *Text, str: []const u8) !void { + for (str) |c| try self.write(c); +} + fn draw(self: *Text) void { if (self.masked) { if (self.maybe_mask) |mask| { diff --git a/res/config.ini b/res/config.ini index 4269e7f..a6f5d65 100644 --- a/res/config.ini +++ b/res/config.ini @@ -375,6 +375,10 @@ start_cmd = $CONFIG_DIRECTORY/ly/startup.sh # Center the session name. text_in_center = false +# If true, user will need to manually type username instead of selecting from the list +# of discovered users +type_username = false + # Default vi mode # normal -> normal mode # insert -> insert mode diff --git a/src/components/Session.zig b/src/components/Session.zig index 6cb252a..fe8c498 100644 --- a/src/components/Session.zig +++ b/src/components/Session.zig @@ -14,19 +14,19 @@ const Env = struct { environment: Environment, index: usize, }; -const EnvironmentLabel = CyclableLabel(Env, *UserList); +const EnvironmentLabel = CyclableLabel(Env, *?UserList); const Session = @This(); instance: ?Widget = null, label: *EnvironmentLabel, -user_list: *UserList, +user_list: *?UserList, pub fn init( allocator: Allocator, io: std.Io, buffer: *TerminalBuffer, - user_list: *UserList, + user_list: *?UserList, width: usize, text_in_center: bool, fg: u32, @@ -79,7 +79,7 @@ pub fn addEnvironment(self: *Session, environment: Environment) !void { const env = Env{ .environment = environment, .index = self.label.list.items.len }; try self.label.addItem(env); - addedSession(env, self.user_list); + if (self.user_list.*) |w| addedSession(env, w); } fn draw(self: *Session) void { @@ -90,16 +90,16 @@ fn handle(self: *Session, maybe_key: ?keyboard.Key) !void { try self.label.handle(maybe_key); } -fn addedSession(env: Env, user_list: *UserList) void { +fn addedSession(env: Env, user_list: UserList) void { const user = user_list.label.list.items[user_list.label.current]; if (!user.first_run) return; user.session_index.* = env.index; } -fn sessionChanged(env: Env, maybe_user_list: ?*UserList) void { +fn sessionChanged(env: Env, maybe_user_list: ?*?UserList) void { if (maybe_user_list) |user_list| { - user_list.label.list.items[user_list.label.current].session_index.* = env.index; + if (user_list.*) |w| w.label.list.items[w.label.current].session_index.* = env.index; } } diff --git a/src/config/Config.zig b/src/config/Config.zig index b7b258b..85d3ea1 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -95,6 +95,7 @@ sleep_cmd: ?[]const u8 = null, sleep_key: []const u8 = "F3", start_cmd: ?[]const u8 = null, text_in_center: bool = false, +type_username: bool = false, vi_default_mode: ViMode = .normal, vi_mode: bool = false, waylandsessions: ?[]const u8 = build_options.prefix_directory ++ "/share/wayland-sessions", diff --git a/src/main.zig b/src/main.zig index 91f3af8..5d4b074 100644 --- a/src/main.zig +++ b/src/main.zig @@ -107,8 +107,10 @@ const UiState = struct { info_line: InfoLine, animate: bool, session: Session, + saved_username: ?[]const u8, saved_users: SavedUsers, - login: UserList, + login: ?UserList, + login_text: ?*Text, password: *Text, password_widget: *Widget, insert_mode: bool, @@ -295,6 +297,7 @@ pub fn main(init: std.process.Init) !void { } state.has_old_save = false; + state.saved_username = null; if (state.config.save) read_save_file: { old_save_parser = migrator.tryMigrateIniSaveFile(state.allocator, state.io, state.old_save_path, &state.saved_users, usernames.items) catch break :read_save_file; @@ -312,8 +315,19 @@ pub fn main(init: std.process.Init) !void { var file_reader = save_file.reader(state.io, &file_buffer); var reader = &file_reader.interface; - const last_username_index_str = reader.takeDelimiterInclusive('\n') catch break :read_save_file; - state.saved_users.last_username_index = std.fmt.parseInt(usize, last_username_index_str[0..(last_username_index_str.len - 1)], 10) catch break :read_save_file; + const username_line = reader.takeDelimiterInclusive('\n') catch break :read_save_file; + + if (std.mem.containsAtLeastScalar2(u8, username_line, '-', 1)) read_username: { + var iterator = std.mem.splitScalar(u8, username_line[0..(username_line.len - 1)], '-'); + if (iterator.next() == null) break :read_username; // Would be index + + const maybe_username = iterator.next(); + if (maybe_username) |username| { + state.saved_username = try state.allocator.dupe(u8, username); + } + } else if (!state.config.type_username) { + state.saved_users.last_username_index = std.fmt.parseInt(usize, username_line[0..(username_line.len - 1)], 10) catch break :read_save_file; + } while (reader.seek < reader.buffer.len) { const line = reader.takeDelimiterInclusive('\n') catch break; @@ -763,22 +777,25 @@ pub fn main(init: std.process.Init) !void { ); defer state.login_label.deinit(); - state.login = try UserList.init( - state.allocator, - state.io, - &state.buffer, - usernames, - &state.saved_users, - &state.session, - state.box.width - 2 * state.box.horizontal_margin - state.labels_max_length - 1, - state.config.text_in_center, - state.buffer.fg, - state.buffer.bg, - ); - defer state.login.deinit(); + state.login = null; + if (!state.config.type_username) { + state.login = try UserList.init( + state.allocator, + state.io, + &state.buffer, + usernames, + &state.saved_users, + &state.session, + state.box.width - 2 * state.box.horizontal_margin - state.labels_max_length - 1, + state.config.text_in_center, + state.buffer.fg, + state.buffer.bg, + ); - try state.buffer.registerKeybind(state.io, &state.login.label.keybinds, "H", &viGoLeft, &state); - try state.buffer.registerKeybind(state.io, &state.login.label.keybinds, "L", &viGoRight, &state); + try state.buffer.registerKeybind(state.io, &state.login.?.label.keybinds, "H", &viGoLeft, &state); + try state.buffer.registerKeybind(state.io, &state.login.?.label.keybinds, "L", &viGoRight, &state); + } + defer if (state.login) |*w| w.deinit(); if (state.config.shell) { addOtherEnvironment(&state.session, state.lang, .shell, null) catch |err| { @@ -887,7 +904,7 @@ pub fn main(init: std.process.Init) !void { // This effectively means you can't login, since there would be no local // accounts *and* no root account...but at this point, if that's the // case, you have bigger problems to deal with in the first place. :D - try state.info_line.addMessage(state.lang.err_no_users, state.config.error_bg, state.config.error_fg); + if (!state.config.type_username) try state.info_line.addMessage(state.lang.err_no_users, state.config.error_bg, state.config.error_fg); try state.log_file.err(state.io, "sys", "no users found", .{}); } @@ -920,6 +937,22 @@ pub fn main(init: std.process.Init) !void { try state.buffer.registerKeybind(state.io, &state.password.keybinds, "L", &viGoRight, &state); state.password_widget = state.password.widget(); + state.login_text = null; + + if (state.config.type_username) { + state.login_text = try Text.init( + state.allocator, + state.io, + &state.buffer, + state.insert_mode, + false, + null, + state.box.width - 2 * state.box.horizontal_margin - state.labels_max_length - 1, + state.buffer.fg, + state.buffer.bg, + ); + } + defer if (state.login_text) |lt| lt.deinit(); state.version_label = Label.init( ly_version_str, @@ -974,13 +1007,18 @@ pub fn main(init: std.process.Init) !void { ); state.session.label.current = session_index; - for (state.login.label.list.items, 0..) |username, i| { - if (std.mem.eql(u8, username.name, auto_user)) { - state.login.label.current = i; - break; + state.is_autologin = true; + + if (state.login_text) |box| { + try box.writeText(auto_user); + } else { + for (state.login.?.label.list.items, 0..) |username, i| { + if (std.mem.eql(u8, username.name, auto_user)) { + state.login.?.label.current = i; + break; + } } } - state.is_autologin = true; } // Switch to selected TTY @@ -1133,7 +1171,22 @@ pub fn main(init: std.process.Init) !void { var default_input = state.config.default_input; if (state.config.save and !state.is_autologin) { - if (state.saved_users.last_username_index) |index| load_last_user: { + if (state.login_text) |box| { + if (state.saved_username) |username| { + defer state.allocator.free(username); + + try box.writeText(username); + + default_input = .password; + + for (state.saved_users.user_list.items) |user| { + if (std.mem.eql(u8, username, user.username)) { + state.session.label.current = @min(user.session_index, state.session.label.list.items.len - 1); + break; + } + } + } + } else if (state.saved_users.last_username_index) |index| load_last_user: { // If the saved index isn't valid, bail out if (index >= state.saved_users.user_list.items.len) break :load_last_user; @@ -1143,7 +1196,7 @@ pub fn main(init: std.process.Init) !void { // If it doesn't exist (anymore), we don't change the value for (usernames.items, 0..) |username, i| { if (std.mem.eql(u8, username, user.username)) { - state.login.label.current = i; + state.login.?.label.current = i; break; } } @@ -1156,7 +1209,7 @@ pub fn main(init: std.process.Init) !void { const info_line_widget = state.info_line.widget(); const session_widget = state.session.widget(); - const login_widget = state.login.widget(); + const login_widget = if (state.config.type_username) state.login_text.?.widget() else state.login.?.widget(); var widgets: std.ArrayList([]*Widget) = .empty; defer widgets.deinit(state.allocator); @@ -1400,6 +1453,7 @@ fn disableInsertMode(ptr: *anyopaque) !bool { if (state.config.vi_mode and state.insert_mode) { state.insert_mode = false; state.password.should_insert = false; + if (state.login_text) |lt| lt.should_insert = false; state.buffer.drawNextFrame(true); } return false; @@ -1411,6 +1465,7 @@ fn enableInsertMode(ptr: *anyopaque) !bool { state.insert_mode = true; state.password.should_insert = true; + if (state.login_text) |lt| lt.should_insert = true; state.buffer.drawNextFrame(true); return false; } @@ -1552,7 +1607,11 @@ fn authenticate(ptr: *anyopaque) !bool { var file_writer = file.writer(state.io, &file_buffer); var writer = &file_writer.interface; - try writer.print("{d}\n", .{state.login.label.current}); + if (state.login_text) |box| { + try writer.print("0-{s}\n", .{box.text.items}); + } else { + try writer.print("{d}\n", .{state.login.?.label.current}); + } for (state.saved_users.user_list.items) |user| { try writer.print("{s}:{d}\n", .{ user.username, user.session_index }); } @@ -1610,7 +1669,7 @@ fn authenticate(ptr: *anyopaque) !bool { &state.log_file, auth_options, current_environment, - state.login.getCurrentUsername(), + if (state.login_text) |box| box.text.items else state.login.?.getCurrentUsername(), password_text, ) catch |err| { shared_err.writeError(err); @@ -2135,12 +2194,22 @@ fn positionWidgets(ptr: *anyopaque) !void { .childrenPosition() .resetXFrom(state.info_line.label.childrenPosition()) .addY(1)); - state.login.label.positionY(state.login_label - .childrenPosition() - .addX(state.labels_max_length - TerminalBuffer.strWidth(state.login_label.text) + 1)); + if (state.login_text) |box| { + box.positionY(state.login_label + .childrenPosition() + .addX(state.labels_max_length - TerminalBuffer.strWidth(state.login_label.text) + 1)); + } else { + state.login.?.label.positionY(state.login_label + .childrenPosition() + .addX(state.labels_max_length - TerminalBuffer.strWidth(state.login_label.text) + 1)); + } - state.password_label.positionX(state.login.label - .childrenPosition() + const login_children_pos = if (state.login_text) |box| + box.childrenPosition() + else + state.login.?.label.childrenPosition(); + + state.password_label.positionX(login_children_pos .resetXFrom(state.info_line.label.childrenPosition()) .addY(1)); state.password.positionY(state.password_label From e0c287306ee280d057d0b3f5d46504c1882025ee Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 5 Jul 2026 23:22:03 +0200 Subject: [PATCH 53/77] feature: add corner customization (closes #961) (#963) ## What are the changes about? Add corner customization (what is in which corner of the screen) ## What existing issue does this resolve? Issue #961 ## Pre-requisites - [x] I have tested & confirmed the changes work locally - [x] I have run `zig fmt` throughout my changes Co-authored-by: AnErrupTion Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/963 Reviewed-by: AnErrupTion --- res/config.ini | 28 ++++ src/config/Config.zig | 4 + src/main.zig | 363 ++++++++++++++++++++++++++++++++---------- 3 files changed, 315 insertions(+), 80 deletions(-) diff --git a/res/config.ini b/res/config.ini index a6f5d65..c57c7f4 100644 --- a/res/config.ini +++ b/res/config.ini @@ -153,6 +153,34 @@ colormix_col2 = 0x000000FF # Color mixing animation third color id colormix_col3 = 0x20000000 +# Screen corners customization +# Keywords: +# keys -> Power management keys (shutdown, restart, etc.) +# clock -> Clock (format defined by 'clock' option) +# tty -> Active TTY number +# battery -> Battery percentage +# version -> Ly version string +# numlock -> Numlock state +# capslock -> Capslock state +# labels -> All custom info labels (lbl:) +# binds -> All custom keybind hints (cmd:) +# lbl:name -> Specific custom info label +# cmd:key -> Specific custom keybind hint +# +# The order defines the vertical stack (first item is at the edge). + +# Bottom left +corner_bottom_left = version + +# Bottom right +corner_bottom_right = labels + +# Top left +corner_top_left = keys + +# Top right +corner_top_right = clock tty + # For custom binds: the horizontal limit in characters for each # line of custom binds before moving on to the next. # If null, defaults to the width of the terminal instead. diff --git a/src/config/Config.zig b/src/config/Config.zig index 85d3ea1..36c5a41 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -39,6 +39,10 @@ cmatrix_max_codepoint: u16 = 0x7B, colormix_col1: u32 = 0x00FF0000, colormix_col2: u32 = 0x000000FF, colormix_col3: u32 = 0x20000000, +corner_bottom_left: []const u8 = "version", +corner_bottom_right: []const u8 = "labels", +corner_top_left: []const u8 = "keys", +corner_top_right: []const u8 = "clock tty", custom_bind_width: ?u32 = null, custom_sessions: []const u8 = build_options.config_directory ++ "/ly/custom-sessions", default_input: Input = .login, diff --git a/src/main.zig b/src/main.zig index 5d4b074..f77f63a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2062,93 +2062,300 @@ fn updateSessionSpecifier(self: *Label, ptr: *anyopaque) !void { self.setText(env.environment.specifier); } -fn positionWidgets(ptr: *anyopaque) !void { - var state: *UiState = @ptrCast(@alignCast(ptr)); +const Corner = enum { + bottomLeft, + bottomRight, + topLeft, + topRight, +}; - // Offsets for custom bind placement. Declared here instead of the - // below if stmt as we need these for `battery_label` positioning. - var x_offset: usize = 0; - // To account for the first row of built-in key hints - var y_offset: usize = 1; - if (!state.config.hide_key_hints) { - state.shutdown_label.positionX(state.edge_margin - .add(TerminalBuffer.START_POSITION)); - var last_label = state.shutdown_label; - state.restart_label.positionX(last_label - .childrenPosition() - .addX(1)); - last_label = state.restart_label; - state.sleep_label.positionX(last_label - .childrenPosition() - .addX(1)); - if (state.config.sleep_cmd != null) { - last_label = state.sleep_label; +const PositionedWidgets = struct { + binds: []bool, + labels: []bool, +}; + +fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, current_y: usize, is_left: bool, is_top: bool, positioned: *PositionedWidgets) !bool { + const base_x = state.edge_margin.x; + + if (std.mem.eql(u8, item, "keys")) { + if (state.config.hide_key_hints) return false; + + var local_x = current_x.*; + var local_y = current_y; + + const labels = [_]?*Label{ + &state.shutdown_label, + &state.restart_label, + if (state.config.sleep_cmd != null) &state.sleep_label else null, + if (state.config.hibernate_cmd != null) &state.hibernate_label else null, + &state.toggle_password_label, + if (state.config.brightness_down_key != null) &state.brightness_down_label else null, + if (state.config.brightness_up_key != null) &state.brightness_up_label else null, + }; + + for (labels) |maybe_label| { + const label = maybe_label orelse continue; + const width = TerminalBuffer.strWidth(label.text); + + if (is_left) { + if (local_x + width > state.buffer.width - state.edge_margin.x) { + local_x = base_x; + if (is_top) local_y += 1 else local_y -= 1; + } + label.positionXY(Position.init(local_x, local_y)); + local_x += width + 1; + } else { + if (width + state.edge_margin.x > local_x) { + local_x = state.buffer.width - state.edge_margin.x; + if (is_top) local_y += 1 else local_y -= 1; + } + label.positionXY(Position.init(local_x - width, local_y)); + local_x -= width + 1; + } } - state.hibernate_label.positionX(last_label - .childrenPosition() - .addX(1)); - if (state.config.hibernate_cmd != null) { - last_label = state.hibernate_label; + current_x.* = local_x; + return true; + } else if (std.mem.eql(u8, item, "clock") or std.mem.eql(u8, item, "time")) { + if (state.config.clock == null) return false; + const width = TerminalBuffer.strWidth(state.clock_label.text); + if (is_left) { + state.clock_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.clock_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; } - state.toggle_password_label.positionX(last_label - .childrenPosition() - .addX(1)); - last_label = state.toggle_password_label; - state.brightness_down_label.positionX(last_label - .childrenPosition() - .addX(1)); - if (state.config.brightness_down_key != null) { - last_label = state.brightness_down_label; + return true; + } else if (std.mem.eql(u8, item, "tty")) { + if (!state.config.show_tty) return false; + const width = TerminalBuffer.strWidth(state.tty_label.text); + if (is_left) { + state.tty_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.tty_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; } - state.brightness_up_label.positionXY(last_label - .childrenPosition() - .addX(1)); - for (state.custom_binds.items) |*item| { - item.lbl.positionXY(state.edge_margin - .addY(y_offset) - .addX(x_offset)); - x_offset += item.lbl.text.len + 1; - if (x_offset + item.lbl.text.len > state.config.custom_bind_width orelse state.buffer.width) { - x_offset = 0; - y_offset += 1; + return true; + } else if (std.mem.eql(u8, item, "battery")) { + if (state.config.battery_id == null) return false; + const width = TerminalBuffer.strWidth(state.battery_label.text); + if (is_left) { + state.battery_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.battery_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + return true; + } else if (std.mem.eql(u8, item, "version")) { + if (state.config.hide_version_string) return false; + const width = TerminalBuffer.strWidth(state.version_label.text); + if (is_left) { + state.version_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.version_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + return true; + } else if (std.mem.eql(u8, item, "numlock")) { + if (state.config.hide_keyboard_locks) return false; + const width = TerminalBuffer.strWidth(state.lang.numlock); + if (is_left) { + state.numlock_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.numlock_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + return true; + } else if (std.mem.eql(u8, item, "capslock")) { + if (state.config.hide_keyboard_locks) return false; + const width = TerminalBuffer.strWidth(state.lang.capslock); + if (is_left) { + state.capslock_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.capslock_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + return true; + } else if (std.mem.eql(u8, item, "labels")) { + for (state.custom_info.items, 0..) |*info, i| { + if (positioned.labels[i]) continue; + const width = TerminalBuffer.strWidth(info.lbl.text); + if (is_left) { + info.lbl.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + info.lbl.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + positioned.labels[i] = true; + } + return true; + } else if (std.mem.eql(u8, item, "binds")) { + var local_x = current_x.*; + var local_y = current_y; + + for (state.custom_binds.items, 0..) |*bind, i| { + if (positioned.binds[i]) continue; + const width = TerminalBuffer.strWidth(bind.lbl.text); + + if (is_left) { + if (local_x + width > (state.config.custom_bind_width orelse state.buffer.width) - state.edge_margin.x) { + local_x = base_x; + if (is_top) local_y += 1 else local_y -= 1; + } + bind.lbl.positionXY(Position.init(local_x, local_y)); + local_x += width + 1; + } else { + if (width + state.edge_margin.x > local_x) { + local_x = state.buffer.width - state.edge_margin.x; + if (is_top) local_y += 1 else local_y -= 1; + } + bind.lbl.positionXY(Position.init(local_x - width, local_y)); + local_x -= width + 1; + } + positioned.binds[i] = true; + } + current_x.* = local_x; + return true; + } else if (std.mem.startsWith(u8, item, "lbl:")) { + const name = item["lbl:".len..]; + for (state.custom_info.items, 0..) |*info, i| { + if (std.mem.eql(u8, info.info.name, name)) { + if (positioned.labels[i]) return false; + const width = TerminalBuffer.strWidth(info.lbl.text); + if (is_left) { + info.lbl.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + info.lbl.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + positioned.labels[i] = true; + return true; + } + } + } else if (std.mem.startsWith(u8, item, "cmd:")) { + const key = item["cmd:".len..]; + for (state.custom_binds.items, 0..) |*bind, i| { + if (std.mem.eql(u8, bind.key, key)) { + if (positioned.binds[i]) return false; + const width = TerminalBuffer.strWidth(bind.lbl.text); + if (is_left) { + bind.lbl.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + bind.lbl.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + positioned.binds[i] = true; + return true; } } } - for (state.custom_info.items, 0..) |*item, i| { - item.lbl.positionXY(state.edge_margin - .invertX(state.buffer.width) - .removeX(item.lbl.text.len) - .invertY(state.buffer.height) - .removeY(state.custom_info.items.len) - .addY(i)); + return false; +} + +fn positionItem(state: *UiState, item: []const u8, current_x: usize, current_y: usize, is_left: bool, is_top: bool, positioned: *PositionedWidgets) !bool { + // Check if item contains a comma for compound widgets + if (std.mem.indexOf(u8, item, ",") == null) { + var line_x = current_x; + return positionSingleWidget(state, item, &line_x, current_y, is_left, is_top, positioned); } - state.battery_label.positionXY(state.edge_margin - .add(TerminalBuffer.START_POSITION) - .addYFromIf(state.brightness_up_label.childrenPosition(), !state.config.hide_key_hints) - .addYIf(y_offset, !state.config.hide_key_hints) - .removeYFromIf(state.edge_margin, !state.config.hide_key_hints)); + var it = std.mem.tokenizeAny(u8, item, ","); + var success = false; - const tty_label_width = if (state.config.show_tty) TerminalBuffer.strWidth(state.tty_label.text) else 0; - const tty_label_gap = if (state.config.show_tty and state.config.clock != null) @as(usize, 1) else 0; - state.tty_label.positionXY(state.edge_margin - .add(TerminalBuffer.START_POSITION) - .invertX(state.buffer.width) - .removeXIf(tty_label_width, state.buffer.width > tty_label_width + state.edge_margin.x)); - state.clock_label.positionXY(state.edge_margin - .add(TerminalBuffer.START_POSITION) - .invertX(state.buffer.width) - .removeXIf(TerminalBuffer.strWidth(state.clock_label.text) + tty_label_width + tty_label_gap, state.buffer.width > TerminalBuffer.strWidth(state.clock_label.text) + tty_label_width + tty_label_gap + state.edge_margin.x)); + // Check if we need to wrap to next line + var line_x = current_x; - state.numlock_label.positionX(state.edge_margin - .add(TerminalBuffer.START_POSITION) - .addYFromIf(state.clock_label.childrenPosition(), state.config.clock != null) - .removeYFromIf(state.edge_margin, state.config.clock != null) - .invertX(state.buffer.width) - .removeXIf(TerminalBuffer.strWidth(state.lang.numlock), state.buffer.width > TerminalBuffer.strWidth(state.lang.numlock) + state.edge_margin.x)); - state.capslock_label.positionX(state.numlock_label - .childrenPosition() - .removeX(TerminalBuffer.strWidth(state.lang.numlock) + TerminalBuffer.strWidth(state.lang.capslock) + 1)); + // Now position each subitem + while (it.next()) |subitem| { + const trimmed = std.mem.trim(u8, subitem, " "); + + if (try positionSingleWidget(state, trimmed, &line_x, current_y, is_left, is_top, positioned)) { + success = true; + } + } + + return success; +} + +fn positionCorner(state: *UiState, config_str: []const u8, corner: Corner, positioned: *PositionedWidgets) !void { + const is_left = corner == .topLeft or corner == .bottomLeft; + const is_top = corner == .topLeft or corner == .topRight; + + var y_offset: usize = 0; + var i: usize = 0; + const len = config_str.len; + + while (i < len) { + // Skip whitespace and brackets + while (i < len and (config_str[i] == ' ' or config_str[i] == '\t' or config_str[i] == '[' or config_str[i] == ']')) { + i += 1; + } + if (i >= len) break; + + const start = i; + while (i < len and config_str[i] != ' ' and config_str[i] != '\t' and config_str[i] != '[' and config_str[i] != ']') { + i += 1; + } + const token = config_str[start..i]; + + const current_x = if (is_left) state.edge_margin.x else state.buffer.width - state.edge_margin.x; + const current_y = if (is_top) state.edge_margin.y + y_offset else state.buffer.height - 1 - state.edge_margin.y - y_offset; + + if (try positionItem(state, token, current_x, current_y, is_left, is_top, positioned)) { + y_offset += 1; + } + } +} + +fn positionWidgets(ptr: *anyopaque) !void { + var state: *UiState = @ptrCast(@alignCast(ptr)); + + const offscreen = Position.init(state.buffer.width + 1, state.buffer.height + 1); + + // Reset all potential corner widgets to offscreen + state.shutdown_label.positionXY(offscreen); + state.restart_label.positionXY(offscreen); + state.sleep_label.positionXY(offscreen); + state.hibernate_label.positionXY(offscreen); + state.toggle_password_label.positionXY(offscreen); + state.brightness_down_label.positionXY(offscreen); + state.brightness_up_label.positionXY(offscreen); + state.clock_label.positionXY(offscreen); + state.tty_label.positionXY(offscreen); + state.battery_label.positionXY(offscreen); + state.version_label.positionXY(offscreen); + state.numlock_label.positionXY(offscreen); + state.capslock_label.positionXY(offscreen); + + for (state.custom_binds.items) |*bind| { + bind.lbl.positionXY(offscreen); + } + for (state.custom_info.items) |*info| { + info.lbl.positionXY(offscreen); + } + + var positioned = PositionedWidgets{ + .binds = try state.allocator.alloc(bool, state.custom_binds.items.len), + .labels = try state.allocator.alloc(bool, state.custom_info.items.len), + }; + defer state.allocator.free(positioned.binds); + defer state.allocator.free(positioned.labels); + + @memset(positioned.binds, false); + @memset(positioned.labels, false); + + try positionCorner(state, state.config.corner_top_left, .topLeft, &positioned); + try positionCorner(state, state.config.corner_top_right, .topRight, &positioned); + try positionCorner(state, state.config.corner_bottom_left, .bottomLeft, &positioned); + try positionCorner(state, state.config.corner_bottom_right, .bottomRight, &positioned); var bb_height = state.box.height; var bb_width = state.box.width; @@ -2215,10 +2422,6 @@ fn positionWidgets(ptr: *anyopaque) !void { state.password.positionY(state.password_label .childrenPosition() .addX(state.labels_max_length - TerminalBuffer.strWidth(state.password_label.text) + 1)); - - state.version_label.positionXY(state.edge_margin - .add(TerminalBuffer.START_POSITION) - .invertY(state.buffer.height - 1)); } fn handleInactivity(ptr: *anyopaque) !void { From 102d1c9a9b61eef1f9620570e3c3838e402c2c63 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 00:22:51 +0200 Subject: [PATCH 54/77] Unset Shift and Ctrl for arrow keys (closes #1015) Signed-off-by: AnErrupTion --- ly-ui/src/keyboard.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ly-ui/src/keyboard.zig b/ly-ui/src/keyboard.zig index a90148b..626f21f 100644 --- a/ly-ui/src/keyboard.zig +++ b/ly-ui/src/keyboard.zig @@ -167,6 +167,12 @@ pub fn getKeyList(allocator: Allocator, tb_event: termbox.tb_event) !KeyList { 21 => key.right = true, else => {}, } + + if (code >= 18 and code <= 21) { + // https://github.com/termbox/termbox2/blob/605398fa79108412976191e062ea14bd4bd30213/termbox2.h#L446 + key.ctrl = false; + key.shift = false; + } } else if (tb_event.ch < 128) { const code = if (tb_event.ch == 0 and tb_event.key < 128) tb_event.key else tb_event.ch; From 4513033bcb8d0ba1004bcc5bfa4d6e22a117a16d Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 02:22:40 +0200 Subject: [PATCH 55/77] ly@.service: Use agetty Signed-off-by: AnErrupTion --- readme.md | 6 ------ res/ly@.service | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index 8c554fd..3b79436 100644 --- a/readme.md +++ b/readme.md @@ -162,12 +162,6 @@ Then, similarly to the previous command, you need to enable the Ly service: # systemctl disable getty@tty2.service ``` -On platforms that use systemd-logind to dynamically start `autovt@.service` instances when the switch to a new tty occurs, any ly instances for ttys _except the default tty_ need to be enabled using a different mechanism: To autostart ly on switch to `tty2`, do not enable any `ly` unit directly, instead symlink `autovt@tty2.service` to `ly@tty2.service` within `/usr/lib/systemd/system/` (analogous for every other tty you want to enable ly on). - -The target of the symlink, `ly@ttyN.service`, does not actually exist, but systemd nevertheless recognizes that the instanciation of `autovt@.service` with `%I` equal to `ttyN` now points to an instanciation of `ly@.service` with `%I` set to `ttyN`. - -Compare to `man 5 logind.conf`, especially regarding the `NAutoVTs=` and `ReserveVT=` parameters. - On non-systemd systems, you can change the TTY Ly will run on by editing the corresponding service file for your platform. ### OpenRC diff --git a/res/ly@.service b/res/ly@.service index 54d8bf6..2db6df4 100644 --- a/res/ly@.service +++ b/res/ly@.service @@ -1,16 +1,46 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# Modified for Ly by AnErrupTion + [Unit] -Description=TUI display manager -After=systemd-user-sessions.service plymouth-quit-wait.service -After=getty@%i.service +Description=TUI display manager on %I +After=systemd-user-sessions.service plymouth-quit-wait.service getty@%i.service Conflicts=getty@%i.service [Service] +ExecStart=$PREFIX_DIRECTORY/bin/agetty -nl $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME %I ${TERM} Type=idle -ExecStart=$PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME +Restart=always +RestartSec=0 +UtmpIdentifier=%I StandardInput=tty +StandardOutput=tty TTYPath=/dev/%I TTYReset=yes TTYVHangup=yes +TTYVTDisallocate=yes +IgnoreSIGPIPE=no +SendSIGHUP=yes + +ImportCredential=tty.virtual.%I.agetty.*:agetty. +ImportCredential=tty.virtual.%I.login.*:login. +ImportCredential=agetty.* +ImportCredential=login.* +ImportCredential=shell.* + +# Unset locale for the console getty since the console has problems +# displaying some internationalized messages. +UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION [Install] +Alias=autovt@.service + WantedBy=multi-user.target +DefaultInstance=tty2 From 9b8046e37c93db564feb3f6a2349dd16caa67f81 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 11:10:26 +0200 Subject: [PATCH 56/77] auth: chown & chmod TTY (closes #944) Signed-off-by: AnErrupTion --- src/auth.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/auth.zig b/src/auth.zig index 7a3c033..00ae005 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -105,6 +105,11 @@ pub fn authenticate(allocator: std.mem.Allocator, io: std.Io, log_file: *LogFile try log_file.info(io, "auth/passwd", "setting user shell", .{}); if (user_entry.shell == null) interop.setUserShell(&user_entry); + // chown & chmod stdin (which is the TTY) + // https://github.com/mirror/busybox/blob/371fe9f71d445d18be28c82a2a6d82115c8af19d/loginutils/login.c#L558 + if (interop.isError(std.posix.system.fchown(std.posix.STDIN_FILENO, user_entry.uid, user_entry.gid))) return error.TtyChownFailed; + if (interop.isError(std.posix.system.fchmod(std.posix.STDIN_FILENO, 0o600))) return error.TtyChmodFailed; + var shared_err = try SharedError.init(null, null); defer shared_err.deinit(); From 32f11cdbe56cc081079cfc2f1e1ab4ade50e66eb Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 11:47:37 +0200 Subject: [PATCH 57/77] Modify link to black hole animation (closes #1006) Signed-off-by: AnErrupTion --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 3b79436..2d26c31 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ ![Ly screenshot](.github/screenshot.png "Ly screenshot") -_Note: the above animation can be found [here](https://codeberg.org/attachments/f336d6ac-8331-4323-91fc-0e4619803401)!_ +_Note: the above animation can be found [here](https://codeberg.org/fairyglade/ly-community/src/branch/main/animations/dur/blackhole-smooth-240x67.dur)!_ Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD, designed with portability in mind and doesn't require systemd to run. From 7eae544418d8fce4fa59f72946bff30bbfbe8702 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 12:43:10 +0200 Subject: [PATCH 58/77] systemd: Add more conflicts, better kmscon service Signed-off-by: AnErrupTion --- res/ly-kmsconvt@.service | 21 ++++++++++++++++----- res/ly@.service | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/res/ly-kmsconvt@.service b/res/ly-kmsconvt@.service index 85b0f05..9384bdf 100644 --- a/res/ly-kmsconvt@.service +++ b/res/ly-kmsconvt@.service @@ -1,17 +1,28 @@ +# Default kmsconvt@.service +# Modified for Ly by AnErrupTion + [Unit] -Description=TUI display manager using KMSCON -After=systemd-user-sessions.service plymouth-quit-wait.service -After=kmsconvt@%i.service -Conflicts=kmsconvt@%i.service +Description=TUI display manager on %I using KMSCON +After=systemd-user-sessions.service plymouth-quit-wait.service rc-local.service kmsconvt@%i.service +Conflicts=getty@%i.service kmsconvt@%i.service ly@%i.service +OnFailure=ly@%i.service [Service] ExecStart=$PREFIX_DIRECTORY/bin/kmscon --term=linux --font-engine unifont --vt=%I --login -- $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME --use-kmscon-vt -StandardInput=tty +Type=idle +Restart=always +RestartSec=0 UtmpIdentifier=%I +StandardInput=tty +StandardOutput=tty TTYPath=/dev/%I TTYReset=yes TTYVHangup=yes TTYVTDisallocate=yes +IgnoreSIGPIPE=no +SendSIGHUP=yes [Install] +Alias=autovt@.service WantedBy=multi-user.target +DefaultInstance=tty2 diff --git a/res/ly@.service b/res/ly@.service index 2db6df4..b2fb5ff 100644 --- a/res/ly@.service +++ b/res/ly@.service @@ -12,7 +12,7 @@ [Unit] Description=TUI display manager on %I After=systemd-user-sessions.service plymouth-quit-wait.service getty@%i.service -Conflicts=getty@%i.service +Conflicts=getty@%i.service kmsconvt@%i.service ly-kmsconvt@%i.service [Service] ExecStart=$PREFIX_DIRECTORY/bin/agetty -nl $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME %I ${TERM} From 954e90b3bd99ffed44695e8167cd33d638056b6c Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 17:20:05 +0200 Subject: [PATCH 59/77] Remove options superseded by corner customisation Signed-off-by: AnErrupTion --- res/config.ini | 18 +------- src/config/Config.zig | 6 +-- src/config/migrator.zig | 5 +++ src/main.zig | 93 +++++++++++++++++++++++++---------------- 4 files changed, 66 insertions(+), 56 deletions(-) diff --git a/res/config.ini b/res/config.ini index c57c7f4..c29b50a 100644 --- a/res/config.ini +++ b/res/config.ini @@ -155,7 +155,7 @@ colormix_col3 = 0x20000000 # Screen corners customization # Keywords: -# keys -> Power management keys (shutdown, restart, etc.) +# keys -> Power management, brightness control & toggle password keys # clock -> Clock (format defined by 'clock' option) # tty -> Active TTY number # battery -> Battery percentage @@ -179,7 +179,7 @@ corner_bottom_right = labels corner_top_left = keys # Top right -corner_top_right = clock tty +corner_top_right = clock # For custom binds: the horizontal limit in characters for each # line of custom binds before moving on to the next. @@ -285,15 +285,6 @@ hibernate_key = F4 # Remove main box borders hide_borders = false -# Remove power management command hints -hide_key_hints = false - -# Remove keyboard lock states from the top right corner -hide_keyboard_locks = false - -# Remove version number from the top left corner -hide_version_string = false - # Command executed when no input is detected for a certain time # If null, no command will be executed inactivity_cmd = null @@ -379,11 +370,6 @@ shell = true # Specifies the key combination used for showing the password show_password_key = F7 -# Display the active TTY number (e.g. tty3) to the right of the clock in the top right corner -# If the clock is disabled, the TTY label occupies the top right corner on its own -# If false, the TTY number will not be shown -show_tty = false - # Command executed when pressing shutdown_key shutdown_cmd = /sbin/shutdown $PLATFORM_SHUTDOWN_ARG now diff --git a/src/config/Config.zig b/src/config/Config.zig index 36c5a41..0436f5f 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -42,7 +42,7 @@ colormix_col3: u32 = 0x20000000, corner_bottom_left: []const u8 = "version", corner_bottom_right: []const u8 = "labels", corner_top_left: []const u8 = "keys", -corner_top_right: []const u8 = "clock tty", +corner_top_right: []const u8 = "clock", custom_bind_width: ?u32 = null, custom_sessions: []const u8 = build_options.config_directory ++ "/ly/custom-sessions", default_input: Input = .login, @@ -67,9 +67,6 @@ gameoflife_initial_density: f32 = 0.4, hibernate_cmd: ?[]const u8 = null, hibernate_key: []const u8 = "F4", hide_borders: bool = false, -hide_key_hints: bool = false, -hide_keyboard_locks: bool = false, -hide_version_string: bool = false, inactivity_cmd: ?[]const u8 = null, inactivity_delay: u16 = 0, initial_info_text: ?[]const u8 = null, @@ -92,7 +89,6 @@ session_log: ?[]const u8 = "ly-session.log", setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh", shell: bool = true, show_password_key: []const u8 = "F7", -show_tty: bool = false, shutdown_cmd: []const u8 = "/sbin/shutdown -a now", shutdown_key: []const u8 = "F1", sleep_cmd: ?[]const u8 = null, diff --git a/src/config/migrator.zig b/src/config/migrator.zig index 366bc81..b174a48 100644 --- a/src/config/migrator.zig +++ b/src/config/migrator.zig @@ -45,6 +45,11 @@ const removed_properties = [_][]const u8{ "wayland_cmd", "console_dev", "load", + // Migrating these isn't worth the effort so just say we removed them + "hide_key_hints", + "hide_keyboard_locks", + "hide_version_string", + "show_tty", }; pub var auto_eight_colors: bool = true; diff --git a/src/main.zig b/src/main.zig index f77f63a..7eb8ff3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -103,6 +103,13 @@ const UiState = struct { password_label: Label, version_label: Label, bigclock_label: BigLabel, + show_tty: bool, + hide_key_hints: bool, + hide_numlock: bool, + hide_capslock: bool, + hide_version_string: bool, + hide_labels: bool, + hide_binds: bool, box: Box, info_line: InfoLine, animate: bool, @@ -433,6 +440,14 @@ pub fn main(init: std.process.Init) !void { }; std.posix.sigaction(std.posix.SIG.TERM, &act, null); + state.show_tty = cornersContain(state, "tty"); + state.hide_key_hints = !cornersContain(state, "keys"); + state.hide_numlock = !cornersContain(state, "numlock"); + state.hide_capslock = !cornersContain(state, "capslock"); + state.hide_version_string = !cornersContain(state, "version"); + state.hide_labels = !cornersContain(state, "labels") and !cornersContain(state, "lbl:"); + state.hide_binds = !cornersContain(state, "binds") and !cornersContain(state, "cmd:"); + // Initialize components state.shutdown_label = Label.init( "", @@ -504,7 +519,7 @@ pub fn main(init: std.process.Init) !void { ); defer state.brightness_up_label.deinit(); - if (!state.config.hide_key_hints) { + if (!state.hide_key_hints) { try state.shutdown_label.setTextAlloc( state.allocator, "{s} {s}", @@ -1052,7 +1067,7 @@ pub fn main(init: std.process.Init) !void { }; } - if (state.config.show_tty) { + if (state.show_tty) { try state.tty_label.setTextBuf(&state.tty_buf, "tty{d}", .{state.active_tty}); } @@ -1226,34 +1241,35 @@ pub fn main(init: std.process.Init) !void { state.custom_binds = .empty; defer state.custom_binds.deinit(state.allocator); - - state.custom_info = .empty; - defer state.custom_info.deinit(state.allocator); - - var lblIter = custom.labels.iterator(); - // NOTE: Because widgets have a pointer to the underlying Label, we have to ensure - // that the ArrayList doesn't allocate more memory than what we ensured. Otherwise - // the pointer to the Label becomes invalid. - try state.custom_info.ensureTotalCapacity(state.allocator, @intCast(custom.labels.count())); - while (lblIter.next()) |i| { - try state.custom_info.append(state.allocator, .{ - .info = i.value_ptr.*, - .lbl = .init("", null, state.buffer.fg, state.buffer.bg, updateCustomInfo, null), - }); - var latest = &state.custom_info.items[state.custom_info.items.len - 1]; - latest.info.id = latest.lbl.widget().id; - latest.info.counter = 1; - } - defer for (state.custom_info.items) |*item| { - item.lbl.deinit(); - }; - - var iter = custom.binds.iterator(); defer for (state.custom_binds.items) |*i| { i.lbl.deinit(); }; - if (!state.config.hide_key_hints) { + state.custom_info = .empty; + defer state.custom_info.deinit(state.allocator); + defer for (state.custom_info.items) |*item| { + item.lbl.deinit(); + }; + + if (!state.hide_labels) { + var lblIter = custom.labels.iterator(); + // NOTE: Because widgets have a pointer to the underlying Label, we have to ensure + // that the ArrayList doesn't allocate more memory than what we ensured. Otherwise + // the pointer to the Label becomes invalid. + try state.custom_info.ensureTotalCapacity(state.allocator, @intCast(custom.labels.count())); + while (lblIter.next()) |i| { + try state.custom_info.append(state.allocator, .{ + .info = i.value_ptr.*, + .lbl = .init("", null, state.buffer.fg, state.buffer.bg, updateCustomInfo, null), + }); + var latest = &state.custom_info.items[state.custom_info.items.len - 1]; + latest.info.id = latest.lbl.widget().id; + latest.info.counter = 1; + } + } + + if (!state.hide_binds) { + var iter = custom.binds.iterator(); while (iter.next()) |i| { var concat = try std.mem.concat(state.allocator, u8, &[_][]const u8{ i.key_ptr.*, " ", i.value_ptr.name }); inline for (@typeInfo(Lang).@"struct".fields) |lang_key| { @@ -1276,6 +1292,8 @@ pub fn main(init: std.process.Init) !void { }); state.custom_binds.items[state.custom_binds.items.len - 1].lbl.allocator = state.allocator; } + } + if (!state.hide_key_hints) { try layer2.append(state.allocator, state.shutdown_label.widget()); try layer2.append(state.allocator, state.restart_label.widget()); if (state.config.sleep_cmd != null) { @@ -1298,14 +1316,16 @@ pub fn main(init: std.process.Init) !void { if (state.config.clock != null) { try layer2.append(state.allocator, state.clock_label.widget()); } - if (state.config.show_tty) { + if (state.show_tty) { try layer2.append(state.allocator, state.tty_label.widget()); } if (state.config.bigclock != .none) { try layer2.append(state.allocator, state.bigclock_label.widget()); } - if (!state.config.hide_keyboard_locks) { + if (!state.hide_numlock) { try layer2.append(state.allocator, state.numlock_label.widget()); + } + if (!state.hide_capslock) { try layer2.append(state.allocator, state.capslock_label.widget()); } try layer2.append(state.allocator, state.box.widget()); @@ -1316,7 +1336,7 @@ pub fn main(init: std.process.Init) !void { try layer2.append(state.allocator, login_widget); try layer2.append(state.allocator, state.password_label.widget()); try layer2.append(state.allocator, state.password_widget); - if (!state.config.hide_version_string) { + if (!state.hide_version_string) { try layer2.append(state.allocator, state.version_label.widget()); } @@ -1408,6 +1428,15 @@ pub fn main(init: std.process.Init) !void { ); } +fn cornersContain(state: UiState, text: []const u8) bool { + const top_left = std.mem.containsAtLeast(u8, state.config.corner_top_left, 1, text); + const top_right = std.mem.containsAtLeast(u8, state.config.corner_top_right, 1, text); + const bottom_left = std.mem.containsAtLeast(u8, state.config.corner_bottom_left, 1, text); + const bottom_right = std.mem.containsAtLeast(u8, state.config.corner_bottom_right, 1, text); + + return top_left or top_right or bottom_left or bottom_right; +} + fn maxWidths(labels: [][]const u8) usize { var max_width: usize = 0; @@ -2078,8 +2107,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu const base_x = state.edge_margin.x; if (std.mem.eql(u8, item, "keys")) { - if (state.config.hide_key_hints) return false; - var local_x = current_x.*; var local_y = current_y; @@ -2127,7 +2154,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu } return true; } else if (std.mem.eql(u8, item, "tty")) { - if (!state.config.show_tty) return false; const width = TerminalBuffer.strWidth(state.tty_label.text); if (is_left) { state.tty_label.positionXY(Position.init(current_x.*, current_y)); @@ -2149,7 +2175,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu } return true; } else if (std.mem.eql(u8, item, "version")) { - if (state.config.hide_version_string) return false; const width = TerminalBuffer.strWidth(state.version_label.text); if (is_left) { state.version_label.positionXY(Position.init(current_x.*, current_y)); @@ -2160,7 +2185,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu } return true; } else if (std.mem.eql(u8, item, "numlock")) { - if (state.config.hide_keyboard_locks) return false; const width = TerminalBuffer.strWidth(state.lang.numlock); if (is_left) { state.numlock_label.positionXY(Position.init(current_x.*, current_y)); @@ -2171,7 +2195,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu } return true; } else if (std.mem.eql(u8, item, "capslock")) { - if (state.config.hide_keyboard_locks) return false; const width = TerminalBuffer.strWidth(state.lang.capslock); if (is_left) { state.capslock_label.positionXY(Position.init(current_x.*, current_y)); From e1696a4e73c68fa5774488e8adc2545e62e74941 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 17:32:49 +0200 Subject: [PATCH 60/77] config: Better document corner customisation Signed-off-by: AnErrupTion --- res/config.ini | 11 ++++++++--- src/config/Config.zig | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/res/config.ini b/res/config.ini index c29b50a..ae63e6f 100644 --- a/res/config.ini +++ b/res/config.ini @@ -167,7 +167,12 @@ colormix_col3 = 0x20000000 # lbl:name -> Specific custom info label # cmd:key -> Specific custom keybind hint # -# The order defines the vertical stack (first item is at the edge). +# If using a keyword that groups multiple labels into one (e.g. keys, labels, +# binds, ...), they'll be placed horizontally +# +# Also, the order defines the vertical stack (first item is at the edge) +# If items are separted by commas, they'll be placed horizontally +# It is possible to have both horizontal and vertical items on the same corner # Bottom left corner_bottom_left = version @@ -176,10 +181,10 @@ corner_bottom_left = version corner_bottom_right = labels # Top left -corner_top_left = keys +corner_top_left = keys battery # Top right -corner_top_right = clock +corner_top_right = clock numlock,capslock # For custom binds: the horizontal limit in characters for each # line of custom binds before moving on to the next. diff --git a/src/config/Config.zig b/src/config/Config.zig index 0436f5f..8ad10ae 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -41,8 +41,8 @@ colormix_col2: u32 = 0x000000FF, colormix_col3: u32 = 0x20000000, corner_bottom_left: []const u8 = "version", corner_bottom_right: []const u8 = "labels", -corner_top_left: []const u8 = "keys", -corner_top_right: []const u8 = "clock", +corner_top_left: []const u8 = "keys battery", +corner_top_right: []const u8 = "clock numlock,capslock", custom_bind_width: ?u32 = null, custom_sessions: []const u8 = build_options.config_directory ++ "/ly/custom-sessions", default_input: Input = .login, From acb532b5d4f092b9b7ebb213069616c25ba535d7 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 18:33:13 +0200 Subject: [PATCH 61/77] migrator: Free old save path later Signed-off-by: AnErrupTion --- src/config/migrator.zig | 2 -- src/main.zig | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/config/migrator.zig b/src/config/migrator.zig index b174a48..a2659ef 100644 --- a/src/config/migrator.zig +++ b/src/config/migrator.zig @@ -289,8 +289,6 @@ pub fn tryMigrateIniSaveFile(allocator: std.mem.Allocator, io: std.Io, path: []c fn tryMigrateFirstSaveFile(io: std.Io, user_buf: *[32]u8) ?OldSave { if (maybe_save_file) |path| { - defer temporary_allocator.free(path); - var save = OldSave{}; var file = std.Io.Dir.openFileAbsolute(io, path, .{}) catch return null; defer file.close(io); diff --git a/src/main.zig b/src/main.zig index 7eb8ff3..83aa008 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1648,6 +1648,7 @@ fn authenticate(ptr: *anyopaque) !bool { // Delete previous save file if it exists if (migrator.maybe_save_file) |path| { + defer temporary_allocator.free(path); std.Io.Dir.cwd().deleteFile(state.io, path) catch {}; } else if (state.has_old_save) { std.Io.Dir.cwd().deleteFile(state.io, state.old_save_path) catch {}; From 5fc5fd62a075635ac7119dd07a3fb90a5501c83a Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 19:44:10 +0200 Subject: [PATCH 62/77] Remove shutdown_cmd & restart_cmd + sleep & hibernate Signed-off-by: AnErrupTion --- build.zig | 4 -- ly-core/src/interop.zig | 35 +++++++++++ res/config.ini | 18 ------ src/config/Config.zig | 6 -- src/config/migrator.zig | 48 ++++++++++++++- src/main.zig | 130 ++-------------------------------------- 6 files changed, 85 insertions(+), 156 deletions(-) diff --git a/build.zig b/build.zig index a3a5f22..b4f216c 100644 --- a/build.zig +++ b/build.zig @@ -136,10 +136,6 @@ pub fn Installer(install_config: bool) type { try patch_map.put("$PREFIX_DIRECTORY", prefix_directory); try patch_map.put("$EXECUTABLE_NAME", executable_name); - // The "-a" argument doesn't exist on FreeBSD, so we use "-p" - // instead to shutdown the system. - try patch_map.put("$PLATFORM_SHUTDOWN_ARG", if (init_system == .freebsd) "-p" else "-a"); - try install_ly(allocator, io, patch_map, install_config); try install_service(allocator, io, patch_map); } diff --git a/ly-core/src/interop.zig b/ly-core/src/interop.zig index 736d8ca..873db15 100644 --- a/ly-core/src/interop.zig +++ b/ly-core/src/interop.zig @@ -179,6 +179,20 @@ fn PlatformStruct() type { return uid_range; } + pub fn shutdownSystemImpl() !void { + std.posix.system.sync(); + if (isError(std.os.linux.reboot(.MAGIC1, .MAGIC2, .POWER_OFF, null))) { + return error.CouldntShutdown; + } + } + + pub fn rebootSystemImpl() !void { + std.posix.system.sync(); + if (isError(std.os.linux.reboot(.MAGIC1, .MAGIC2, .RESTART, null))) { + return error.CouldntShutdown; + } + } + fn parseValue(comptime T: type, name: []const u8, buffer: []const u8) !T { var iterator = std.mem.splitAny(u8, buffer, " \t"); var maybe_value: ?T = null; @@ -209,6 +223,7 @@ fn PlatformStruct() type { .freebsd => struct { pub const kbio = @import("kbio"); pub const consio = @import("consio"); + pub const reboot = @import("reboot"); pub const LedState = c_int; pub const get_led_state = kbio.KDGETLED; @@ -243,6 +258,18 @@ fn PlatformStruct() type { .uid_max = FREEBSD_UID_MAX, }; } + + pub fn shutdownSystemImpl() !void { + if (isError(reboot.reboot(reboot.RB_POWEROFF))) { + return error.CouldntShutdown; + } + } + + pub fn rebootSystemImpl() !void { + if (isError(reboot.reboot(reboot.RB_AUTOBOOT))) { + return error.CouldntReboot; + } + } }, else => @compileError("Unsupported target: " ++ builtin.os.tag), }; @@ -396,3 +423,11 @@ pub fn closePasswordDatabase() void { pub fn getUserIdRange(allocator: std.mem.Allocator, io: std.Io, file_path: []const u8) !UidRange { return platform_struct.getUserIdRange(allocator, io, file_path); } + +pub fn shutdownSystem() !void { + try platform_struct.shutdownSystemImpl(); +} + +pub fn rebootSystem() !void { + try platform_struct.rebootSystemImpl(); +} diff --git a/res/config.ini b/res/config.ini index ae63e6f..0ae21b7 100644 --- a/res/config.ini +++ b/res/config.ini @@ -281,12 +281,6 @@ gameoflife_frame_delay = 6 # 0.7+ -> Dense, chaotic patterns gameoflife_initial_density = 0.4 -# Command executed when pressing hibernate key (can be null) -hibernate_cmd = null - -# Specifies the key combination used for hibernate -hibernate_key = F4 - # Remove main box borders hide_borders = false @@ -344,9 +338,6 @@ numlock = false # If null, ly doesn't set a path path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -# Command executed when pressing restart_key -restart_cmd = /sbin/shutdown -r now - # Specifies the key combination used for restart restart_key = F2 @@ -375,18 +366,9 @@ shell = true # Specifies the key combination used for showing the password show_password_key = F7 -# Command executed when pressing shutdown_key -shutdown_cmd = /sbin/shutdown $PLATFORM_SHUTDOWN_ARG now - # Specifies the key combination used for shutdown shutdown_key = F1 -# Command executed when pressing sleep key (can be null) -sleep_cmd = null - -# Specifies the key combination used for sleep -sleep_key = F3 - # Command executed when starting Ly (before the TTY is taken control of) # See file at path below for an example of changing the default TTY colors start_cmd = $CONFIG_DIRECTORY/ly/startup.sh diff --git a/src/config/Config.zig b/src/config/Config.zig index 8ad10ae..f78c169 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -64,8 +64,6 @@ gameoflife_fg: u32 = 0x0000FF00, gameoflife_entropy_interval: usize = 10, gameoflife_frame_delay: usize = 6, gameoflife_initial_density: f32 = 0.4, -hibernate_cmd: ?[]const u8 = null, -hibernate_key: []const u8 = "F4", hide_borders: bool = false, inactivity_cmd: ?[]const u8 = null, inactivity_delay: u16 = 0, @@ -81,7 +79,6 @@ margin_box_h: u8 = 2, margin_box_v: u8 = 1, numlock: bool = false, path: ?[]const u8 = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", -restart_cmd: []const u8 = "/sbin/shutdown -r now", restart_key: []const u8 = "F2", save: bool = true, service_name: [:0]const u8 = "ly", @@ -89,10 +86,7 @@ session_log: ?[]const u8 = "ly-session.log", setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh", shell: bool = true, show_password_key: []const u8 = "F7", -shutdown_cmd: []const u8 = "/sbin/shutdown -a now", shutdown_key: []const u8 = "F1", -sleep_cmd: ?[]const u8 = null, -sleep_key: []const u8 = "F3", start_cmd: ?[]const u8 = null, text_in_center: bool = false, type_username: bool = false, diff --git a/src/config/migrator.zig b/src/config/migrator.zig index a2659ef..758f44f 100644 --- a/src/config/migrator.zig +++ b/src/config/migrator.zig @@ -14,6 +14,7 @@ const IniParser = ly_core.IniParser; const ini = ly_core.ini; const Config = @import("Config.zig"); +const Lang = @import("Lang.zig"); const OldSave = @import("OldSave.zig"); const SavedUsers = @import("SavedUsers.zig"); const custom = @import("custom.zig"); @@ -45,6 +46,8 @@ const removed_properties = [_][]const u8{ "wayland_cmd", "console_dev", "load", + "shutdown_cmd", + "restart_cmd", // Migrating these isn't worth the effort so just say we removed them "hide_key_hints", "hide_keyboard_locks", @@ -56,6 +59,10 @@ pub var auto_eight_colors: bool = true; pub var maybe_animate: ?bool = null; pub var maybe_save_file: ?[]const u8 = null; +pub var maybe_sleep_key: ?[]const u8 = null; +pub var maybe_sleep_cmd: ?[]const u8 = null; +pub var maybe_hibernate_key: ?[]const u8 = null; +pub var maybe_hibernate_cmd: ?[]const u8 = null; pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniField { if (std.mem.eql(u8, field.key, "animate")) { @@ -129,7 +136,6 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie if (std.mem.eql(u8, field.key, "save_file")) { // The option doesn't exist anymore, but we save its value for migration later on maybe_save_file = temporary_allocator.dupe(u8, field.value) catch return null; - return null; } @@ -168,6 +174,26 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie return mapped_field; } + if (std.mem.eql(u8, field.key, "sleep_key")) { + maybe_sleep_key = temporary_allocator.dupe(u8, field.value) catch return null; + return null; + } + + if (std.mem.eql(u8, field.key, "sleep_cmd")) { + maybe_sleep_cmd = temporary_allocator.dupe(u8, field.value) catch return null; + return null; + } + + if (std.mem.eql(u8, field.key, "hibernate_key")) { + maybe_hibernate_key = temporary_allocator.dupe(u8, field.value) catch return null; + return null; + } + + if (std.mem.eql(u8, field.key, "hibernate_cmd")) { + maybe_hibernate_cmd = temporary_allocator.dupe(u8, field.value) catch return null; + return null; + } + // TODO: Dearest Melpert, // I pray this message finds you well, as daylight dwindles and the witching hour // approaches, I find it more and more imperative as time continues that I place @@ -228,7 +254,7 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie // This is the stuff we only handle after reading the config. // For example, the "animate" field could come after "animation" -pub fn lateConfigFieldHandler(config: *Config) void { +pub fn lateConfigFieldHandler(config: *Config, lang: Lang) void { if (maybe_animate) |animate| { if (!animate) config.*.animation = .none; } @@ -257,6 +283,24 @@ pub fn lateConfigFieldHandler(config: *Config) void { if (!set_color_properties[7]) config.error_fg = Styling.BOLD | Color.ECOL_RED; if (!set_color_properties[8]) config.fg = Color.ECOL_WHITE; } + + if (maybe_sleep_key) |key| { + if (maybe_sleep_cmd) |cmd| { + custom.binds.put(temporary_allocator, key, .{ + .name = temporary_allocator.dupe(u8, lang.sleep) catch "", + .cmd = cmd, + }) catch {}; + } + } + + if (maybe_hibernate_key) |key| { + if (maybe_hibernate_cmd) |cmd| { + custom.binds.put(temporary_allocator, key, .{ + .name = temporary_allocator.dupe(u8, lang.hibernate) catch "", + .cmd = cmd, + }) catch {}; + } + } } pub fn tryMigrateIniSaveFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8, saved_users: *SavedUsers, usernames: [][]const u8) !?IniParser(OldSave) { diff --git a/src/main.zig b/src/main.zig index 83aa008..8ae1227 100644 --- a/src/main.zig +++ b/src/main.zig @@ -88,8 +88,6 @@ const UiState = struct { labels_max_length: usize, shutdown_label: Label, restart_label: Label, - sleep_label: Label, - hibernate_label: Label, toggle_password_label: Label, brightness_down_label: Label, brightness_up_label: Label, @@ -141,9 +139,6 @@ var shutdown = false; var restart = false; pub fn main(init: std.process.Init) !void { - var shutdown_cmd: []const u8 = undefined; - var restart_cmd: []const u8 = undefined; - var commands_allocated = false; var state: UiState = undefined; state.io = init.io; @@ -152,21 +147,12 @@ pub fn main(init: std.process.Init) !void { var stderr_writer = std.Io.File.stderr().writer(state.io, &stderr_buffer); var stderr = &stderr_writer.interface; + // If we can't shutdown or restart due to an error, we print it to standard error. If that fails, just bail out defer { - // If we can't shutdown or restart due to an error, we print it to standard error. If that fails, just bail out if (shutdown) { - const shutdown_error = std.process.replace(state.io, .{ .argv = &[_][]const u8{ "/bin/sh", "-c", shutdown_cmd } }); - std.log.err("couldn't shutdown: {s}", .{@errorName(shutdown_error)}); + interop.shutdownSystem() catch std.log.err("whoopsie doodle, couldn't shutdown system!", .{}); } else if (restart) { - const restart_error = std.process.replace(state.io, .{ .argv = &[_][]const u8{ "/bin/sh", "-c", restart_cmd } }); - std.log.err("couldn't restart: {s}", .{@errorName(restart_error)}); - } else { - // The user has quit Ly using Ctrl+C - if (commands_allocated) { - // Necessary if we error out before allocating - temporary_allocator.free(shutdown_cmd); - temporary_allocator.free(restart_cmd); - } + interop.rebootSystem() catch std.log.err("whoopsie doodle, couldn't restart system!", .{}); } } @@ -293,7 +279,7 @@ pub fn main(init: std.process.Init) !void { } if (config_parser.maybe_load_error == null) { - migrator.lateConfigFieldHandler(&state.config); + migrator.lateConfigFieldHandler(&state.config, state.lang); } var maybe_uid_range_error: ?anyerror = null; @@ -374,12 +360,6 @@ pub fn main(init: std.process.Init) !void { try state.log_file.info(state.io, "tui", "using {s} vt", .{if (state.use_kmscon_vt) "kmscon" else "default"}); - // These strings only end up getting freed if the user quits Ly using Ctrl+C, which is fine since in the other cases - // we end up shutting down or restarting the system - shutdown_cmd = try temporary_allocator.dupe(u8, state.config.shutdown_cmd); - restart_cmd = try temporary_allocator.dupe(u8, state.config.restart_cmd); - commands_allocated = true; - if (state.config.start_cmd) |start_cmd| handle_start_cmd: { var process = std.process.spawn(state.io, .{ .argv = &[_][]const u8{ "/bin/sh", "-c", start_cmd }, @@ -469,26 +449,6 @@ pub fn main(init: std.process.Init) !void { ); defer state.restart_label.deinit(); - state.sleep_label = Label.init( - "", - null, - state.buffer.fg, - state.buffer.bg, - null, - null, - ); - defer state.sleep_label.deinit(); - - state.hibernate_label = Label.init( - "", - null, - state.buffer.fg, - state.buffer.bg, - null, - null, - ); - defer state.hibernate_label.deinit(); - state.toggle_password_label = Label.init( "", null, @@ -535,20 +495,6 @@ pub fn main(init: std.process.Init) !void { "{s} {s}", .{ state.config.show_password_key, state.lang.toggle_password }, ); - if (state.config.sleep_cmd != null) { - try state.sleep_label.setTextAlloc( - state.allocator, - "{s} {s}", - .{ state.config.sleep_key, state.lang.sleep }, - ); - } - if (state.config.hibernate_cmd != null) { - try state.hibernate_label.setTextAlloc( - state.allocator, - "{s} {s}", - .{ state.config.hibernate_key, state.lang.hibernate }, - ); - } if (state.config.brightness_down_key) |key| { try state.brightness_down_label.setTextAlloc( state.allocator, @@ -1296,12 +1242,6 @@ pub fn main(init: std.process.Init) !void { if (!state.hide_key_hints) { try layer2.append(state.allocator, state.shutdown_label.widget()); try layer2.append(state.allocator, state.restart_label.widget()); - if (state.config.sleep_cmd != null) { - try layer2.append(state.allocator, state.sleep_label.widget()); - } - if (state.config.hibernate_cmd != null) { - try layer2.append(state.allocator, state.hibernate_label.widget()); - } try layer2.append(state.allocator, state.toggle_password_label.widget()); if (state.config.brightness_down_key != null) { try layer2.append(state.allocator, state.brightness_down_label.widget()); @@ -1372,8 +1312,6 @@ pub fn main(init: std.process.Init) !void { try state.buffer.registerGlobalKeybind(state.io, state.config.shutdown_key, &shutdownCmd, &state); try state.buffer.registerGlobalKeybind(state.io, state.config.restart_key, &restartCmd, &state); try state.buffer.registerGlobalKeybind(state.io, state.config.show_password_key, &togglePasswordMask, &state); - if (state.config.sleep_cmd != null) try state.buffer.registerGlobalKeybind(state.io, state.config.sleep_key, &sleepCmd, &state); - if (state.config.hibernate_cmd != null) try state.buffer.registerGlobalKeybind(state.io, state.config.hibernate_key, &hibernateCmd, &state); if (state.config.brightness_down_key) |key| try state.buffer.registerGlobalKeybind(state.io, key, &decreaseBrightnessCmd, &state); if (state.config.brightness_up_key) |key| try state.buffer.registerGlobalKeybind(state.io, key, &increaseBrightnessCmd, &state); @@ -1787,62 +1725,6 @@ fn restartCmd(ptr: *anyopaque) !bool { return false; } -fn sleepCmd(ptr: *anyopaque) !bool { - var state: *UiState = @ptrCast(@alignCast(ptr)); - - if (state.config.sleep_cmd) |sleep_cmd| { - var process = std.process.spawn(state.io, .{ - .argv = &[_][]const u8{ "/bin/sh", "-c", sleep_cmd }, - .stdout = .ignore, - .stderr = .ignore, - }) catch return false; - - const process_result = process.wait(state.io) catch return false; - if (process_result.exited != 0) { - try state.info_line.addMessage( - state.lang.err_sleep, - state.config.error_bg, - state.config.error_fg, - ); - try state.log_file.err( - state.io, - "sys", - "failed to execute sleep command: exit code {d}", - .{process_result.exited}, - ); - } - } - return false; -} - -fn hibernateCmd(ptr: *anyopaque) !bool { - var state: *UiState = @ptrCast(@alignCast(ptr)); - - if (state.config.hibernate_cmd) |hibernate_cmd| { - var process = std.process.spawn(state.io, .{ - .argv = &[_][]const u8{ "/bin/sh", "-c", hibernate_cmd }, - .stdout = .ignore, - .stderr = .ignore, - }) catch return false; - - const process_result = process.wait(state.io) catch return false; - if (process_result.exited != 0) { - try state.info_line.addMessage( - state.lang.err_hibernate, - state.config.error_bg, - state.config.error_fg, - ); - try state.log_file.err( - state.io, - "sys", - "failed to execute hibernate command: exit code {d}", - .{process_result.exited}, - ); - } - } - return false; -} - fn decreaseBrightnessCmd(ptr: *anyopaque) !bool { var state: *UiState = @ptrCast(@alignCast(ptr)); @@ -2114,8 +1996,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu const labels = [_]?*Label{ &state.shutdown_label, &state.restart_label, - if (state.config.sleep_cmd != null) &state.sleep_label else null, - if (state.config.hibernate_cmd != null) &state.hibernate_label else null, &state.toggle_password_label, if (state.config.brightness_down_key != null) &state.brightness_down_label else null, if (state.config.brightness_up_key != null) &state.brightness_up_label else null, @@ -2347,8 +2227,6 @@ fn positionWidgets(ptr: *anyopaque) !void { // Reset all potential corner widgets to offscreen state.shutdown_label.positionXY(offscreen); state.restart_label.positionXY(offscreen); - state.sleep_label.positionXY(offscreen); - state.hibernate_label.positionXY(offscreen); state.toggle_password_label.positionXY(offscreen); state.brightness_down_label.positionXY(offscreen); state.brightness_up_label.positionXY(offscreen); From 26377fd31908a6ef9a1e62965930ea27db525b6a Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 19:56:24 +0200 Subject: [PATCH 63/77] FreeBSD: Fix compilation Signed-off-by: AnErrupTion --- ly-core/build.zig | 1 + ly-core/src/interop.zig | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ly-core/build.zig b/ly-core/build.zig index 75ecb3f..f62fb2e 100644 --- a/ly-core/build.zig +++ b/ly-core/build.zig @@ -52,6 +52,7 @@ pub fn build(b: *std.Build) void { addCImport(b, mod, translate_c, target, optimize, "kbio", "#include "); addCImport(b, mod, translate_c, target, optimize, "consio", "#include "); addCImport(b, mod, translate_c, target, optimize, "sysctl", "#include "); + addCImport(b, mod, translate_c, target, optimize, "reboot", "#include "); } const mod_tests = b.addTest(.{ diff --git a/ly-core/src/interop.zig b/ly-core/src/interop.zig index 873db15..f04b2a4 100644 --- a/ly-core/src/interop.zig +++ b/ly-core/src/interop.zig @@ -260,13 +260,13 @@ fn PlatformStruct() type { } pub fn shutdownSystemImpl() !void { - if (isError(reboot.reboot(reboot.RB_POWEROFF))) { + if (isError(unistd.reboot(reboot.RB_POWEROFF))) { return error.CouldntShutdown; } } pub fn rebootSystemImpl() !void { - if (isError(reboot.reboot(reboot.RB_AUTOBOOT))) { + if (isError(unistd.reboot(reboot.RB_AUTOBOOT))) { return error.CouldntReboot; } } From 7e6474924c438197aa6dc603e1677465bed74eb5 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 19:57:29 +0200 Subject: [PATCH 64/77] config: Order battery_id alphabetically Signed-off-by: AnErrupTion --- res/config.ini | 12 ++++++------ src/config/Config.zig | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/res/config.ini b/res/config.ini index 0ae21b7..5c63043 100644 --- a/res/config.ini +++ b/res/config.ini @@ -47,12 +47,6 @@ asterisk = * # If set to 0, the animation will never be played auth_fails = 10 -# Identifier for battery whose charge to display at top left -# Primary battery is usually BAT0 or BAT1 -# If set to null, battery status won't be shown -# Unused on FreeBSD (a sysctl is used there) -battery_id = null - # Automatic login configuration # This feature allows Ly to automatically log in a user without password prompt. # IMPORTANT: Both auto_login_user and auto_login_session must be set for this to work. @@ -77,6 +71,12 @@ auto_login_session = null # If null, automatic login is disabled auto_login_user = null +# Identifier for battery whose charge to display at top left +# Primary battery is usually BAT0 or BAT1 +# If set to null, battery status won't be shown +# Unused on FreeBSD (a sysctl is used there) +battery_id = null + # Background color id bg = 0x00000000 diff --git a/src/config/Config.zig b/src/config/Config.zig index f78c169..1be16ec 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -13,10 +13,10 @@ animation_frame_delay: u16 = 5, animation_timeout_sec: u12 = 0, asterisk: ?u32 = '*', auth_fails: u64 = 10, -battery_id: ?[]const u8 = null, auto_login_service: [:0]const u8 = "ly-autologin", auto_login_session: ?[]const u8 = null, auto_login_user: ?[]const u8 = null, +battery_id: ?[]const u8 = null, bg: u32 = 0x00000000, bigclock: Bigclock = .none, bigclock_12hr: bool = false, From 54f1ff14eea4518ea723bf63bf444123f3a57e9d Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 20:17:46 +0200 Subject: [PATCH 65/77] corners: Break up "keys" into individual keys Signed-off-by: AnErrupTion --- res/config.ini | 12 ++-- src/config/Config.zig | 2 +- src/main.zig | 124 ++++++++++++++++++++++++++++-------------- 3 files changed, 91 insertions(+), 47 deletions(-) diff --git a/res/config.ini b/res/config.ini index 5c63043..445022e 100644 --- a/res/config.ini +++ b/res/config.ini @@ -155,7 +155,11 @@ colormix_col3 = 0x20000000 # Screen corners customization # Keywords: -# keys -> Power management, brightness control & toggle password keys +# shutdown -> Shutdown key +# restart -> Restart key +# britup -> Brightness up key +# britdown -> Brightness down key +# password -> Toggle password key # clock -> Clock (format defined by 'clock' option) # tty -> Active TTY number # battery -> Battery percentage @@ -167,8 +171,8 @@ colormix_col3 = 0x20000000 # lbl:name -> Specific custom info label # cmd:key -> Specific custom keybind hint # -# If using a keyword that groups multiple labels into one (e.g. keys, labels, -# binds, ...), they'll be placed horizontally +# If using a keyword that groups multiple labels into one (e.g. labels, binds), +# they'll be placed horizontally # # Also, the order defines the vertical stack (first item is at the edge) # If items are separted by commas, they'll be placed horizontally @@ -181,7 +185,7 @@ corner_bottom_left = version corner_bottom_right = labels # Top left -corner_top_left = keys battery +corner_top_left = shutdown,restart,britup,britdown,password battery # Top right corner_top_right = clock numlock,capslock diff --git a/src/config/Config.zig b/src/config/Config.zig index 1be16ec..a68458d 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -41,7 +41,7 @@ colormix_col2: u32 = 0x000000FF, colormix_col3: u32 = 0x20000000, corner_bottom_left: []const u8 = "version", corner_bottom_right: []const u8 = "labels", -corner_top_left: []const u8 = "keys battery", +corner_top_left: []const u8 = "shutdown,restart,britup,britdown,password battery", corner_top_right: []const u8 = "clock numlock,capslock", custom_bind_width: ?u32 = null, custom_sessions: []const u8 = build_options.config_directory ++ "/ly/custom-sessions", diff --git a/src/main.zig b/src/main.zig index 8ae1227..b008e1c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -102,7 +102,9 @@ const UiState = struct { version_label: Label, bigclock_label: BigLabel, show_tty: bool, - hide_key_hints: bool, + hide_shutdown: bool, + hide_restart: bool, + hide_toggle_password: bool, hide_numlock: bool, hide_capslock: bool, hide_version_string: bool, @@ -421,7 +423,9 @@ pub fn main(init: std.process.Init) !void { std.posix.sigaction(std.posix.SIG.TERM, &act, null); state.show_tty = cornersContain(state, "tty"); - state.hide_key_hints = !cornersContain(state, "keys"); + state.hide_shutdown = !cornersContain(state, "shutdown"); + state.hide_restart = !cornersContain(state, "restart"); + state.hide_toggle_password = !cornersContain(state, "password"); state.hide_numlock = !cornersContain(state, "numlock"); state.hide_capslock = !cornersContain(state, "capslock"); state.hide_version_string = !cornersContain(state, "version"); @@ -479,22 +483,28 @@ pub fn main(init: std.process.Init) !void { ); defer state.brightness_up_label.deinit(); - if (!state.hide_key_hints) { + if (!state.hide_shutdown) { try state.shutdown_label.setTextAlloc( state.allocator, "{s} {s}", .{ state.config.shutdown_key, state.lang.shutdown }, ); + } + if (!state.hide_restart) { try state.restart_label.setTextAlloc( state.allocator, "{s} {s}", .{ state.config.restart_key, state.lang.restart }, ); + } + if (!state.hide_toggle_password) { try state.toggle_password_label.setTextAlloc( state.allocator, "{s} {s}", .{ state.config.show_password_key, state.lang.toggle_password }, ); + } + if (state.config.brightness_down_key != null) { if (state.config.brightness_down_key) |key| { try state.brightness_down_label.setTextAlloc( state.allocator, @@ -502,6 +512,8 @@ pub fn main(init: std.process.Init) !void { .{ key, state.lang.brightness_down }, ); } + } + if (state.config.brightness_up_key != null) { if (state.config.brightness_up_key) |key| { try state.brightness_up_label.setTextAlloc( state.allocator, @@ -1239,16 +1251,26 @@ pub fn main(init: std.process.Init) !void { state.custom_binds.items[state.custom_binds.items.len - 1].lbl.allocator = state.allocator; } } - if (!state.hide_key_hints) { + if (!state.hide_shutdown) { try layer2.append(state.allocator, state.shutdown_label.widget()); + } + if (!state.hide_restart) { try layer2.append(state.allocator, state.restart_label.widget()); + } + if (!state.hide_shutdown) { + try layer2.append(state.allocator, state.shutdown_label.widget()); + } + if (!state.hide_restart) { + try layer2.append(state.allocator, state.restart_label.widget()); + } + if (!state.hide_toggle_password) { try layer2.append(state.allocator, state.toggle_password_label.widget()); - if (state.config.brightness_down_key != null) { - try layer2.append(state.allocator, state.brightness_down_label.widget()); - } - if (state.config.brightness_up_key != null) { - try layer2.append(state.allocator, state.brightness_up_label.widget()); - } + } + if (state.config.brightness_down_key != null) { + try layer2.append(state.allocator, state.brightness_down_label.widget()); + } + if (state.config.brightness_up_key != null) { + try layer2.append(state.allocator, state.brightness_up_label.widget()); } if (state.config.battery_id != null) { try layer2.append(state.allocator, state.battery_label.widget()); @@ -1989,39 +2011,57 @@ const PositionedWidgets = struct { fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, current_y: usize, is_left: bool, is_top: bool, positioned: *PositionedWidgets) !bool { const base_x = state.edge_margin.x; - if (std.mem.eql(u8, item, "keys")) { - var local_x = current_x.*; - var local_y = current_y; - - const labels = [_]?*Label{ - &state.shutdown_label, - &state.restart_label, - &state.toggle_password_label, - if (state.config.brightness_down_key != null) &state.brightness_down_label else null, - if (state.config.brightness_up_key != null) &state.brightness_up_label else null, - }; - - for (labels) |maybe_label| { - const label = maybe_label orelse continue; - const width = TerminalBuffer.strWidth(label.text); - - if (is_left) { - if (local_x + width > state.buffer.width - state.edge_margin.x) { - local_x = base_x; - if (is_top) local_y += 1 else local_y -= 1; - } - label.positionXY(Position.init(local_x, local_y)); - local_x += width + 1; - } else { - if (width + state.edge_margin.x > local_x) { - local_x = state.buffer.width - state.edge_margin.x; - if (is_top) local_y += 1 else local_y -= 1; - } - label.positionXY(Position.init(local_x - width, local_y)); - local_x -= width + 1; - } + if (std.mem.eql(u8, item, "shutdown")) { + const width = TerminalBuffer.strWidth(state.shutdown_label.text); + if (is_left) { + state.shutdown_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.shutdown_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + return true; + } else if (std.mem.eql(u8, item, "restart")) { + const width = TerminalBuffer.strWidth(state.restart_label.text); + if (is_left) { + state.restart_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.restart_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + return true; + } else if (std.mem.eql(u8, item, "britup")) { + if (state.config.brightness_up_key == null) return false; + const width = TerminalBuffer.strWidth(state.brightness_up_label.text); + if (is_left) { + state.brightness_up_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.brightness_up_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + return true; + } else if (std.mem.eql(u8, item, "britdown")) { + if (state.config.brightness_down_key == null) return false; + const width = TerminalBuffer.strWidth(state.brightness_down_label.text); + if (is_left) { + state.brightness_down_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.brightness_down_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; + } + return true; + } else if (std.mem.eql(u8, item, "password")) { + const width = TerminalBuffer.strWidth(state.toggle_password_label.text); + if (is_left) { + state.toggle_password_label.positionXY(Position.init(current_x.*, current_y)); + current_x.* += width + 1; + } else { + state.toggle_password_label.positionXY(Position.init(current_x.* - width, current_y)); + current_x.* -= width + 1; } - current_x.* = local_x; return true; } else if (std.mem.eql(u8, item, "clock") or std.mem.eql(u8, item, "time")) { if (state.config.clock == null) return false; From 018d797ed67327b083af4b6b9084beeb17a439ab Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 20:19:40 +0200 Subject: [PATCH 66/77] Brother what am I doing Signed-off-by: AnErrupTion --- src/main.zig | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main.zig b/src/main.zig index b008e1c..b1a3957 100644 --- a/src/main.zig +++ b/src/main.zig @@ -504,23 +504,19 @@ pub fn main(init: std.process.Init) !void { .{ state.config.show_password_key, state.lang.toggle_password }, ); } - if (state.config.brightness_down_key != null) { - if (state.config.brightness_down_key) |key| { - try state.brightness_down_label.setTextAlloc( - state.allocator, - "{s} {s}", - .{ key, state.lang.brightness_down }, - ); - } + if (state.config.brightness_down_key) |key| { + try state.brightness_down_label.setTextAlloc( + state.allocator, + "{s} {s}", + .{ key, state.lang.brightness_down }, + ); } - if (state.config.brightness_up_key != null) { - if (state.config.brightness_up_key) |key| { - try state.brightness_up_label.setTextAlloc( - state.allocator, - "{s} {s}", - .{ key, state.lang.brightness_up }, - ); - } + if (state.config.brightness_up_key) |key| { + try state.brightness_up_label.setTextAlloc( + state.allocator, + "{s} {s}", + .{ key, state.lang.brightness_up }, + ); } state.numlock_label = Label.init( From e4e399cd076f1ce2bfd9295a2b0f763aa514f52b Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 21:18:49 +0200 Subject: [PATCH 67/77] Allow toggling visibility of shutdown, restart & show password keybinds (closes #993) Signed-off-by: AnErrupTion --- res/config.ini | 9 +++++++-- src/config/Config.zig | 6 +++--- src/main.zig | 43 ++++++++++++++++--------------------------- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/res/config.ini b/res/config.ini index 445022e..081e534 100644 --- a/res/config.ini +++ b/res/config.ini @@ -114,13 +114,15 @@ box_title = null # Brightness decrease command brightness_down_cmd = $PREFIX_DIRECTORY/bin/brightnessctl -q -n s 10%- -# Brightness decrease key combination, or null to disable +# Brightness decrease key combination +# If null, the keybind is disabled and isn't shown brightness_down_key = F5 # Brightness increase command brightness_up_cmd = $PREFIX_DIRECTORY/bin/brightnessctl -q -n s +10% -# Brightness increase key combination, or null to disable +# Brightness increase key combination +# If null, the keybind is disabled and isn't shown brightness_up_key = F6 # Erase password input on failure @@ -343,6 +345,7 @@ numlock = false path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # Specifies the key combination used for restart +# If null, the keybind is disabled and isn't shown restart_key = F2 # Save the current desktop and login as defaults, and load them on startup @@ -368,9 +371,11 @@ setup_cmd = $CONFIG_DIRECTORY/ly/setup.sh shell = true # Specifies the key combination used for showing the password +# If null, the keybind is disabled and isn't shown show_password_key = F7 # Specifies the key combination used for shutdown +# If null, the keybind is disabled and isn't shown shutdown_key = F1 # Command executed when starting Ly (before the TTY is taken control of) diff --git a/src/config/Config.zig b/src/config/Config.zig index a68458d..32e1b97 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -79,14 +79,14 @@ margin_box_h: u8 = 2, margin_box_v: u8 = 1, numlock: bool = false, path: ?[]const u8 = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", -restart_key: []const u8 = "F2", +restart_key: ?[]const u8 = "F2", save: bool = true, service_name: [:0]const u8 = "ly", session_log: ?[]const u8 = "ly-session.log", setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh", shell: bool = true, -show_password_key: []const u8 = "F7", -shutdown_key: []const u8 = "F1", +show_password_key: ?[]const u8 = "F7", +shutdown_key: ?[]const u8 = "F1", start_cmd: ?[]const u8 = null, text_in_center: bool = false, type_username: bool = false, diff --git a/src/main.zig b/src/main.zig index b1a3957..471bb6e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -102,9 +102,6 @@ const UiState = struct { version_label: Label, bigclock_label: BigLabel, show_tty: bool, - hide_shutdown: bool, - hide_restart: bool, - hide_toggle_password: bool, hide_numlock: bool, hide_capslock: bool, hide_version_string: bool, @@ -423,9 +420,6 @@ pub fn main(init: std.process.Init) !void { std.posix.sigaction(std.posix.SIG.TERM, &act, null); state.show_tty = cornersContain(state, "tty"); - state.hide_shutdown = !cornersContain(state, "shutdown"); - state.hide_restart = !cornersContain(state, "restart"); - state.hide_toggle_password = !cornersContain(state, "password"); state.hide_numlock = !cornersContain(state, "numlock"); state.hide_capslock = !cornersContain(state, "capslock"); state.hide_version_string = !cornersContain(state, "version"); @@ -483,25 +477,25 @@ pub fn main(init: std.process.Init) !void { ); defer state.brightness_up_label.deinit(); - if (!state.hide_shutdown) { + if (state.config.shutdown_key) |key| { try state.shutdown_label.setTextAlloc( state.allocator, "{s} {s}", - .{ state.config.shutdown_key, state.lang.shutdown }, + .{ key, state.lang.shutdown }, ); } - if (!state.hide_restart) { + if (state.config.restart_key) |key| { try state.restart_label.setTextAlloc( state.allocator, "{s} {s}", - .{ state.config.restart_key, state.lang.restart }, + .{ key, state.lang.restart }, ); } - if (!state.hide_toggle_password) { + if (state.config.show_password_key) |key| { try state.toggle_password_label.setTextAlloc( state.allocator, "{s} {s}", - .{ state.config.show_password_key, state.lang.toggle_password }, + .{ key, state.lang.toggle_password }, ); } if (state.config.brightness_down_key) |key| { @@ -1021,9 +1015,7 @@ pub fn main(init: std.process.Init) !void { }; } - if (state.show_tty) { - try state.tty_label.setTextBuf(&state.tty_buf, "tty{d}", .{state.active_tty}); - } + try state.tty_label.setTextBuf(&state.tty_buf, "tty{d}", .{state.active_tty}); // Initialize the animation, if any var animation: ?*Widget = null; @@ -1247,19 +1239,13 @@ pub fn main(init: std.process.Init) !void { state.custom_binds.items[state.custom_binds.items.len - 1].lbl.allocator = state.allocator; } } - if (!state.hide_shutdown) { + if (state.config.shutdown_key != null) { try layer2.append(state.allocator, state.shutdown_label.widget()); } - if (!state.hide_restart) { + if (state.config.restart_key != null) { try layer2.append(state.allocator, state.restart_label.widget()); } - if (!state.hide_shutdown) { - try layer2.append(state.allocator, state.shutdown_label.widget()); - } - if (!state.hide_restart) { - try layer2.append(state.allocator, state.restart_label.widget()); - } - if (!state.hide_toggle_password) { + if (state.config.show_password_key != null) { try layer2.append(state.allocator, state.toggle_password_label.widget()); } if (state.config.brightness_down_key != null) { @@ -1327,9 +1313,9 @@ pub fn main(init: std.process.Init) !void { try state.buffer.registerGlobalKeybind(state.io, "Enter", &authenticate, &state); - try state.buffer.registerGlobalKeybind(state.io, state.config.shutdown_key, &shutdownCmd, &state); - try state.buffer.registerGlobalKeybind(state.io, state.config.restart_key, &restartCmd, &state); - try state.buffer.registerGlobalKeybind(state.io, state.config.show_password_key, &togglePasswordMask, &state); + if (state.config.shutdown_key) |key| try state.buffer.registerGlobalKeybind(state.io, key, &shutdownCmd, &state); + if (state.config.restart_key) |key| try state.buffer.registerGlobalKeybind(state.io, key, &restartCmd, &state); + if (state.config.show_password_key) |key| try state.buffer.registerGlobalKeybind(state.io, key, &togglePasswordMask, &state); if (state.config.brightness_down_key) |key| try state.buffer.registerGlobalKeybind(state.io, key, &decreaseBrightnessCmd, &state); if (state.config.brightness_up_key) |key| try state.buffer.registerGlobalKeybind(state.io, key, &increaseBrightnessCmd, &state); @@ -2008,6 +1994,7 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu const base_x = state.edge_margin.x; if (std.mem.eql(u8, item, "shutdown")) { + if (state.config.shutdown_key == null) return false; const width = TerminalBuffer.strWidth(state.shutdown_label.text); if (is_left) { state.shutdown_label.positionXY(Position.init(current_x.*, current_y)); @@ -2018,6 +2005,7 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu } return true; } else if (std.mem.eql(u8, item, "restart")) { + if (state.config.restart_key == null) return false; const width = TerminalBuffer.strWidth(state.restart_label.text); if (is_left) { state.restart_label.positionXY(Position.init(current_x.*, current_y)); @@ -2050,6 +2038,7 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu } return true; } else if (std.mem.eql(u8, item, "password")) { + if (state.config.show_password_key == null) return false; const width = TerminalBuffer.strWidth(state.toggle_password_label.text); if (is_left) { state.toggle_password_label.positionXY(Position.init(current_x.*, current_y)); From a41ebe8f6f33307b3445b91ece675a0f5e4189f4 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 21:33:30 +0200 Subject: [PATCH 68/77] Remove cornersContain() Signed-off-by: AnErrupTion --- src/main.zig | 143 +++++++++++++++++---------------------------------- 1 file changed, 47 insertions(+), 96 deletions(-) diff --git a/src/main.zig b/src/main.zig index 471bb6e..73861c4 100644 --- a/src/main.zig +++ b/src/main.zig @@ -101,12 +101,6 @@ const UiState = struct { password_label: Label, version_label: Label, bigclock_label: BigLabel, - show_tty: bool, - hide_numlock: bool, - hide_capslock: bool, - hide_version_string: bool, - hide_labels: bool, - hide_binds: bool, box: Box, info_line: InfoLine, animate: bool, @@ -419,13 +413,6 @@ pub fn main(init: std.process.Init) !void { }; std.posix.sigaction(std.posix.SIG.TERM, &act, null); - state.show_tty = cornersContain(state, "tty"); - state.hide_numlock = !cornersContain(state, "numlock"); - state.hide_capslock = !cornersContain(state, "capslock"); - state.hide_version_string = !cornersContain(state, "version"); - state.hide_labels = !cornersContain(state, "labels") and !cornersContain(state, "lbl:"); - state.hide_binds = !cornersContain(state, "binds") and !cornersContain(state, "cmd:"); - // Initialize components state.shutdown_label = Label.init( "", @@ -1197,81 +1184,55 @@ pub fn main(init: std.process.Init) !void { item.lbl.deinit(); }; - if (!state.hide_labels) { - var lblIter = custom.labels.iterator(); - // NOTE: Because widgets have a pointer to the underlying Label, we have to ensure - // that the ArrayList doesn't allocate more memory than what we ensured. Otherwise - // the pointer to the Label becomes invalid. - try state.custom_info.ensureTotalCapacity(state.allocator, @intCast(custom.labels.count())); - while (lblIter.next()) |i| { - try state.custom_info.append(state.allocator, .{ - .info = i.value_ptr.*, - .lbl = .init("", null, state.buffer.fg, state.buffer.bg, updateCustomInfo, null), - }); - var latest = &state.custom_info.items[state.custom_info.items.len - 1]; - latest.info.id = latest.lbl.widget().id; - latest.info.counter = 1; - } + var lblIter = custom.labels.iterator(); + // NOTE: Because widgets have a pointer to the underlying Label, we have to ensure + // that the ArrayList doesn't allocate more memory than what we ensured. Otherwise + // the pointer to the Label becomes invalid. + try state.custom_info.ensureTotalCapacity(state.allocator, @intCast(custom.labels.count())); + while (lblIter.next()) |i| { + try state.custom_info.append(state.allocator, .{ + .info = i.value_ptr.*, + .lbl = .init("", null, state.buffer.fg, state.buffer.bg, updateCustomInfo, null), + }); + var latest = &state.custom_info.items[state.custom_info.items.len - 1]; + latest.info.id = latest.lbl.widget().id; + latest.info.counter = 1; } - if (!state.hide_binds) { - var iter = custom.binds.iterator(); - while (iter.next()) |i| { - var concat = try std.mem.concat(state.allocator, u8, &[_][]const u8{ i.key_ptr.*, " ", i.value_ptr.name }); - inline for (@typeInfo(Lang).@"struct".fields) |lang_key| { - const new = try std.mem.replaceOwned(u8, state.allocator, concat, "$" ++ lang_key.name, @field(state.lang, lang_key.name)); - state.allocator.free(concat); - concat = new; - } - try state.custom_binds.append(state.allocator, .{ - .lbl = .init( - concat, - null, - state.buffer.fg, - state.buffer.bg, - null, - null, - ), - .cmd = i.value_ptr.*, - .key = i.key_ptr.*, - .io = state.io, - }); - state.custom_binds.items[state.custom_binds.items.len - 1].lbl.allocator = state.allocator; + var iter = custom.binds.iterator(); + while (iter.next()) |i| { + var concat = try std.mem.concat(state.allocator, u8, &[_][]const u8{ i.key_ptr.*, " ", i.value_ptr.name }); + inline for (@typeInfo(Lang).@"struct".fields) |lang_key| { + const new = try std.mem.replaceOwned(u8, state.allocator, concat, "$" ++ lang_key.name, @field(state.lang, lang_key.name)); + state.allocator.free(concat); + concat = new; } + try state.custom_binds.append(state.allocator, .{ + .lbl = .init( + concat, + null, + state.buffer.fg, + state.buffer.bg, + null, + null, + ), + .cmd = i.value_ptr.*, + .key = i.key_ptr.*, + .io = state.io, + }); + state.custom_binds.items[state.custom_binds.items.len - 1].lbl.allocator = state.allocator; } - if (state.config.shutdown_key != null) { - try layer2.append(state.allocator, state.shutdown_label.widget()); - } - if (state.config.restart_key != null) { - try layer2.append(state.allocator, state.restart_label.widget()); - } - if (state.config.show_password_key != null) { - try layer2.append(state.allocator, state.toggle_password_label.widget()); - } - if (state.config.brightness_down_key != null) { - try layer2.append(state.allocator, state.brightness_down_label.widget()); - } - if (state.config.brightness_up_key != null) { - try layer2.append(state.allocator, state.brightness_up_label.widget()); - } - if (state.config.battery_id != null) { - try layer2.append(state.allocator, state.battery_label.widget()); - } - if (state.config.clock != null) { - try layer2.append(state.allocator, state.clock_label.widget()); - } - if (state.show_tty) { - try layer2.append(state.allocator, state.tty_label.widget()); - } - if (state.config.bigclock != .none) { - try layer2.append(state.allocator, state.bigclock_label.widget()); - } - if (!state.hide_numlock) { - try layer2.append(state.allocator, state.numlock_label.widget()); - } - if (!state.hide_capslock) { - try layer2.append(state.allocator, state.capslock_label.widget()); - } + try layer2.append(state.allocator, state.shutdown_label.widget()); + try layer2.append(state.allocator, state.restart_label.widget()); + try layer2.append(state.allocator, state.toggle_password_label.widget()); + try layer2.append(state.allocator, state.brightness_down_label.widget()); + try layer2.append(state.allocator, state.brightness_up_label.widget()); + try layer2.append(state.allocator, state.battery_label.widget()); + try layer2.append(state.allocator, state.clock_label.widget()); + try layer2.append(state.allocator, state.tty_label.widget()); + try layer2.append(state.allocator, state.bigclock_label.widget()); + try layer2.append(state.allocator, state.numlock_label.widget()); + try layer2.append(state.allocator, state.capslock_label.widget()); try layer2.append(state.allocator, state.box.widget()); try layer2.append(state.allocator, info_line_widget); try layer2.append(state.allocator, state.session_specifier_label.widget()); @@ -1280,9 +1241,7 @@ pub fn main(init: std.process.Init) !void { try layer2.append(state.allocator, login_widget); try layer2.append(state.allocator, state.password_label.widget()); try layer2.append(state.allocator, state.password_widget); - if (!state.hide_version_string) { - try layer2.append(state.allocator, state.version_label.widget()); - } + try layer2.append(state.allocator, state.version_label.widget()); for (state.custom_binds.items) |*item| { try layer2.append(state.allocator, item.lbl.widget()); @@ -1370,15 +1329,6 @@ pub fn main(init: std.process.Init) !void { ); } -fn cornersContain(state: UiState, text: []const u8) bool { - const top_left = std.mem.containsAtLeast(u8, state.config.corner_top_left, 1, text); - const top_right = std.mem.containsAtLeast(u8, state.config.corner_top_right, 1, text); - const bottom_left = std.mem.containsAtLeast(u8, state.config.corner_bottom_left, 1, text); - const bottom_right = std.mem.containsAtLeast(u8, state.config.corner_bottom_right, 1, text); - - return top_left or top_right or bottom_left or bottom_right; -} - fn maxWidths(labels: [][]const u8) usize { var max_width: usize = 0; @@ -2256,6 +2206,7 @@ fn positionWidgets(ptr: *anyopaque) !void { state.brightness_down_label.positionXY(offscreen); state.brightness_up_label.positionXY(offscreen); state.clock_label.positionXY(offscreen); + state.bigclock_label.positionXY(offscreen); state.tty_label.positionXY(offscreen); state.battery_label.positionXY(offscreen); state.version_label.positionXY(offscreen); From 78c7c2e2e85b2c7e1c05ecf62fe1104fb4763105 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 6 Jul 2026 22:11:52 +0200 Subject: [PATCH 69/77] Decouple save file path from config directory (closes #1025) Signed-off-by: AnErrupTion --- res/config.ini | 5 +++-- src/config/Config.zig | 2 +- src/config/migrator.zig | 14 ++++++++++++++ src/main.zig | 14 +++++++------- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/res/config.ini b/res/config.ini index 081e534..8924b1b 100644 --- a/res/config.ini +++ b/res/config.ini @@ -348,8 +348,9 @@ path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # If null, the keybind is disabled and isn't shown restart_key = F2 -# Save the current desktop and login as defaults, and load them on startup -save = true +# Absolute directory for the save file +# If null, current desktop & login won't be saved nor loaded +save_file_dir = $CONFIG_DIRECTORY/ly # Service name (set to ly to use the provided pam config file) service_name = ly diff --git a/src/config/Config.zig b/src/config/Config.zig index 32e1b97..90913ad 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -80,7 +80,7 @@ margin_box_v: u8 = 1, numlock: bool = false, path: ?[]const u8 = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", restart_key: ?[]const u8 = "F2", -save: bool = true, +save_file_dir: ?[]const u8 = build_options.config_directory ++ "/ly", service_name: [:0]const u8 = "ly", session_log: ?[]const u8 = "ly-session.log", setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh", diff --git a/src/config/migrator.zig b/src/config/migrator.zig index 758f44f..4ed4d2e 100644 --- a/src/config/migrator.zig +++ b/src/config/migrator.zig @@ -2,6 +2,7 @@ // Properties removed or changed since 0.6.0 // Color codes interpreted differently since 1.1.0 +const build_options = @import("build_options"); const std = @import("std"); var temporary_allocator = std.heap.page_allocator; @@ -194,6 +195,19 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie return null; } + if (std.mem.eql(u8, field.key, "save")) { + // The option now uses a string for the file's parent directory + var mapped_field = field; + + if (std.mem.eql(u8, field.value, "true")) { + mapped_field.value = build_options.config_directory ++ "/ly"; + } else if (std.mem.eql(u8, field.value, "false")) { + mapped_field.value = "null"; + } + + return mapped_field; + } + // TODO: Dearest Melpert, // I pray this message finds you well, as daylight dwindles and the witching hour // approaches, I find it more and more imperative as time continues that I place diff --git a/src/main.zig b/src/main.zig index 73861c4..85ababf 100644 --- a/src/main.zig +++ b/src/main.zig @@ -224,7 +224,7 @@ pub fn main(init: std.process.Init) !void { } // Load configuration file - defer if (state.config.save) { + defer if (state.config.save_file_dir != null) { state.allocator.free(state.save_path); state.allocator.free(state.old_save_path); }; @@ -266,8 +266,8 @@ pub fn main(init: std.process.Init) !void { state.lang = lang_parser.structure; - if (state.config.save) { - state.save_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "save.txt" }); + if (state.config.save_file_dir) |dir| { + state.save_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ dir, "save.txt" }); state.old_save_path = try std.Io.Dir.path.join(state.allocator, &[_][]const u8{ config_parent_path, "save.ini" }); } @@ -285,7 +285,7 @@ pub fn main(init: std.process.Init) !void { state.has_old_save = false; state.saved_username = null; - if (state.config.save) read_save_file: { + if (state.config.save_file_dir != null) read_save_file: { old_save_parser = migrator.tryMigrateIniSaveFile(state.allocator, state.io, state.old_save_path, &state.saved_users, usernames.items) catch break :read_save_file; // Don't read the new save file if the old one still exists @@ -335,7 +335,7 @@ pub fn main(init: std.process.Init) !void { // If no save file previously existed, fill it up with all usernames // TODO: Add new username with existing save file - if (state.config.save and state.saved_users.user_list.items.len == 0) { + if (state.config.save_file_dir != null and state.saved_users.user_list.items.len == 0) { for (usernames.items) |user| { try state.saved_users.user_list.append(state.allocator, .{ .username = user, @@ -1118,7 +1118,7 @@ pub fn main(init: std.process.Init) !void { // Skip if autologin is active to prevent overriding autologin session var default_input = state.config.default_input; - if (state.config.save and !state.is_autologin) { + if (state.config.save_file_dir != null and !state.is_autologin) { if (state.login_text) |box| { if (state.saved_username) |username| { defer state.allocator.free(username); @@ -1502,7 +1502,7 @@ fn authenticate(ptr: *anyopaque) !bool { try TerminalBuffer.presentBuffer(); } - if (state.config.save) save_last_settings: { + if (state.config.save_file_dir != null) save_last_settings: { // It isn't worth cluttering the code with precise error // handling, so let's just report a generic error message, // that should be good enough for debugging anyway. From 5ccd91c132dbf0b4b7d8905eb3533af00d1e0519 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Tue, 7 Jul 2026 11:51:05 +0200 Subject: [PATCH 70/77] Prepare for Zig 0.17.0 Still requires Zig 0.16.x for now. Signed-off-by: AnErrupTion --- build.zig | 474 +++++++---------------------------- install.zig | 445 ++++++++++++++++++++++++++++++++ ly-core/build.zig.zon | 4 +- ly-ui/build.zig | 2 +- ly-ui/build.zig.zon | 4 +- ly-ui/src/TerminalBuffer.zig | 6 +- ly-ui/src/keyboard.zig | 10 +- 7 files changed, 546 insertions(+), 399 deletions(-) create mode 100644 install.zig diff --git a/build.zig b/build.zig index b4f216c..cdb0d1f 100644 --- a/build.zig +++ b/build.zig @@ -1,7 +1,6 @@ const std = @import("std"); const builtin = @import("builtin"); -const PatchMap = std.StringHashMap([]const u8); const InitSystem = enum { systemd, openrc, @@ -11,6 +10,12 @@ const InitSystem = enum { sysvinit, freebsd, }; +const InstallType = enum { + installexe, + installnoconf, + uninstallexe, + uninstallnoconf, +}; const min_zig_string = "0.16.0"; const current_zig = builtin.zig_version; @@ -25,19 +30,45 @@ comptime { const ly_version = std.SemanticVersion{ .major = 1, .minor = 5, .patch = 0 }; -var dest_directory: []const u8 = undefined; -var config_directory: []const u8 = undefined; -var prefix_directory: []const u8 = undefined; -var executable_name: []const u8 = undefined; -var init_system: InitSystem = undefined; -var default_tty_str: []const u8 = undefined; +fn InstallStep( + b: *std.Build, + target: std.Build.ResolvedTarget, + comptime install_type: InstallType, + dest_directory: []const u8, + config_directory: []const u8, + prefix_directory: []const u8, + executable_name: []const u8, + init_system: InitSystem, + default_tty_str: []const u8, +) *std.Build.Step.Run { + const step = b.addRunArtifact(b.addExecutable(.{ + .name = "install", + .root_module = b.createModule(.{ + .root_source_file = b.path("install.zig"), + .target = target, + }), + })); + step.step.dependOn(b.getInstallStep()); + + step.addArgs(&.{ + std.enums.tagName(InstallType, install_type).?, + dest_directory, + config_directory, + prefix_directory, + executable_name, + std.enums.tagName(InitSystem, init_system).?, + default_tty_str, + }); + + return step; +} pub fn build(b: *std.Build) !void { - dest_directory = b.option([]const u8, "dest_directory", "Specify a destination directory for installation") orelse ""; - config_directory = b.option([]const u8, "config_directory", "Specify a default config directory (default is /etc). This path gets embedded into the binary") orelse "/etc"; - prefix_directory = b.option([]const u8, "prefix_directory", "Specify a default prefix directory (default is /usr)") orelse "/usr"; - executable_name = b.option([]const u8, "name", "Specify installed executable file name (default is ly)") orelse "ly"; - init_system = b.option(InitSystem, "init_system", "Specify the target init system (default is systemd)") orelse .systemd; + const dest_directory = b.option([]const u8, "dest_directory", "Specify a destination directory for installation") orelse ""; + const config_directory = b.option([]const u8, "config_directory", "Specify a default config directory (default is /etc). This path gets embedded into the binary") orelse "/etc"; + const prefix_directory = b.option([]const u8, "prefix_directory", "Specify a default prefix directory (default is /usr)") orelse "/usr"; + const executable_name = b.option([]const u8, "name", "Specify installed executable file name (default is ly)") orelse "ly"; + const init_system = b.option(InitSystem, "init_system", "Specify the target init system (default is systemd)") orelse .systemd; const build_options = b.addOptions(); const version_str = try getVersionStr(b, "ly", ly_version); @@ -47,7 +78,7 @@ pub fn build(b: *std.Build) !void { const fallback_uid_min = b.option(std.posix.uid_t, "fallback_uid_min", "Set the fallback minimum UID (default is 1000). This value gets embedded into the binary") orelse 1000; const fallback_uid_max = b.option(std.posix.uid_t, "fallback_uid_max", "Set the fallback maximum UID (default is 60000). This value gets embedded into the binary") orelse 60000; - default_tty_str = try std.fmt.allocPrint(b.allocator, "{d}", .{default_tty}); + const default_tty_str = try std.fmt.allocPrint(b.allocator, "{d}", .{default_tty}); build_options.addOption([]const u8, "config_directory", config_directory); build_options.addOption([]const u8, "prefix_directory", prefix_directory); @@ -98,296 +129,63 @@ pub fn build(b: *std.Build) !void { b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); - run_cmd.step.dependOn(b.getInstallStep()); - if (b.args) |args| run_cmd.addArgs(args); const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); const installexe_step = b.step("installexe", "Install Ly and the selected init system service"); - installexe_step.makeFn = Installer(true).make; - installexe_step.dependOn(b.getInstallStep()); + installexe_step.dependOn(&InstallStep( + b, + target, + .installexe, + dest_directory, + config_directory, + prefix_directory, + executable_name, + init_system, + default_tty_str, + ).step); const installnoconf_step = b.step("installnoconf", "Install Ly and the selected init system service, but not the configuration file"); - installnoconf_step.makeFn = Installer(false).make; - installnoconf_step.dependOn(b.getInstallStep()); + installnoconf_step.dependOn(&InstallStep( + b, + target, + .installnoconf, + dest_directory, + config_directory, + prefix_directory, + executable_name, + init_system, + default_tty_str, + ).step); const uninstallexe_step = b.step("uninstallexe", "Uninstall Ly and remove the selected init system service"); - uninstallexe_step.makeFn = Uninstaller(true).make; + uninstallexe_step.dependOn(&InstallStep( + b, + target, + .uninstallexe, + dest_directory, + config_directory, + prefix_directory, + executable_name, + init_system, + default_tty_str, + ).step); const uninstallnoconf_step = b.step("uninstallnoconf", "Uninstall Ly and remove the selected init system service, but keep the configuration directory"); - uninstallnoconf_step.makeFn = Uninstaller(false).make; -} - -pub fn Installer(install_config: bool) type { - return struct { - pub fn make(step: *std.Build.Step, _: std.Build.Step.MakeOptions) !void { - var threaded: std.Io.Threaded = .init_single_threaded; - const io = threaded.io(); - const allocator = step.owner.allocator; - - var patch_map = PatchMap.init(allocator); - defer patch_map.deinit(); - - try patch_map.put("$DEFAULT_TTY", default_tty_str); - try patch_map.put("$CONFIG_DIRECTORY", config_directory); - try patch_map.put("$PREFIX_DIRECTORY", prefix_directory); - try patch_map.put("$EXECUTABLE_NAME", executable_name); - - try install_ly(allocator, io, patch_map, install_config); - try install_service(allocator, io, patch_map); - } - }; -} - -fn install_ly(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap, install_config: bool) !void { - const ly_config_directory = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly" }); - - std.Io.Dir.cwd().createDirPath(io, ly_config_directory) catch { - std.debug.print("warn: {s} already exists as a directory.\n", .{ly_config_directory}); - }; - - const ly_custom_sessions_directory = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/custom-sessions" }); - - std.Io.Dir.cwd().createDirPath(io, ly_custom_sessions_directory) catch { - std.debug.print("warn: {s} already exists as a directory.\n", .{ly_custom_sessions_directory}); - }; - - const ly_lang_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/lang" }); - std.Io.Dir.cwd().createDirPath(io, ly_lang_path) catch { - std.debug.print("warn: {s} already exists as a directory.\n", .{ly_lang_path}); - }; - - { - const exe_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" }); - std.Io.Dir.cwd().createDirPath(io, exe_path) catch { - if (!std.mem.eql(u8, dest_directory, "")) { - std.debug.print("warn: {s} already exists as a directory.\n", .{exe_path}); - } - }; - - var executable_dir = std.Io.Dir.cwd().openDir(io, exe_path, .{}) catch unreachable; - defer executable_dir.close(io); - - try installFile(io, "zig-out/bin/ly", executable_dir, exe_path, executable_name, .{}); - } - - { - var config_dir = std.Io.Dir.cwd().openDir(io, ly_config_directory, .{}) catch unreachable; - defer config_dir.close(io); - - if (install_config) { - const patched_config = try patchFile(allocator, io, "res/config.ini", patch_map); - try installText(io, patched_config, config_dir, ly_config_directory, "config.ini", .{}); - - try installFile(io, "res/startup.sh", config_dir, ly_config_directory, "startup.sh", .{ .permissions = .fromMode(0o755) }); - } - - const patched_example_config = try patchFile(allocator, io, "res/config.ini", patch_map); - try installText(io, patched_example_config, config_dir, ly_config_directory, "config.ini.example", .{}); - - const patched_setup = try patchFile(allocator, io, "res/setup.sh", patch_map); - try installText(io, patched_setup, config_dir, ly_config_directory, "setup.sh", .{ .permissions = .fromMode(0o755) }); - - try installFile(io, "res/example.dur", config_dir, ly_config_directory, "example.dur", .{ .permissions = .fromMode(0o755) }); - - try installFile(io, "res/example.lua", config_dir, ly_config_directory, "example.lua", .{ .permissions = .fromMode(0o755) }); - } - - { - var custom_sessions_dir = std.Io.Dir.cwd().openDir(io, ly_custom_sessions_directory, .{}) catch unreachable; - defer custom_sessions_dir.close(io); - - const patched_readme = try patchFile(allocator, io, "res/custom-sessions/README", patch_map); - try installText(io, patched_readme, custom_sessions_dir, ly_custom_sessions_directory, "README", .{}); - } - - { - var lang_dir = std.Io.Dir.cwd().openDir(io, ly_lang_path, .{}) catch unreachable; - defer lang_dir.close(io); - - const languages = [_][]const u8{ - "ar.ini", - "bg.ini", - "cat.ini", - "cs.ini", - "de.ini", - "en.ini", - "eo.ini", - "es.ini", - "fr.ini", - "it.ini", - "ja_JP.ini", - "ku.ini", - "lv.ini", - "pl.ini", - "pt.ini", - "pt_BR.ini", - "ro.ini", - "ru.ini", - "sr.ini", - "sr_Cyrl.ini", - "sv.ini", - "tr.ini", - "uk.ini", - "zh_CN.ini", - "zh_TW.ini", - }; - - inline for (languages) |language| { - try installFile(io, "res/lang/" ++ language, lang_dir, ly_lang_path, language, .{}); - } - } - - { - const pam_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/pam.d" }); - std.Io.Dir.cwd().createDirPath(io, pam_path) catch { - if (!std.mem.eql(u8, dest_directory, "")) { - std.debug.print("warn: {s} already exists as a directory.\n", .{pam_path}); - } - }; - - var pam_dir = std.Io.Dir.cwd().openDir(io, pam_path, .{}) catch unreachable; - defer pam_dir.close(io); - - try installFile(io, if (init_system == .freebsd) "res/pam.d/ly-freebsd" else "res/pam.d/ly-linux", pam_dir, pam_path, "ly", .{ .permissions = .fromMode(0o644) }); - try installFile(io, if (init_system == .freebsd) "res/pam.d/ly-freebsd-autologin" else "res/pam.d/ly-linux-autologin", pam_dir, pam_path, "ly-autologin", .{ .permissions = .fromMode(0o644) }); - } -} - -fn install_service(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap) !void { - switch (init_system) { - .systemd => { - const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/lib/systemd/system" }); - std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; - var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; - defer service_dir.close(io); - - const patched_service = try patchFile(allocator, io, "res/ly@.service", patch_map); - try installText(io, patched_service, service_dir, service_path, "ly@.service", .{ .permissions = .fromMode(0o644) }); - - const patched_kmsconvt_service = try patchFile(allocator, io, "res/ly-kmsconvt@.service", patch_map); - try installText(io, patched_kmsconvt_service, service_dir, service_path, "ly-kmsconvt@.service", .{ .permissions = .fromMode(0o644) }); - }, - .openrc => { - const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" }); - std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; - var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; - defer service_dir.close(io); - - const patched_service = try patchFile(allocator, io, "res/ly-openrc", patch_map); - try installText(io, patched_service, service_dir, service_path, executable_name, .{ .permissions = .fromMode(0o755) }); - }, - .runit => { - const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/sv/ly" }); - std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; - var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; - defer service_dir.close(io); - - const supervise_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ service_path, "supervise" }); - - const patched_conf = try patchFile(allocator, io, "res/ly-runit-service/conf", patch_map); - try installText(io, patched_conf, service_dir, service_path, "conf", .{}); - - try installFile(io, "res/ly-runit-service/finish", service_dir, service_path, "finish", .{ .permissions = .fromMode(0o755) }); - - const patched_run = try patchFile(allocator, io, "res/ly-runit-service/run", patch_map); - try installText(io, patched_run, service_dir, service_path, "run", .{ .permissions = .fromMode(0o755) }); - - std.Io.Dir.cwd().symLink(io, "/run/runit/supervise.ly", supervise_path, .{}) catch |err| { - if (err == error.PathAlreadyExists) { - std.debug.print("warn: /run/runit/supervise.ly already exists as a symbolic link.\n", .{}); - } else { - return err; - } - }; - std.debug.print("info: installed symlink /run/runit/supervise.ly\n", .{}); - }, - .s6 => { - const admin_service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/adminsv/default/contents.d" }); - std.Io.Dir.cwd().createDirPath(io, admin_service_path) catch {}; - var admin_service_dir = std.Io.Dir.cwd().openDir(io, admin_service_path, .{}) catch unreachable; - defer admin_service_dir.close(io); - - const file = try admin_service_dir.createFile(io, "ly-srv", .{}); - file.close(io); - - const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/sv/ly-srv" }); - std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; - var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; - defer service_dir.close(io); - - const patched_run = try patchFile(allocator, io, "res/ly-s6/run", patch_map); - try installText(io, patched_run, service_dir, service_path, "run", .{ .permissions = .fromMode(0o755) }); - - try installFile(io, "res/ly-s6/type", service_dir, service_path, "type", .{}); - }, - .dinit => { - const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/dinit.d" }); - std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; - var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; - defer service_dir.close(io); - - const patched_service = try patchFile(allocator, io, "res/ly-dinit", patch_map); - try installText(io, patched_service, service_dir, service_path, "ly", .{}); - }, - .sysvinit => { - const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" }); - std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; - var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; - defer service_dir.close(io); - - const patched_service = try patchFile(allocator, io, "res/ly-sysvinit", patch_map); - try installText(io, patched_service, service_dir, service_path, "ly", .{ .permissions = .fromMode(0o755) }); - }, - .freebsd => { - const exe_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" }); - var executable_dir = std.Io.Dir.cwd().openDir(io, exe_path, .{}) catch unreachable; - defer executable_dir.close(io); - - const patched_wrapper = try patchFile(allocator, io, "res/ly-freebsd-wrapper", patch_map); - try installText(io, patched_wrapper, executable_dir, exe_path, "ly_wrapper", .{ .permissions = .fromMode(0o755) }); - }, - } -} - -pub fn Uninstaller(uninstall_config: bool) type { - return struct { - pub fn make(step: *std.Build.Step, _: std.Build.Step.MakeOptions) !void { - var threaded: std.Io.Threaded = .init_single_threaded; - const io = threaded.io(); - const allocator = step.owner.allocator; - - if (uninstall_config) { - try deleteTree(allocator, io, config_directory, "/ly", "ly config directory not found"); - } - - const exe_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ prefix_directory, "/bin/", executable_name }); - var success = true; - std.Io.Dir.cwd().deleteFile(io, exe_path) catch { - std.debug.print("warn: ly executable not found\n", .{}); - success = false; - }; - if (success) std.debug.print("info: deleted {s}\n", .{exe_path}); - - try deleteFile(allocator, io, config_directory, "/pam.d/ly", "ly pam file not found"); - - switch (init_system) { - .systemd => try deleteFile(allocator, io, prefix_directory, "/lib/systemd/system/ly@.service", "systemd service not found"), - .openrc => try deleteFile(allocator, io, config_directory, "/init.d/ly", "openrc service not found"), - .runit => try deleteTree(allocator, io, config_directory, "/sv/ly", "runit service not found"), - .s6 => { - try deleteTree(allocator, io, config_directory, "/s6/sv/ly-srv", "s6 service not found"); - try deleteFile(allocator, io, config_directory, "/s6/adminsv/default/contents.d/ly-srv", "s6 admin service not found"); - }, - .dinit => try deleteFile(allocator, io, config_directory, "/dinit.d/ly", "dinit service not found"), - .sysvinit => try deleteFile(allocator, io, config_directory, "/init.d/ly", "sysvinit service not found"), - .freebsd => try deleteFile(allocator, io, prefix_directory, "/bin/ly_wrapper", "freebsd wrapper not found"), - } - } - }; + uninstallnoconf_step.dependOn(&InstallStep( + b, + target, + .uninstallnoconf, + dest_directory, + config_directory, + prefix_directory, + executable_name, + init_system, + default_tty_str, + ).step); } fn getVersionStr(b: *std.Build, name: []const u8, version: std.SemanticVersion) ![]const u8 { @@ -444,99 +242,3 @@ fn getVersionStr(b: *std.Build, name: []const u8, version: std.SemanticVersion) }, } } - -fn installFile( - io: std.Io, - source_file: []const u8, - destination_directory: std.Io.Dir, - destination_directory_path: []const u8, - destination_file: []const u8, - options: std.Io.Dir.CopyFileOptions, -) !void { - try std.Io.Dir.cwd().copyFile(source_file, destination_directory, destination_file, io, options); - std.debug.print("info: installed {s}/{s}\n", .{ destination_directory_path, destination_file }); -} - -fn patchFile(allocator: std.mem.Allocator, io: std.Io, source_file: []const u8, patch_map: PatchMap) ![]const u8 { - var file = try std.Io.Dir.cwd().openFile(io, source_file, .{}); - defer file.close(io); - - const stat = try file.stat(io); - - var buffer: [4096]u8 = undefined; - var reader = file.reader(io, &buffer); - var text = try reader.interface.readAlloc(allocator, @intCast(stat.size)); - - var iterator = patch_map.iterator(); - while (iterator.next()) |kv| { - const new_text = try std.mem.replaceOwned(u8, allocator, text, kv.key_ptr.*, kv.value_ptr.*); - allocator.free(text); - text = new_text; - } - - return text; -} - -fn installText( - io: std.Io, - text: []const u8, - destination_directory: std.Io.Dir, - destination_directory_path: []const u8, - destination_file: []const u8, - options: std.Io.File.CreateFlags, -) !void { - var file = try destination_directory.createFile(io, destination_file, options); - defer file.close(io); - - var buffer: [1024]u8 = undefined; - var writer = file.writer(io, &buffer); - try writer.interface.writeAll(text); - try writer.interface.flush(); - - std.debug.print("info: installed {s}/{s}\n", .{ destination_directory_path, destination_file }); -} - -fn deleteFile( - allocator: std.mem.Allocator, - io: std.Io, - prefix: []const u8, - file: []const u8, - warning: []const u8, -) !void { - const path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix, file }); - - std.Io.Dir.cwd().deleteFile(io, path) catch |err| { - if (err == error.FileNotFound) { - std.debug.print("warn: {s}\n", .{warning}); - return; - } - - return err; - }; - - std.debug.print("info: deleted {s}\n", .{path}); -} - -fn deleteTree( - allocator: std.mem.Allocator, - io: std.Io, - prefix: []const u8, - directory: []const u8, - warning: []const u8, -) !void { - const path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix, directory }); - - var dir = std.Io.Dir.cwd().openDir(io, path, .{}) catch |err| { - if (err == error.FileNotFound) { - std.debug.print("warn: {s}\n", .{warning}); - return; - } - - return err; - }; - dir.close(io); - - try std.Io.Dir.cwd().deleteTree(io, path); - - std.debug.print("info: deleted {s}\n", .{path}); -} diff --git a/install.zig b/install.zig new file mode 100644 index 0000000..b5649cd --- /dev/null +++ b/install.zig @@ -0,0 +1,445 @@ +const std = @import("std"); + +const PatchMap = std.StringHashMap([]const u8); +const InitSystem = enum { + systemd, + openrc, + runit, + s6, + dinit, + sysvinit, + freebsd, +}; +const InstallType = enum { + installexe, + installnoconf, + uninstallexe, + uninstallnoconf, +}; + +var dest_directory: []const u8 = undefined; +var config_directory: []const u8 = undefined; +var prefix_directory: []const u8 = undefined; +var executable_name: []const u8 = undefined; +var init_system: InitSystem = undefined; + +pub fn main(init: std.process.Init) !void { + const io = init.io; + const allocator = init.gpa; + + var args = init.minimal.args.iterate(); + if (!args.skip()) return error.NoProgramName; + + const install_type = std.meta.stringToEnum(InstallType, args.next().?).?; + dest_directory = args.next().?; + config_directory = args.next().?; + prefix_directory = args.next().?; + executable_name = args.next().?; + init_system = std.meta.stringToEnum(InitSystem, args.next().?).?; + const default_tty_str = args.next().?; + + switch (install_type) { + .installexe, .installnoconf => { + var patch_map = PatchMap.init(allocator); + defer patch_map.deinit(); + + try patch_map.put("$DEFAULT_TTY", default_tty_str); + try patch_map.put("$CONFIG_DIRECTORY", config_directory); + try patch_map.put("$PREFIX_DIRECTORY", prefix_directory); + try patch_map.put("$EXECUTABLE_NAME", executable_name); + + try installLy(allocator, io, patch_map, install_type == .installexe); + try installService(allocator, io, patch_map); + }, + .uninstallexe, .uninstallnoconf => { + if (install_type == .uninstallexe) { + try deleteTree(allocator, io, config_directory, "/ly", "ly config directory not found"); + } + + const exe_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ prefix_directory, "/bin/", executable_name }); + defer allocator.free(exe_path); + + var success = true; + std.Io.Dir.cwd().deleteFile(io, exe_path) catch { + std.debug.print("warn: ly executable not found\n", .{}); + success = false; + }; + if (success) std.debug.print("info: deleted {s}\n", .{exe_path}); + + try deleteFile(allocator, io, config_directory, "/pam.d/ly", "ly pam file not found"); + + switch (init_system) { + .systemd => try deleteFile(allocator, io, prefix_directory, "/lib/systemd/system/ly@.service", "systemd service not found"), + .openrc => try deleteFile(allocator, io, config_directory, "/init.d/ly", "openrc service not found"), + .runit => try deleteTree(allocator, io, config_directory, "/sv/ly", "runit service not found"), + .s6 => { + try deleteTree(allocator, io, config_directory, "/s6/sv/ly-srv", "s6 service not found"); + try deleteFile(allocator, io, config_directory, "/s6/adminsv/default/contents.d/ly-srv", "s6 admin service not found"); + }, + .dinit => try deleteFile(allocator, io, config_directory, "/dinit.d/ly", "dinit service not found"), + .sysvinit => try deleteFile(allocator, io, config_directory, "/init.d/ly", "sysvinit service not found"), + .freebsd => try deleteFile(allocator, io, prefix_directory, "/bin/ly_wrapper", "freebsd wrapper not found"), + } + }, + } +} + +fn installLy(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap, install_config: bool) !void { + const ly_config_directory = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly" }); + defer allocator.free(ly_config_directory); + + std.Io.Dir.cwd().createDirPath(io, ly_config_directory) catch { + std.debug.print("warn: {s} already exists as a directory.\n", .{ly_config_directory}); + }; + + const ly_custom_sessions_directory = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/custom-sessions" }); + defer allocator.free(ly_custom_sessions_directory); + + std.Io.Dir.cwd().createDirPath(io, ly_custom_sessions_directory) catch { + std.debug.print("warn: {s} already exists as a directory.\n", .{ly_custom_sessions_directory}); + }; + + const ly_lang_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/lang" }); + defer allocator.free(ly_lang_path); + + std.Io.Dir.cwd().createDirPath(io, ly_lang_path) catch { + std.debug.print("warn: {s} already exists as a directory.\n", .{ly_lang_path}); + }; + + { + const exe_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" }); + defer allocator.free(exe_path); + + std.Io.Dir.cwd().createDirPath(io, exe_path) catch { + if (!std.mem.eql(u8, dest_directory, "")) { + std.debug.print("warn: {s} already exists as a directory.\n", .{exe_path}); + } + }; + + var executable_dir = std.Io.Dir.cwd().openDir(io, exe_path, .{}) catch unreachable; + defer executable_dir.close(io); + + try installFile(io, "zig-out/bin/ly", executable_dir, exe_path, executable_name, .{}); + } + + { + var config_dir = std.Io.Dir.cwd().openDir(io, ly_config_directory, .{}) catch unreachable; + defer config_dir.close(io); + + if (install_config) { + const patched_config = try patchFile(allocator, io, "res/config.ini", patch_map); + defer allocator.free(patched_config); + + try installText(io, patched_config, config_dir, ly_config_directory, "config.ini", .{}); + + try installFile(io, "res/startup.sh", config_dir, ly_config_directory, "startup.sh", .{ .permissions = .fromMode(0o755) }); + } + + const patched_example_config = try patchFile(allocator, io, "res/config.ini", patch_map); + defer allocator.free(patched_example_config); + + try installText(io, patched_example_config, config_dir, ly_config_directory, "config.ini.example", .{}); + + const patched_setup = try patchFile(allocator, io, "res/setup.sh", patch_map); + defer allocator.free(patched_setup); + + try installText(io, patched_setup, config_dir, ly_config_directory, "setup.sh", .{ .permissions = .fromMode(0o755) }); + + try installFile(io, "res/example.dur", config_dir, ly_config_directory, "example.dur", .{ .permissions = .fromMode(0o755) }); + + try installFile(io, "res/example.lua", config_dir, ly_config_directory, "example.lua", .{ .permissions = .fromMode(0o755) }); + } + + { + var custom_sessions_dir = std.Io.Dir.cwd().openDir(io, ly_custom_sessions_directory, .{}) catch unreachable; + defer custom_sessions_dir.close(io); + + const patched_readme = try patchFile(allocator, io, "res/custom-sessions/README", patch_map); + defer allocator.free(patched_readme); + + try installText(io, patched_readme, custom_sessions_dir, ly_custom_sessions_directory, "README", .{}); + } + + { + var lang_dir = std.Io.Dir.cwd().openDir(io, ly_lang_path, .{}) catch unreachable; + defer lang_dir.close(io); + + const languages = [_][]const u8{ + "ar.ini", + "bg.ini", + "cat.ini", + "cs.ini", + "de.ini", + "en.ini", + "eo.ini", + "es.ini", + "fr.ini", + "it.ini", + "ja_JP.ini", + "ku.ini", + "lv.ini", + "pl.ini", + "pt.ini", + "pt_BR.ini", + "ro.ini", + "ru.ini", + "sr.ini", + "sr_Cyrl.ini", + "sv.ini", + "tr.ini", + "uk.ini", + "zh_CN.ini", + "zh_TW.ini", + }; + + inline for (languages) |language| { + try installFile(io, "res/lang/" ++ language, lang_dir, ly_lang_path, language, .{}); + } + } + + { + const pam_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/pam.d" }); + defer allocator.free(pam_path); + + std.Io.Dir.cwd().createDirPath(io, pam_path) catch { + if (!std.mem.eql(u8, dest_directory, "")) { + std.debug.print("warn: {s} already exists as a directory.\n", .{pam_path}); + } + }; + + var pam_dir = std.Io.Dir.cwd().openDir(io, pam_path, .{}) catch unreachable; + defer pam_dir.close(io); + + try installFile(io, if (init_system == .freebsd) "res/pam.d/ly-freebsd" else "res/pam.d/ly-linux", pam_dir, pam_path, "ly", .{ .permissions = .fromMode(0o644) }); + try installFile(io, if (init_system == .freebsd) "res/pam.d/ly-freebsd-autologin" else "res/pam.d/ly-linux-autologin", pam_dir, pam_path, "ly-autologin", .{ .permissions = .fromMode(0o644) }); + } +} + +fn installService(allocator: std.mem.Allocator, io: std.Io, patch_map: PatchMap) !void { + switch (init_system) { + .systemd => { + const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/lib/systemd/system" }); + defer allocator.free(service_path); + + std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; + var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; + defer service_dir.close(io); + + const patched_service = try patchFile(allocator, io, "res/ly@.service", patch_map); + defer allocator.free(patched_service); + + try installText(io, patched_service, service_dir, service_path, "ly@.service", .{ .permissions = .fromMode(0o644) }); + + const patched_kmsconvt_service = try patchFile(allocator, io, "res/ly-kmsconvt@.service", patch_map); + defer allocator.free(patched_kmsconvt_service); + + try installText(io, patched_kmsconvt_service, service_dir, service_path, "ly-kmsconvt@.service", .{ .permissions = .fromMode(0o644) }); + }, + .openrc => { + const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" }); + defer allocator.free(service_path); + + std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; + var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; + defer service_dir.close(io); + + const patched_service = try patchFile(allocator, io, "res/ly-openrc", patch_map); + defer allocator.free(patched_service); + + try installText(io, patched_service, service_dir, service_path, executable_name, .{ .permissions = .fromMode(0o755) }); + }, + .runit => { + const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/sv/ly" }); + defer allocator.free(service_path); + + std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; + var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; + defer service_dir.close(io); + + const supervise_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ service_path, "supervise" }); + defer allocator.free(supervise_path); + + const patched_conf = try patchFile(allocator, io, "res/ly-runit-service/conf", patch_map); + defer allocator.free(patched_conf); + + try installText(io, patched_conf, service_dir, service_path, "conf", .{}); + + try installFile(io, "res/ly-runit-service/finish", service_dir, service_path, "finish", .{ .permissions = .fromMode(0o755) }); + + const patched_run = try patchFile(allocator, io, "res/ly-runit-service/run", patch_map); + defer allocator.free(patched_run); + + try installText(io, patched_run, service_dir, service_path, "run", .{ .permissions = .fromMode(0o755) }); + + std.Io.Dir.cwd().symLink(io, "/run/runit/supervise.ly", supervise_path, .{}) catch |err| { + if (err == error.PathAlreadyExists) { + std.debug.print("warn: /run/runit/supervise.ly already exists as a symbolic link.\n", .{}); + } else { + return err; + } + }; + std.debug.print("info: installed symlink /run/runit/supervise.ly\n", .{}); + }, + .s6 => { + const admin_service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/adminsv/default/contents.d" }); + std.Io.Dir.cwd().createDirPath(io, admin_service_path) catch {}; + defer allocator.free(admin_service_path); + + var admin_service_dir = std.Io.Dir.cwd().openDir(io, admin_service_path, .{}) catch unreachable; + defer admin_service_dir.close(io); + + const file = try admin_service_dir.createFile(io, "ly-srv", .{}); + file.close(io); + + const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/sv/ly-srv" }); + defer allocator.free(service_path); + + std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; + var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; + defer service_dir.close(io); + + const patched_run = try patchFile(allocator, io, "res/ly-s6/run", patch_map); + defer allocator.free(patched_run); + + try installText(io, patched_run, service_dir, service_path, "run", .{ .permissions = .fromMode(0o755) }); + + try installFile(io, "res/ly-s6/type", service_dir, service_path, "type", .{}); + }, + .dinit => { + const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/dinit.d" }); + defer allocator.free(service_path); + + std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; + var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; + defer service_dir.close(io); + + const patched_service = try patchFile(allocator, io, "res/ly-dinit", patch_map); + defer allocator.free(patched_service); + + try installText(io, patched_service, service_dir, service_path, "ly", .{}); + }, + .sysvinit => { + const service_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" }); + defer allocator.free(service_path); + + std.Io.Dir.cwd().createDirPath(io, service_path) catch {}; + var service_dir = std.Io.Dir.cwd().openDir(io, service_path, .{}) catch unreachable; + defer service_dir.close(io); + + const patched_service = try patchFile(allocator, io, "res/ly-sysvinit", patch_map); + defer allocator.free(patched_service); + + try installText(io, patched_service, service_dir, service_path, "ly", .{ .permissions = .fromMode(0o755) }); + }, + .freebsd => { + const exe_path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" }); + defer allocator.free(exe_path); + + var executable_dir = std.Io.Dir.cwd().openDir(io, exe_path, .{}) catch unreachable; + defer executable_dir.close(io); + + const patched_wrapper = try patchFile(allocator, io, "res/ly-freebsd-wrapper", patch_map); + defer allocator.free(patched_wrapper); + + try installText(io, patched_wrapper, executable_dir, exe_path, "ly_wrapper", .{ .permissions = .fromMode(0o755) }); + }, + } +} + +fn installFile( + io: std.Io, + source_file: []const u8, + destination_directory: std.Io.Dir, + destination_directory_path: []const u8, + destination_file: []const u8, + options: std.Io.Dir.CopyFileOptions, +) !void { + try std.Io.Dir.cwd().copyFile(source_file, destination_directory, destination_file, io, options); + std.debug.print("info: installed {s}/{s}\n", .{ destination_directory_path, destination_file }); +} + +fn patchFile(allocator: std.mem.Allocator, io: std.Io, source_file: []const u8, patch_map: PatchMap) ![]const u8 { + var file = try std.Io.Dir.cwd().openFile(io, source_file, .{}); + defer file.close(io); + + const stat = try file.stat(io); + + var buffer: [4096]u8 = undefined; + var reader = file.reader(io, &buffer); + var text = try reader.interface.readAlloc(allocator, @intCast(stat.size)); + + var iterator = patch_map.iterator(); + while (iterator.next()) |kv| { + const new_text = try std.mem.replaceOwned(u8, allocator, text, kv.key_ptr.*, kv.value_ptr.*); + allocator.free(text); + text = new_text; + } + + return text; +} + +fn installText( + io: std.Io, + text: []const u8, + destination_directory: std.Io.Dir, + destination_directory_path: []const u8, + destination_file: []const u8, + options: std.Io.File.CreateFlags, +) !void { + var file = try destination_directory.createFile(io, destination_file, options); + defer file.close(io); + + var buffer: [1024]u8 = undefined; + var writer = file.writer(io, &buffer); + try writer.interface.writeAll(text); + try writer.interface.flush(); + + std.debug.print("info: installed {s}/{s}\n", .{ destination_directory_path, destination_file }); +} + +fn deleteFile( + allocator: std.mem.Allocator, + io: std.Io, + prefix: []const u8, + file: []const u8, + warning: []const u8, +) !void { + const path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix, file }); + defer allocator.free(path); + + std.Io.Dir.cwd().deleteFile(io, path) catch |err| { + if (err == error.FileNotFound) { + std.debug.print("warn: {s}\n", .{warning}); + return; + } + + return err; + }; + + std.debug.print("info: deleted {s}\n", .{path}); +} + +fn deleteTree( + allocator: std.mem.Allocator, + io: std.Io, + prefix: []const u8, + directory: []const u8, + warning: []const u8, +) !void { + const path = try std.Io.Dir.path.join(allocator, &[_][]const u8{ dest_directory, prefix, directory }); + defer allocator.free(path); + + var dir = std.Io.Dir.cwd().openDir(io, path, .{}) catch |err| { + if (err == error.FileNotFound) { + std.debug.print("warn: {s}\n", .{warning}); + return; + } + + return err; + }; + dir.close(io); + + try std.Io.Dir.cwd().deleteTree(io, path); + + std.debug.print("info: deleted {s}\n", .{path}); +} diff --git a/ly-core/build.zig.zon b/ly-core/build.zig.zon index b40c8f8..0d84326 100644 --- a/ly-core/build.zig.zon +++ b/ly-core/build.zig.zon @@ -9,8 +9,8 @@ .hash = "zigini-0.5.0-BSkB7e9WAACfyCBABNZiWL3gFMw18GKn3qBcPs8L1Ec1", }, .translate_c = .{ - .url = "git+https://codeberg.org/ziglang/translate-c#7a1a9fdc4ab00835748a6657ecbb835e3d5d45f7", - .hash = "translate_c-0.0.0-Q_BUWvP1BgCjAk6PWv5286tOlvzD9-X-NkuTzh0KxY0Q", + .url = "git+https://codeberg.org/ziglang/translate-c?ref=zig-0.16.x#6fe0ffc4549f15c5f2d9432c2b4460ba90ff85ac", + .hash = "translate_c-1.0.0-Q_BUWo_5BgD4flHdUhA31zOz0XvZk9k7lQv1ouzyNXj2", }, }, .paths = .{ diff --git a/ly-ui/build.zig b/ly-ui/build.zig index 0ab5b70..b13633f 100644 --- a/ly-ui/build.zig +++ b/ly-ui/build.zig @@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void { .optimize = optimize, .enable_x11_support = enable_x11_support, .fallback_uid_min = fallback_uid_min, - .fallback_uid_max = fallback_uid_max + .fallback_uid_max = fallback_uid_max, }); mod.addImport("ly-core", ly_core.module("ly-core")); diff --git a/ly-ui/build.zig.zon b/ly-ui/build.zig.zon index 2a7e175..68131d1 100644 --- a/ly-ui/build.zig.zon +++ b/ly-ui/build.zig.zon @@ -12,8 +12,8 @@ .hash = "N-V-__8AAAUXBQD6Fwpi9m0MBqWXFFaqW5l1lVrJC2Ynj7a-", }, .translate_c = .{ - .url = "git+https://codeberg.org/ziglang/translate-c#7a1a9fdc4ab00835748a6657ecbb835e3d5d45f7", - .hash = "translate_c-0.0.0-Q_BUWvP1BgCjAk6PWv5286tOlvzD9-X-NkuTzh0KxY0Q", + .url = "git+https://codeberg.org/ziglang/translate-c?ref=zig-0.16.x#6fe0ffc4549f15c5f2d9432c2b4460ba90ff85ac", + .hash = "translate_c-1.0.0-Q_BUWo_5BgD4flHdUhA31zOz0XvZk9k7lQv1ouzyNXj2", }, }, .paths = .{ diff --git a/ly-ui/src/TerminalBuffer.zig b/ly-ui/src/TerminalBuffer.zig index 9dfa1f3..7ead34f 100644 --- a/ly-ui/src/TerminalBuffer.zig +++ b/ly-ui/src/TerminalBuffer.zig @@ -578,9 +578,9 @@ fn parseKeybind(self: *TerminalBuffer, io: std.Io, keybind: []const u8) !keyboar while (iterator.next()) |item| { var found = false; - inline for (std.meta.fields(keyboard.Key)) |field| { - if (std.ascii.eqlIgnoreCase(field.name, item)) { - @field(key, field.name) = true; + inline for (comptime std.meta.fieldNames(keyboard.Key)) |name| { + if (std.ascii.eqlIgnoreCase(name, item)) { + @field(key, name) = true; found = true; break; } diff --git a/ly-ui/src/keyboard.zig b/ly-ui/src/keyboard.zig index 626f21f..16b9e77 100644 --- a/ly-ui/src/keyboard.zig +++ b/ly-ui/src/keyboard.zig @@ -113,14 +113,14 @@ pub const Key = packed struct { pub fn getEnabledPrintableAscii(self: Key) ?u8 { if (self.ctrl or self.alt) return null; - inline for (std.meta.fields(Key)) |field| { - if (field.name.len == 1 and std.ascii.isPrint(field.name[0]) and @field(self, field.name)) { + inline for (comptime std.meta.fieldNames(Key)) |name| { + if (name.len == 1 and std.ascii.isPrint(name[0]) and @field(self, name)) { if (self.shift) { - if (!std.ascii.isAlphanumeric(field.name[0])) return null; - return std.ascii.toUpper(field.name[0]); + if (!std.ascii.isAlphanumeric(name[0])) return null; + return std.ascii.toUpper(name[0]); } - return field.name[0]; + return name[0]; } } From fb544b33578be6dda9c9b87d67adee42e60f16e3 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Tue, 7 Jul 2026 12:22:43 +0200 Subject: [PATCH 71/77] Change default box_position_v to 0.5 This can potentially be confusing to users. Signed-off-by: AnErrupTion --- res/config.ini | 4 ++-- src/config/Config.zig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/config.ini b/res/config.ini index 8924b1b..2bd2624 100644 --- a/res/config.ini +++ b/res/config.ini @@ -104,8 +104,8 @@ border_fg = 0x00FFFFFF box_position_h = 0.5 # Relative vertical position from the bottom of the screen -# default: 0.4 -box_position_v = 0.4 +# default: 0.5 +box_position_v = 0.5 # Title to show at the top of the main box # If set to null, none will be shown diff --git a/src/config/Config.zig b/src/config/Config.zig index 90913ad..2ba8444 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -24,7 +24,7 @@ bigclock_seconds: bool = false, blank_box: bool = true, border_fg: u32 = 0x00FFFFFF, box_position_h: f32 = 0.5, -box_position_v: f32 = 0.4, +box_position_v: f32 = 0.5, box_title: ?[]const u8 = null, brightness_down_cmd: [:0]const u8 = build_options.prefix_directory ++ "/bin/brightnessctl -q -n s 10%-", brightness_down_key: ?[]const u8 = "F5", From 014a00d33ec76358824dcbabab5ff1ca90347cfd Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Tue, 7 Jul 2026 22:35:06 +0200 Subject: [PATCH 72/77] Improve templates Signed-off-by: AnErrupTion --- .github/ISSUE_TEMPLATE/bug.yml | 17 ++++++++++++++--- .github/ISSUE_TEMPLATE/feature.yml | 7 +++++++ .github/pull_request_template.md | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 1a6d57a..64eef9c 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -11,15 +11,19 @@ body: options: - label: I have looked for any other duplicate issues required: true - - label: I have reproduced the issue on a fresh install of my OS & Ly with default settings, except ones I will mention + - label: I have reproduced the issue with the default config of Ly + required: true + - label: I have reproduced the issue on a fresh install of Ly **as well as** my OS and my desktop environment/window manager, all with **default settings**, except ones I will mention required: false - label: I have confirmed this issue also occurs on the latest development version (found in the `master` branch) required: true + - label: I understand that this issue **will** be closed if requirements are not or not properly met + required: true - type: input id: version attributes: label: Ly version - description: The output of `ly --version`. Please note that only Ly v1.2.0 and above are supported. + description: The output of `ly --version`. Please note that only the latest release and the current version in development are supported. placeholder: 1.1.0-dev.12+2b0301c validations: required: true @@ -41,9 +45,16 @@ body: id: desktop attributes: label: OS + Desktop environment/Window manager - description: Which OS and DE (or WM) did you use when observing the problem? + description: Which operating system and DE (or WM) did you use when observing the problem? validations: required: true + - type: input + id: osimage + attributes: + label: OS version/snapshot used to reproduce + description: Which version (or snapshot if rolling release) of the OS did you use to reproduce the issue? This is only required if you have reproduced the issue on a fresh copy of the OS. + validations: + required: false - type: textarea id: reproduction attributes: diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index b9a26af..b4cc299 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -20,3 +20,10 @@ body: description: What do you want to be added? Describe the behavior clearly. validations: required: true + - type: textarea + id: alternatives + attributes: + label: Alternatives + description: Are there any alternatives to the new behavior you wish to see being added? + validations: + required: true diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a32f0c2..606d00f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,9 +2,9 @@ _Replace this with a brief description of your changes_ -## What existing issue does this resolve? +## What existing issue(s) does this resolve? -_Replace this with a reference to an existing issue, or N/A if there is none_ +_Replace this with a reference to (an) existing issue(s), or N/A if there is none_ ## Pre-requisites From d00780d6ce7f1c9552f013a4180ddf4885e83f10 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Wed, 8 Jul 2026 01:29:57 +0200 Subject: [PATCH 73/77] zig: Remove usage of [*c] Signed-off-by: AnErrupTion --- ly-core/src/interop.zig | 6 +++--- src/auth.zig | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ly-core/src/interop.zig b/ly-core/src/interop.zig index f04b2a4..d894485 100644 --- a/ly-core/src/interop.zig +++ b/ly-core/src/interop.zig @@ -28,7 +28,7 @@ pub const UsernameEntry = struct { gid: std.posix.gid_t, home: ?[]const u8, shell: ?[]const u8, - passwd_struct: [*c]pwd.passwd, + passwd_struct: [*]pwd.passwd, }; // Contains the platform-specific code @@ -381,8 +381,8 @@ pub fn setEnvironmentVariable(allocator: std.mem.Allocator, name: []const u8, va if (status != 0) return error.SetEnvironmentVariableFailed; } -pub fn putEnvironmentVariable(name_and_value: [*c]u8) !void { - const status = stdlib.putenv(name_and_value); +pub fn putEnvironmentVariable(name_and_value: []u8) !void { + const status = stdlib.putenv(name_and_value.ptr); if (status != 0) return error.PutEnvironmentVariableFailed; } diff --git a/src/auth.zig b/src/auth.zig index 00ae005..c9abf15 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -191,10 +191,12 @@ fn startSession( if (pam_env_vars == null) return error.GetEnvListFailed; const env_list = std.mem.span(pam_env_vars.?); - for (env_list) |env_var| { - if (env_var == null) continue; - try log_file.info(io, "auth/env", "setting pam environment variable: {s}", .{std.mem.span(env_var.?)}); - try interop.putEnvironmentVariable(env_var); + for (env_list) |maybe_env_var| { + if (maybe_env_var) |env_var| { + const env_var_slice = std.mem.span(env_var); + try log_file.info(io, "auth/env", "setting pam environment variable: {s}", .{env_var_slice}); + try interop.putEnvironmentVariable(env_var_slice); + } } const home_z = try allocator.dupeZ(u8, user_entry.home.?); From 84950136c96a7e22e2dbbd29da74e1ffd1d102bb Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 10 Jul 2026 00:15:07 +0200 Subject: [PATCH 74/77] positionWidgets: Less integer overflows possible Signed-off-by: AnErrupTion --- ly-ui/src/TerminalBuffer.zig | 3 ++- src/animations/Lua.zig | 4 +++- src/main.zig | 22 +++++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ly-ui/src/TerminalBuffer.zig b/ly-ui/src/TerminalBuffer.zig index 7ead34f..4881a2e 100644 --- a/ly-ui/src/TerminalBuffer.zig +++ b/ly-ui/src/TerminalBuffer.zig @@ -269,7 +269,8 @@ pub fn runEventLoop( } } - try TerminalBuffer.presentBuffer(); + // We don't care about present errors here + TerminalBuffer.presentBuffer() catch {}; } if (inactivity_event_fn) |inactivity_fn| { diff --git a/src/animations/Lua.zig b/src/animations/Lua.zig index d212e03..2d2956f 100644 --- a/src/animations/Lua.zig +++ b/src/animations/Lua.zig @@ -129,8 +129,10 @@ fn draw(self: *Lua) void { cell.put(x, y) catch {}; if (self.lua_str) |str| for (str, 0..) |c, i| { + const dwidth = @divFloor(self.width, 2); + const dlen = @divFloor(str.len, 2); Cell.init(c, 0x00FFFFFF, 0).put( - @divFloor(self.width, 2) - @divFloor(str.len, 2) + i, + (if (dlen > dwidth) 0 else dwidth - dlen) + i, self.margin + 5, ) catch {}; }; diff --git a/src/main.zig b/src/main.zig index 85ababf..382ace4 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2244,26 +2244,34 @@ fn positionWidgets(ptr: *anyopaque) !void { bb_width = @max(bb_width, clock_text_len); } - const max_v_position: f32 = @floatFromInt(state.buffer.height - bb_height - 1); - const max_h_position: f32 = @floatFromInt(state.buffer.width - bb_width - 1); + const dheight = if (bb_height + 1 > state.buffer.height) 1 else state.buffer.height - bb_height - 1; + const dwidth = if (bb_width + 1 > state.buffer.width) 1 else state.buffer.width - bb_width - 1; + + const max_v_position: f32 = @floatFromInt(dheight); + const max_h_position: f32 = @floatFromInt(dwidth); bb_height = @min(bb_height, state.buffer.height - 2); bb_width = @min(bb_width, state.buffer.width - 2); const v_space: f32 = @floatFromInt(state.buffer.height - bb_height); - const v_position: usize = @intFromFloat(std.math.clamp(v_space * state.config.box_position_v, 1.0, max_v_position)); + const v_position: usize = @intFromFloat(if (max_v_position < 1.0) 1.0 else std.math.clamp(v_space * state.config.box_position_v, 1.0, max_v_position)); const h_space: f32 = @floatFromInt(state.buffer.width - bb_width); - const h_position: usize = @intFromFloat(std.math.clamp(h_space * state.config.box_position_h, 1.0, max_h_position)); + const h_position: usize = @intFromFloat(if (max_h_position < 1.0) 1.0 else std.math.clamp(h_space * state.config.box_position_h, 1.0, max_h_position)); if (state.config.bigclock != .none) { + const cwidth = if (clock_text_len > bb_width) 0 else bb_width - clock_text_len; + state.bigclock_label.positionXY(TerminalBuffer.START_POSITION - .addX(h_position + (bb_width - clock_text_len) / 2) + .addX(h_position + cwidth / 2) .addY(v_position)); } + const bwidth = if (state.box.width > bb_width) 0 else bb_width - state.box.width; + const bheight = if (state.box.height > bb_height) 0 else bb_height - state.box.height; + state.box.positionXY(TerminalBuffer.START_POSITION - .addX(h_position + (bb_width - state.box.width) / 2) - .addY(v_position + (bb_height - state.box.height))); + .addX(h_position + bwidth / 2) + .addY(v_position + bheight)); state.info_line.label.positionY(state.box .childrenPosition()); From 7c2ae2738ca71c4df3b590c9ed4068911c23b527 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 10 Jul 2026 13:02:58 +0200 Subject: [PATCH 75/77] positionSingleWidget: Resist integer overflows Signed-off-by: AnErrupTion --- src/main.zig | 75 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/src/main.zig b/src/main.zig index 382ace4..31a8519 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1950,8 +1950,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.shutdown_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.shutdown_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.shutdown_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "restart")) { @@ -1961,8 +1962,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.restart_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.restart_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.restart_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "britup")) { @@ -1972,8 +1974,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.brightness_up_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.brightness_up_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.brightness_up_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "britdown")) { @@ -1983,8 +1986,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.brightness_down_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.brightness_down_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.brightness_down_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "password")) { @@ -1994,8 +1998,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.toggle_password_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.toggle_password_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.toggle_password_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "clock") or std.mem.eql(u8, item, "time")) { @@ -2005,8 +2010,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.clock_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.clock_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.clock_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "tty")) { @@ -2015,8 +2021,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.tty_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.tty_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.tty_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "battery")) { @@ -2026,8 +2033,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.battery_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.battery_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.battery_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "version")) { @@ -2036,8 +2044,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.version_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.version_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.version_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "numlock")) { @@ -2046,8 +2055,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.numlock_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.numlock_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.numlock_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "capslock")) { @@ -2056,8 +2066,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu state.capslock_label.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - state.capslock_label.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + state.capslock_label.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } return true; } else if (std.mem.eql(u8, item, "labels")) { @@ -2068,8 +2079,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu info.lbl.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - info.lbl.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + info.lbl.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } positioned.labels[i] = true; } @@ -2094,8 +2106,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu local_x = state.buffer.width - state.edge_margin.x; if (is_top) local_y += 1 else local_y -= 1; } - bind.lbl.positionXY(Position.init(local_x - width, local_y)); - local_x -= width + 1; + const dwidth = if (width > local_x) 0 else local_x - width; + bind.lbl.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= local_x) local_x -= width + 1; } positioned.binds[i] = true; } @@ -2111,8 +2124,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu info.lbl.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - info.lbl.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + info.lbl.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } positioned.labels[i] = true; return true; @@ -2128,8 +2142,9 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu bind.lbl.positionXY(Position.init(current_x.*, current_y)); current_x.* += width + 1; } else { - bind.lbl.positionXY(Position.init(current_x.* - width, current_y)); - current_x.* -= width + 1; + const dwidth = if (width > current_x.*) 0 else current_x.* - width; + bind.lbl.positionXY(Position.init(dwidth, current_y)); + if (width + 1 <= current_x.*) current_x.* -= width + 1; } positioned.binds[i] = true; return true; From b6fba46b087cd27fefa4d67c0a3b0eb084c7b016 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Tue, 28 Jul 2026 01:38:48 +0200 Subject: [PATCH 76/77] GPA: Add more tracking in Debug Signed-off-by: AnErrupTion --- src/main.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.zig b/src/main.zig index 31a8519..1d0db99 100644 --- a/src/main.zig +++ b/src/main.zig @@ -149,8 +149,11 @@ pub fn main(init: std.process.Init) !void { } } - var gpa = std.heap.DebugAllocator(.{}).init; - defer _ = gpa.deinit(); + var gpa: std.heap.DebugAllocator(.{ + .never_unmap = builtin.mode == .Debug, + .retain_metadata = builtin.mode == .Debug, + }) = .init; + defer if (gpa.deinit() == .leak) std.log.err("attention please, memory has been leaked!", .{}); state.allocator = gpa.allocator(); From a22805d44b7f277d5901036edc11d01d88b749ab Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 31 Jul 2026 23:52:19 +0200 Subject: [PATCH 77/77] Auth: Handle symlinks for session log Signed-off-by: AnErrupTion --- src/auth.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/auth.zig b/src/auth.zig index c9abf15..7d9c66c 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -574,7 +574,15 @@ fn executeCmd(global_log_file: *LogFile, allocator: std.mem.Allocator, io: std.I fn redirectStandardStreams(global_log_file: *LogFile, io: std.Io, session_log: []const u8, create: bool) !std.Io.File { create_session_log_dir: { const session_log_dir = std.Io.Dir.path.dirname(session_log) orelse break :create_session_log_dir; - std.Io.Dir.cwd().createDirPath(io, session_log_dir) catch |err| { + + var buffer = std.mem.zeroes([std.Io.Dir.max_path_bytes]u8); + const len = std.Io.Dir.cwd().realPathFile(io, session_log_dir, &buffer) catch |err| { + try global_log_file.err(io, "auth/sys", "failed to resolve path for session log file directory: {s}", .{@errorName(err)}); + return err; + }; + const resolved_path = buffer[0..len]; + + std.Io.Dir.cwd().createDirPath(io, resolved_path) catch |err| { try global_log_file.err(io, "auth/sys", "failed to create session log file directory: {s}", .{@errorName(err)}); return err; };