Merge branch 'master' into moritz-reinel/03_uniform-lang-files

This commit is contained in:
AnErrupTion 2025-03-05 20:26:01 +00:00
commit 142073c362
8 changed files with 54 additions and 34 deletions

View File

@ -3,7 +3,7 @@ const builtin = @import("builtin");
const PatchMap = std.StringHashMap([]const u8);
const min_zig_string = "0.12.0";
const min_zig_string = "0.14.0";
const current_zig = builtin.zig_version;
// Implementing zig version detection through compile time
@ -22,8 +22,6 @@ var prefix_directory: []const u8 = undefined;
var executable_name: []const u8 = undefined;
var default_tty_str: []const u8 = undefined;
const ProgressNode = if (current_zig.minor == 12) *std.Progress.Node else std.Progress.Node;
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";
@ -31,7 +29,6 @@ pub fn build(b: *std.Build) !void {
executable_name = b.option([]const u8, "name", "Specify installed executable file name (default is ly)") orelse "ly";
const bin_directory = try b.allocator.dupe(u8, config_directory);
config_directory = try std.fs.path.join(b.allocator, &[_][]const u8{ dest_directory, config_directory });
const build_options = b.addOptions();
const version_str = try getVersionStr(b, "ly", ly_version);
@ -123,7 +120,7 @@ pub fn build(b: *std.Build) !void {
pub fn ExeInstaller(install_conf: bool) type {
return struct {
pub fn make(step: *std.Build.Step, _: ProgressNode) !void {
pub fn make(step: *std.Build.Step, _: std.Build.Step.MakeOptions) !void {
try install_ly(step.owner.allocator, install_conf);
}
};
@ -139,7 +136,7 @@ const InitSystem = enum {
pub fn ServiceInstaller(comptime init_system: InitSystem) type {
return struct {
pub fn make(step: *std.Build.Step, _: ProgressNode) !void {
pub fn make(step: *std.Build.Step, _: std.Build.Step.MakeOptions) !void {
const allocator = step.owner.allocator;
var patch_map = PatchMap.init(allocator);
@ -222,22 +219,22 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type {
}
fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void {
const ly_config_directory = try std.fs.path.join(allocator, &[_][]const u8{ config_directory, "/ly" });
const ly_config_directory = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly" });
std.fs.cwd().makePath(ly_config_directory) catch {
std.debug.print("warn: {s} already exists as a directory.\n", .{ly_config_directory});
};
const ly_lang_path = try std.fs.path.join(allocator, &[_][]const u8{ config_directory, "/ly/lang" });
const ly_lang_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/ly/lang" });
std.fs.cwd().makePath(ly_lang_path) catch {
std.debug.print("warn: {s} already exists as a directory.\n", .{config_directory});
std.debug.print("warn: {s} already exists as a directory.\n", .{ ly_lang_path });
};
{
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" });
if (!std.mem.eql(u8, dest_directory, "")) {
std.fs.cwd().makePath(exe_path) catch {
std.debug.print("warn: {s} already exists as a directory.\n", .{exe_path});
std.debug.print("warn: {s} already exists as a directory.\n", .{ exe_path });
};
}
@ -311,7 +308,7 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void {
}
}
pub fn uninstallall(step: *std.Build.Step, _: ProgressNode) !void {
pub fn uninstallall(step: *std.Build.Step, _: std.Build.Step.MakeOptions) !void {
const allocator = step.owner.allocator;
try deleteTree(allocator, config_directory, "/ly", "ly config directory not found");

View File

@ -1,15 +1,16 @@
.{
.name = "ly",
.version = "1.0.0",
.minimum_zig_version = "0.12.0",
.name = .ly,
.version = "1.1.0",
.fingerprint = 0xa148ffcc5dc2cb59,
.minimum_zig_version = "0.14.0",
.dependencies = .{
.clap = .{
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.9.1.tar.gz",
.hash = "122062d301a203d003547b414237229b09a7980095061697349f8bef41be9c30266b",
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.10.0.tar.gz",
.hash = "clap-0.10.0-oBajB434AQBDh-Ei3YtoKIRxZacVPF1iSwp3IX_ZB8f0",
},
.zigini = .{
.url = "https://github.com/Kawaii-Ash/zigini/archive/0bba97a12582928e097f4074cc746c43351ba4c8.tar.gz",
.hash = "12209b971367b4066d40ecad4728e6fdffc4cc4f19356d424c2de57f5b69ac7a619a",
.url = "https://github.com/AnErrupTion/zigini/archive/e61d31b2b7db3365993a20cc90e491d0cb0b7282.tar.gz",
.hash = "zigini-0.3.1-BSkB7XJGAAB2E-sKyzhTaQCBlYBL8yqzE4E_jmSY99sC",
},
},
.paths = .{""},

View File

@ -1,12 +1,14 @@
# Ly - a TUI display manager
## Development is now continuing on [Codeberg](https://codeberg.org/AnErrupTion/ly), with the [GitHub](https://github.com/fairyglade/ly) repository becoming a mirror. Issues & pull requests on GitHub will be ignored from now on.
![Ly screenshot](.github/screenshot.png "Ly screenshot")
Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD.
## Dependencies
- Compile-time:
- zig >=0.12.0
- zig 0.14.0
- libc
- pam
- xcb (optional, required by default; needed for X11 support)
@ -252,4 +254,3 @@ disable the main box borders with `hide_borders = true`.
## Additional Information
The name "Ly" is a tribute to the fairy from the game Rayman.
Ly was tested by oxodao, who is some seriously awesome dude.

View File

@ -9,7 +9,7 @@ const ErrorHandler = packed struct {
const SharedError = @This();
data: []align(std.mem.page_size) u8,
data: []align(std.heap.page_size_min) u8,
pub fn init() !SharedError {
const data = try std.posix.mmap(null, @sizeOf(ErrorHandler), std.posix.PROT.READ | std.posix.PROT.WRITE, .{ .TYPE = .SHARED, .ANONYMOUS = true }, -1, 0);

View File

@ -1,6 +1,6 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const Random = std.rand.Random;
const Random = std.Random;
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
const interop = @import("../interop.zig");

View File

@ -108,7 +108,7 @@ pub fn authenticate(config: Config, current_environment: Session.Environment, lo
.mask = std.posix.empty_sigset,
.flags = 0,
};
try std.posix.sigaction(std.posix.SIG.TERM, &act, null);
std.posix.sigaction(std.posix.SIG.TERM, &act, null);
try addUtmpEntry(&entry, pwd.pw_name.?, child_pid);
}
@ -439,7 +439,7 @@ fn executeX11Cmd(shell: [*:0]const u8, pw_dir: [*:0]const u8, config: Config, de
.mask = std.posix.empty_sigset,
.flags = 0,
};
try std.posix.sigaction(std.posix.SIG.TERM, &act, null);
std.posix.sigaction(std.posix.SIG.TERM, &act, null);
_ = std.posix.waitpid(xorg_pid, 0);
interop.xcb.xcb_disconnect(xcb);

View File

@ -127,7 +127,10 @@ pub fn main() !void {
const config_path = try std.fmt.allocPrint(allocator, "{s}{s}config.ini", .{ s, trailing_slash });
defer allocator.free(config_path);
config = config_ini.readFileToStruct(config_path, comment_characters, migrator.configFieldHandler) catch _config: {
config = config_ini.readFileToStruct(config_path, .{
.fieldHandler = migrator.configFieldHandler,
.comment_characters = comment_characters,
}) catch _config: {
config_load_failed = true;
break :_config Config{};
};
@ -135,21 +138,30 @@ pub fn main() !void {
const lang_path = try std.fmt.allocPrint(allocator, "{s}{s}lang/{s}.ini", .{ s, trailing_slash, config.lang });
defer allocator.free(lang_path);
lang = lang_ini.readFileToStruct(lang_path, comment_characters, null) catch Lang{};
lang = lang_ini.readFileToStruct(lang_path, .{
.fieldHandler = null,
.comment_characters = comment_characters,
}) catch Lang{};
if (config.load) {
save_path = try std.fmt.allocPrint(allocator, "{s}{s}save.ini", .{ s, trailing_slash });
save_path_alloc = true;
var user_buf: [32]u8 = undefined;
save = save_ini.readFileToStruct(save_path, comment_characters, null) catch migrator.tryMigrateSaveFile(&user_buf);
save = save_ini.readFileToStruct(save_path, .{
.fieldHandler = null,
.comment_characters = comment_characters,
}) catch migrator.tryMigrateSaveFile(&user_buf);
}
migrator.lateConfigFieldHandler(&config.animation);
} else {
const config_path = build_options.config_directory ++ "/ly/config.ini";
config = config_ini.readFileToStruct(config_path, comment_characters, migrator.configFieldHandler) catch _config: {
config = config_ini.readFileToStruct(config_path, .{
.fieldHandler = migrator.configFieldHandler,
.comment_characters = comment_characters,
}) catch _config: {
config_load_failed = true;
break :_config Config{};
};
@ -157,11 +169,17 @@ pub fn main() !void {
const lang_path = try std.fmt.allocPrint(allocator, "{s}/ly/lang/{s}.ini", .{ build_options.config_directory, config.lang });
defer allocator.free(lang_path);
lang = lang_ini.readFileToStruct(lang_path, comment_characters, null) catch Lang{};
lang = lang_ini.readFileToStruct(lang_path, .{
.fieldHandler = null,
.comment_characters = comment_characters,
}) catch Lang{};
if (config.load) {
var user_buf: [32]u8 = undefined;
save = save_ini.readFileToStruct(save_path, comment_characters, null) catch migrator.tryMigrateSaveFile(&user_buf);
save = save_ini.readFileToStruct(save_path, .{
.fieldHandler = null,
.comment_characters = comment_characters,
}) catch migrator.tryMigrateSaveFile(&user_buf);
}
migrator.lateConfigFieldHandler(&config.animation);
@ -191,7 +209,7 @@ pub fn main() !void {
.mask = std.posix.empty_sigset,
.flags = 0,
};
try std.posix.sigaction(std.posix.SIG.TERM, &act, null);
std.posix.sigaction(std.posix.SIG.TERM, &act, null);
_ = termbox.tb_set_output_mode(termbox.TB_OUTPUT_NORMAL);
_ = termbox.tb_clear();
@ -670,7 +688,7 @@ pub fn main() !void {
.user = login.text.items,
.session_index = session.label.current,
};
ini.writeFromStruct(save_data, file.writer(), null, true, .{}) catch break :save_last_settings;
ini.writeFromStruct(save_data, file.writer(), null, .{}) catch break :save_last_settings;
// Delete previous save file if it exists
if (migrator.maybe_save_file) |path| std.fs.cwd().deleteFile(path) catch {};

View File

@ -110,7 +110,10 @@ pub fn crawl(self: *Session, path: []const u8, display_server: DisplayServer) !v
const entry_path = try std.fmt.allocPrint(self.label.allocator, "{s}/{s}", .{ path, item.name });
defer self.label.allocator.free(entry_path);
var entry_ini = Ini(Entry).init(self.label.allocator);
_ = try entry_ini.readFileToStruct(entry_path, "#", null);
_ = try entry_ini.readFileToStruct(entry_path, .{
.fieldHandler = null,
.comment_characters = "#",
});
errdefer entry_ini.deinit();
var xdg_session_desktop: []const u8 = undefined;