mirror of https://github.com/fairyglade/ly.git
Merge branch 'master' into villamorrd/master
This commit is contained in:
commit
50e9e912e0
10
build.zig
10
build.zig
|
@ -3,7 +3,7 @@ const builtin = @import("builtin");
|
||||||
|
|
||||||
const PatchMap = std.StringHashMap([]const u8);
|
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;
|
const current_zig = builtin.zig_version;
|
||||||
|
|
||||||
// Implementing zig version detection through compile time
|
// Implementing zig version detection through compile time
|
||||||
|
@ -22,8 +22,6 @@ var prefix_directory: []const u8 = undefined;
|
||||||
var executable_name: []const u8 = undefined;
|
var executable_name: []const u8 = undefined;
|
||||||
var default_tty_str: []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 {
|
pub fn build(b: *std.Build) !void {
|
||||||
dest_directory = b.option([]const u8, "dest_directory", "Specify a destination directory for installation") orelse "";
|
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";
|
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";
|
||||||
|
@ -122,7 +120,7 @@ pub fn build(b: *std.Build) !void {
|
||||||
|
|
||||||
pub fn ExeInstaller(install_conf: bool) type {
|
pub fn ExeInstaller(install_conf: bool) type {
|
||||||
return struct {
|
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);
|
try install_ly(step.owner.allocator, install_conf);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -138,7 +136,7 @@ const InitSystem = enum {
|
||||||
|
|
||||||
pub fn ServiceInstaller(comptime init_system: InitSystem) type {
|
pub fn ServiceInstaller(comptime init_system: InitSystem) type {
|
||||||
return struct {
|
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;
|
const allocator = step.owner.allocator;
|
||||||
|
|
||||||
var patch_map = PatchMap.init(allocator);
|
var patch_map = PatchMap.init(allocator);
|
||||||
|
@ -310,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;
|
const allocator = step.owner.allocator;
|
||||||
|
|
||||||
try deleteTree(allocator, config_directory, "/ly", "ly config directory not found");
|
try deleteTree(allocator, config_directory, "/ly", "ly config directory not found");
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
.{
|
.{
|
||||||
.name = "ly",
|
.name = .ly,
|
||||||
.version = "1.0.0",
|
.version = "1.1.0",
|
||||||
.minimum_zig_version = "0.12.0",
|
.fingerprint = 0xa148ffcc5dc2cb59,
|
||||||
|
.minimum_zig_version = "0.14.0",
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.clap = .{
|
.clap = .{
|
||||||
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.9.1.tar.gz",
|
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.10.0.tar.gz",
|
||||||
.hash = "122062d301a203d003547b414237229b09a7980095061697349f8bef41be9c30266b",
|
.hash = "clap-0.10.0-oBajB434AQBDh-Ei3YtoKIRxZacVPF1iSwp3IX_ZB8f0",
|
||||||
},
|
},
|
||||||
.zigini = .{
|
.zigini = .{
|
||||||
.url = "https://github.com/Kawaii-Ash/zigini/archive/0bba97a12582928e097f4074cc746c43351ba4c8.tar.gz",
|
.url = "https://github.com/AnErrupTion/zigini/archive/e61d31b2b7db3365993a20cc90e491d0cb0b7282.tar.gz",
|
||||||
.hash = "12209b971367b4066d40ecad4728e6fdffc4cc4f19356d424c2de57f5b69ac7a619a",
|
.hash = "zigini-0.3.1-BSkB7XJGAAB2E-sKyzhTaQCBlYBL8yqzE4E_jmSY99sC",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.paths = .{""},
|
.paths = .{""},
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
|
|
||||||
# Ly - a TUI display manager
|
# 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 is a lightweight TUI (ncurses-like) display manager for Linux and BSD.
|
Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
- Compile-time:
|
- Compile-time:
|
||||||
- zig >=0.12.0
|
- zig 0.14.0
|
||||||
- libc
|
- libc
|
||||||
- pam
|
- pam
|
||||||
- xcb (optional, required by default; needed for X11 support)
|
- xcb (optional, required by default; needed for X11 support)
|
||||||
|
@ -252,4 +254,3 @@ disable the main box borders with `hide_borders = true`.
|
||||||
## Additional Information
|
## Additional Information
|
||||||
The name "Ly" is a tribute to the fairy from the game Rayman.
|
The name "Ly" is a tribute to the fairy from the game Rayman.
|
||||||
Ly was tested by oxodao, who is some seriously awesome dude.
|
Ly was tested by oxodao, who is some seriously awesome dude.
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ const ErrorHandler = packed struct {
|
||||||
|
|
||||||
const SharedError = @This();
|
const SharedError = @This();
|
||||||
|
|
||||||
data: []align(std.mem.page_size) u8,
|
data: []align(std.heap.page_size_min) u8,
|
||||||
|
|
||||||
pub fn init() !SharedError {
|
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);
|
const data = try std.posix.mmap(null, @sizeOf(ErrorHandler), std.posix.PROT.READ | std.posix.PROT.WRITE, .{ .TYPE = .SHARED, .ANONYMOUS = true }, -1, 0);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const Random = std.rand.Random;
|
const Random = std.Random;
|
||||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||||
|
|
||||||
const interop = @import("../interop.zig");
|
const interop = @import("../interop.zig");
|
||||||
|
|
|
@ -108,7 +108,7 @@ pub fn authenticate(config: Config, current_environment: Session.Environment, lo
|
||||||
.mask = std.posix.empty_sigset,
|
.mask = std.posix.empty_sigset,
|
||||||
.flags = 0,
|
.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);
|
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,
|
.mask = std.posix.empty_sigset,
|
||||||
.flags = 0,
|
.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);
|
_ = std.posix.waitpid(xorg_pid, 0);
|
||||||
interop.xcb.xcb_disconnect(xcb);
|
interop.xcb.xcb_disconnect(xcb);
|
||||||
|
|
34
src/main.zig
34
src/main.zig
|
@ -127,7 +127,10 @@ pub fn main() !void {
|
||||||
const config_path = try std.fmt.allocPrint(allocator, "{s}{s}config.ini", .{ s, trailing_slash });
|
const config_path = try std.fmt.allocPrint(allocator, "{s}{s}config.ini", .{ s, trailing_slash });
|
||||||
defer allocator.free(config_path);
|
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;
|
config_load_failed = true;
|
||||||
break :_config Config{};
|
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 });
|
const lang_path = try std.fmt.allocPrint(allocator, "{s}{s}lang/{s}.ini", .{ s, trailing_slash, config.lang });
|
||||||
defer allocator.free(lang_path);
|
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) {
|
if (config.load) {
|
||||||
save_path = try std.fmt.allocPrint(allocator, "{s}{s}save.ini", .{ s, trailing_slash });
|
save_path = try std.fmt.allocPrint(allocator, "{s}{s}save.ini", .{ s, trailing_slash });
|
||||||
save_path_alloc = true;
|
save_path_alloc = true;
|
||||||
|
|
||||||
var user_buf: [32]u8 = undefined;
|
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);
|
migrator.lateConfigFieldHandler(&config.animation);
|
||||||
} else {
|
} else {
|
||||||
const config_path = build_options.config_directory ++ "/ly/config.ini";
|
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;
|
config_load_failed = true;
|
||||||
break :_config Config{};
|
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 });
|
const lang_path = try std.fmt.allocPrint(allocator, "{s}/ly/lang/{s}.ini", .{ build_options.config_directory, config.lang });
|
||||||
defer allocator.free(lang_path);
|
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) {
|
if (config.load) {
|
||||||
var user_buf: [32]u8 = undefined;
|
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);
|
migrator.lateConfigFieldHandler(&config.animation);
|
||||||
|
@ -191,7 +209,7 @@ pub fn main() !void {
|
||||||
.mask = std.posix.empty_sigset,
|
.mask = std.posix.empty_sigset,
|
||||||
.flags = 0,
|
.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_set_output_mode(termbox.TB_OUTPUT_NORMAL);
|
||||||
_ = termbox.tb_clear();
|
_ = termbox.tb_clear();
|
||||||
|
@ -670,7 +688,7 @@ pub fn main() !void {
|
||||||
.user = login.text.items,
|
.user = login.text.items,
|
||||||
.session_index = session.label.current,
|
.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
|
// Delete previous save file if it exists
|
||||||
if (migrator.maybe_save_file) |path| std.fs.cwd().deleteFile(path) catch {};
|
if (migrator.maybe_save_file) |path| std.fs.cwd().deleteFile(path) catch {};
|
||||||
|
|
|
@ -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 });
|
const entry_path = try std.fmt.allocPrint(self.label.allocator, "{s}/{s}", .{ path, item.name });
|
||||||
defer self.label.allocator.free(entry_path);
|
defer self.label.allocator.free(entry_path);
|
||||||
var entry_ini = Ini(Entry).init(self.label.allocator);
|
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();
|
errdefer entry_ini.deinit();
|
||||||
|
|
||||||
var xdg_session_desktop: []const u8 = undefined;
|
var xdg_session_desktop: []const u8 = undefined;
|
||||||
|
|
Loading…
Reference in New Issue