mirror of https://github.com/fairyglade/ly.git
Patch resource files + add prefix directory
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
598fa6a505
commit
ee0c00574a
232
build.zig
232
build.zig
|
@ -1,6 +1,8 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
|
|
||||||
|
const PatchMap = std.StringHashMap([]const u8);
|
||||||
|
|
||||||
const min_zig_string = "0.12.0";
|
const min_zig_string = "0.12.0";
|
||||||
const current_zig = builtin.zig_version;
|
const current_zig = builtin.zig_version;
|
||||||
|
|
||||||
|
@ -15,25 +17,30 @@ comptime {
|
||||||
const ly_version = std.SemanticVersion{ .major = 1, .minor = 1, .patch = 0 };
|
const ly_version = std.SemanticVersion{ .major = 1, .minor = 1, .patch = 0 };
|
||||||
|
|
||||||
var dest_directory: []const u8 = undefined;
|
var dest_directory: []const u8 = undefined;
|
||||||
var data_directory: []const u8 = undefined;
|
var config_directory: []const u8 = undefined;
|
||||||
var exe_name: []const u8 = undefined;
|
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;
|
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 "";
|
||||||
data_directory = b.option([]const u8, "data_directory", "Specify a default data directory (default is /etc/ly). This path gets embedded into the binary") orelse "/etc/ly";
|
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";
|
||||||
exe_name = b.option([]const u8, "name", "Specify installed executable file name (default is ly)") orelse "ly";
|
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";
|
||||||
|
|
||||||
const bin_directory = try b.allocator.dupe(u8, data_directory);
|
const bin_directory = try b.allocator.dupe(u8, config_directory);
|
||||||
data_directory = try std.fs.path.join(b.allocator, &[_][]const u8{ dest_directory, data_directory });
|
config_directory = try std.fs.path.join(b.allocator, &[_][]const u8{ dest_directory, config_directory });
|
||||||
|
|
||||||
const build_options = b.addOptions();
|
const build_options = b.addOptions();
|
||||||
const version_str = try getVersionStr(b, "ly", ly_version);
|
const version_str = try getVersionStr(b, "ly", ly_version);
|
||||||
const default_tty = b.option(u8, "default_tty", "Set the TTY (default is 2)") orelse 2;
|
|
||||||
const enable_x11_support = b.option(bool, "enable_x11_support", "Enable X11 support (default is on)") orelse true;
|
const enable_x11_support = b.option(bool, "enable_x11_support", "Enable X11 support (default is on)") orelse true;
|
||||||
|
const default_tty = b.option(u8, "default_tty", "Set the TTY (default is 2)") orelse 2;
|
||||||
|
|
||||||
build_options.addOption([]const u8, "data_directory", bin_directory);
|
default_tty_str = try std.fmt.allocPrint(b.allocator, "{d}", .{default_tty});
|
||||||
|
|
||||||
|
build_options.addOption([]const u8, "config_directory", bin_directory);
|
||||||
build_options.addOption([]const u8, "version", version_str);
|
build_options.addOption([]const u8, "version", version_str);
|
||||||
build_options.addOption(u8, "tty", default_tty);
|
build_options.addOption(u8, "tty", default_tty);
|
||||||
build_options.addOption(bool, "enable_x11_support", enable_x11_support);
|
build_options.addOption(bool, "enable_x11_support", enable_x11_support);
|
||||||
|
@ -138,40 +145,55 @@ 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, _: ProgressNode) !void {
|
||||||
const allocator = step.owner.allocator;
|
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);
|
||||||
|
|
||||||
switch (init_system) {
|
switch (init_system) {
|
||||||
.Systemd => {
|
.Systemd => {
|
||||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/usr/lib/systemd/system" });
|
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/lib/systemd/system" });
|
||||||
std.fs.cwd().makePath(service_path) catch {};
|
std.fs.cwd().makePath(service_path) catch {};
|
||||||
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
||||||
defer service_dir.close();
|
defer service_dir.close();
|
||||||
|
|
||||||
try installFile("res/ly.service", service_dir, service_path, "ly.service", .{ .override_mode = 0o644 });
|
const patched_service = try patchFile(allocator, "res/ly.service", patch_map);
|
||||||
|
try installText(patched_service, service_dir, service_path, "ly.service", .{ .mode = 0o644 });
|
||||||
},
|
},
|
||||||
.Openrc => {
|
.Openrc => {
|
||||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/init.d" });
|
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" });
|
||||||
std.fs.cwd().makePath(service_path) catch {};
|
std.fs.cwd().makePath(service_path) catch {};
|
||||||
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
||||||
defer service_dir.close();
|
defer service_dir.close();
|
||||||
|
|
||||||
try installFile("res/ly-openrc", service_dir, service_path, exe_name, .{ .override_mode = 0o755 });
|
const patched_service = try patchFile(allocator, "res/ly-openrc", patch_map);
|
||||||
|
try installText(patched_service, service_dir, service_path, executable_name, .{ .mode = 0o755 });
|
||||||
},
|
},
|
||||||
.Runit => {
|
.Runit => {
|
||||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/sv/ly" });
|
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/sv/ly" });
|
||||||
std.fs.cwd().makePath(service_path) catch {};
|
std.fs.cwd().makePath(service_path) catch {};
|
||||||
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
||||||
defer service_dir.close();
|
defer service_dir.close();
|
||||||
|
|
||||||
const supervise_path = try std.fs.path.join(allocator, &[_][]const u8{ service_path, "supervise" });
|
const supervise_path = try std.fs.path.join(allocator, &[_][]const u8{ service_path, "supervise" });
|
||||||
|
|
||||||
try installFile("res/ly-runit-service/conf", service_dir, service_path, "conf", .{});
|
const patched_conf = try patchFile(allocator, "res/ly-runit-service/conf", patch_map);
|
||||||
|
try installText(patched_conf, service_dir, service_path, "conf", .{});
|
||||||
|
|
||||||
try installFile("res/ly-runit-service/finish", service_dir, service_path, "finish", .{ .override_mode = 0o755 });
|
try installFile("res/ly-runit-service/finish", service_dir, service_path, "finish", .{ .override_mode = 0o755 });
|
||||||
try installFile("res/ly-runit-service/run", service_dir, service_path, "run", .{ .override_mode = 0o755 });
|
|
||||||
|
const patched_run = try patchFile(allocator, "res/ly-runit-service/run", patch_map);
|
||||||
|
try installText(patched_run, service_dir, service_path, "run", .{ .mode = 0o755 });
|
||||||
|
|
||||||
try std.fs.cwd().symLink("/run/runit/supervise.ly", supervise_path, .{});
|
try std.fs.cwd().symLink("/run/runit/supervise.ly", supervise_path, .{});
|
||||||
std.debug.print("info: installed symlink /run/runit/supervise.ly\n", .{});
|
std.debug.print("info: installed symlink /run/runit/supervise.ly\n", .{});
|
||||||
},
|
},
|
||||||
.S6 => {
|
.S6 => {
|
||||||
const admin_service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/s6/adminsv/default/contents.d" });
|
const admin_service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/adminsv/default/contents.d" });
|
||||||
std.fs.cwd().makePath(admin_service_path) catch {};
|
std.fs.cwd().makePath(admin_service_path) catch {};
|
||||||
var admin_service_dir = std.fs.cwd().openDir(admin_service_path, .{}) catch unreachable;
|
var admin_service_dir = std.fs.cwd().openDir(admin_service_path, .{}) catch unreachable;
|
||||||
defer admin_service_dir.close();
|
defer admin_service_dir.close();
|
||||||
|
@ -179,21 +201,24 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type {
|
||||||
const file = try admin_service_dir.createFile("ly-srv", .{});
|
const file = try admin_service_dir.createFile("ly-srv", .{});
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/s6/sv/ly-srv" });
|
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/s6/sv/ly-srv" });
|
||||||
std.fs.cwd().makePath(service_path) catch {};
|
std.fs.cwd().makePath(service_path) catch {};
|
||||||
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
||||||
defer service_dir.close();
|
defer service_dir.close();
|
||||||
|
|
||||||
try installFile("res/ly-s6/run", service_dir, service_path, "run", .{ .override_mode = 0o755 });
|
const patched_run = try patchFile(allocator, "res/ly-s6/run", patch_map);
|
||||||
|
try installText(patched_run, service_dir, service_path, "run", .{ .mode = 0o755 });
|
||||||
|
|
||||||
try installFile("res/ly-s6/type", service_dir, service_path, "type", .{});
|
try installFile("res/ly-s6/type", service_dir, service_path, "type", .{});
|
||||||
},
|
},
|
||||||
.Dinit => {
|
.Dinit => {
|
||||||
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/dinit.d" });
|
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/dinit.d" });
|
||||||
std.fs.cwd().makePath(service_path) catch {};
|
std.fs.cwd().makePath(service_path) catch {};
|
||||||
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
||||||
defer service_dir.close();
|
defer service_dir.close();
|
||||||
|
|
||||||
try installFile("res/ly-dinit", service_dir, service_path, "ly", .{});
|
const patched_service = try patchFile(allocator, "res/ly-dinit", patch_map);
|
||||||
|
try installText(patched_service, service_dir, service_path, "ly", .{});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,17 +226,19 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void {
|
fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void {
|
||||||
std.fs.cwd().makePath(data_directory) catch {
|
const ly_config_directory = try std.fs.path.join(allocator, &[_][]const u8{ config_directory, "/ly" });
|
||||||
std.debug.print("warn: {s} already exists as a directory.\n", .{data_directory});
|
|
||||||
|
std.fs.cwd().makePath(ly_config_directory) catch {
|
||||||
|
std.debug.print("warn: {s} already exists as a directory.\n", .{ly_config_directory});
|
||||||
};
|
};
|
||||||
|
|
||||||
const lang_path = try std.fs.path.join(allocator, &[_][]const u8{ data_directory, "/lang" });
|
const ly_lang_path = try std.fs.path.join(allocator, &[_][]const u8{ config_directory, "/ly/lang" });
|
||||||
std.fs.cwd().makePath(lang_path) catch {
|
std.fs.cwd().makePath(ly_lang_path) catch {
|
||||||
std.debug.print("warn: {s} already exists as a directory.\n", .{data_directory});
|
std.debug.print("warn: {s} already exists as a directory.\n", .{config_directory});
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/usr/bin" });
|
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin" });
|
||||||
if (!std.mem.eql(u8, dest_directory, "")) {
|
if (!std.mem.eql(u8, dest_directory, "")) {
|
||||||
std.fs.cwd().makePath(exe_path) catch {
|
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});
|
||||||
|
@ -221,44 +248,63 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void {
|
||||||
var executable_dir = std.fs.cwd().openDir(exe_path, .{}) catch unreachable;
|
var executable_dir = std.fs.cwd().openDir(exe_path, .{}) catch unreachable;
|
||||||
defer executable_dir.close();
|
defer executable_dir.close();
|
||||||
|
|
||||||
try installFile("zig-out/bin/ly", executable_dir, exe_path, exe_name, .{});
|
try installFile("zig-out/bin/ly", executable_dir, exe_path, executable_name, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var config_dir = std.fs.cwd().openDir(data_directory, .{}) catch unreachable;
|
var config_dir = std.fs.cwd().openDir(ly_config_directory, .{}) catch unreachable;
|
||||||
defer config_dir.close();
|
defer config_dir.close();
|
||||||
|
|
||||||
if (install_config) {
|
if (install_config) {
|
||||||
try installFile("res/config.ini", config_dir, data_directory, "config.ini", .{});
|
var patch_map = PatchMap.init(allocator);
|
||||||
}
|
defer patch_map.deinit();
|
||||||
try installFile("res/xsetup.sh", config_dir, data_directory, "xsetup.sh", .{});
|
|
||||||
try installFile("res/wsetup.sh", config_dir, data_directory, "wsetup.sh", .{});
|
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);
|
||||||
|
|
||||||
|
const patched_config = try patchFile(allocator, "res/config.ini", patch_map);
|
||||||
|
try installText(patched_config, config_dir, ly_config_directory, "config.ini", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var lang_dir = std.fs.cwd().openDir(lang_path, .{}) catch unreachable;
|
var patch_map = PatchMap.init(allocator);
|
||||||
|
defer patch_map.deinit();
|
||||||
|
|
||||||
|
try patch_map.put("$PREFIX_DIRECTORY", prefix_directory);
|
||||||
|
|
||||||
|
const patched_xsetup = try patchFile(allocator, "res/xsetup.sh", patch_map);
|
||||||
|
const patched_wsetup = try patchFile(allocator, "res/wsetup.sh", patch_map);
|
||||||
|
|
||||||
|
try installText(patched_xsetup, config_dir, ly_config_directory, "xsetup.sh", .{});
|
||||||
|
try installText(patched_wsetup, config_dir, ly_config_directory, "wsetup.sh", .{});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
var lang_dir = std.fs.cwd().openDir(ly_lang_path, .{}) catch unreachable;
|
||||||
defer lang_dir.close();
|
defer lang_dir.close();
|
||||||
|
|
||||||
try installFile("res/lang/cat.ini", lang_dir, lang_path, "cat.ini", .{});
|
try installFile("res/lang/cat.ini", lang_dir, ly_lang_path, "cat.ini", .{});
|
||||||
try installFile("res/lang/cs.ini", lang_dir, lang_path, "cs.ini", .{});
|
try installFile("res/lang/cs.ini", lang_dir, ly_lang_path, "cs.ini", .{});
|
||||||
try installFile("res/lang/de.ini", lang_dir, lang_path, "de.ini", .{});
|
try installFile("res/lang/de.ini", lang_dir, ly_lang_path, "de.ini", .{});
|
||||||
try installFile("res/lang/en.ini", lang_dir, lang_path, "en.ini", .{});
|
try installFile("res/lang/en.ini", lang_dir, ly_lang_path, "en.ini", .{});
|
||||||
try installFile("res/lang/es.ini", lang_dir, lang_path, "es.ini", .{});
|
try installFile("res/lang/es.ini", lang_dir, ly_lang_path, "es.ini", .{});
|
||||||
try installFile("res/lang/fr.ini", lang_dir, lang_path, "fr.ini", .{});
|
try installFile("res/lang/fr.ini", lang_dir, ly_lang_path, "fr.ini", .{});
|
||||||
try installFile("res/lang/it.ini", lang_dir, lang_path, "it.ini", .{});
|
try installFile("res/lang/it.ini", lang_dir, ly_lang_path, "it.ini", .{});
|
||||||
try installFile("res/lang/pl.ini", lang_dir, lang_path, "pl.ini", .{});
|
try installFile("res/lang/pl.ini", lang_dir, ly_lang_path, "pl.ini", .{});
|
||||||
try installFile("res/lang/pt.ini", lang_dir, lang_path, "pt.ini", .{});
|
try installFile("res/lang/pt.ini", lang_dir, ly_lang_path, "pt.ini", .{});
|
||||||
try installFile("res/lang/pt_BR.ini", lang_dir, lang_path, "pt_BR.ini", .{});
|
try installFile("res/lang/pt_BR.ini", lang_dir, ly_lang_path, "pt_BR.ini", .{});
|
||||||
try installFile("res/lang/ro.ini", lang_dir, lang_path, "ro.ini", .{});
|
try installFile("res/lang/ro.ini", lang_dir, ly_lang_path, "ro.ini", .{});
|
||||||
try installFile("res/lang/ru.ini", lang_dir, lang_path, "ru.ini", .{});
|
try installFile("res/lang/ru.ini", lang_dir, ly_lang_path, "ru.ini", .{});
|
||||||
try installFile("res/lang/sr.ini", lang_dir, lang_path, "sr.ini", .{});
|
try installFile("res/lang/sr.ini", lang_dir, ly_lang_path, "sr.ini", .{});
|
||||||
try installFile("res/lang/sv.ini", lang_dir, lang_path, "sv.ini", .{});
|
try installFile("res/lang/sv.ini", lang_dir, ly_lang_path, "sv.ini", .{});
|
||||||
try installFile("res/lang/tr.ini", lang_dir, lang_path, "tr.ini", .{});
|
try installFile("res/lang/tr.ini", lang_dir, ly_lang_path, "tr.ini", .{});
|
||||||
try installFile("res/lang/uk.ini", lang_dir, lang_path, "uk.ini", .{});
|
try installFile("res/lang/uk.ini", lang_dir, ly_lang_path, "uk.ini", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const pam_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/pam.d" });
|
const pam_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/pam.d" });
|
||||||
if (!std.mem.eql(u8, dest_directory, "")) {
|
if (!std.mem.eql(u8, dest_directory, "")) {
|
||||||
std.fs.cwd().makePath(pam_path) catch {
|
std.fs.cwd().makePath(pam_path) catch {
|
||||||
std.debug.print("warn: {s} already exists as a directory.\n", .{pam_path});
|
std.debug.print("warn: {s} already exists as a directory.\n", .{pam_path});
|
||||||
|
@ -275,23 +321,23 @@ 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, _: ProgressNode) !void {
|
||||||
const allocator = step.owner.allocator;
|
const allocator = step.owner.allocator;
|
||||||
|
|
||||||
try deleteTree(allocator, data_directory, "ly data directory not found");
|
try deleteTree(allocator, config_directory, "/ly", "ly data directory not found");
|
||||||
|
|
||||||
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/usr/bin/", exe_name });
|
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin/", executable_name });
|
||||||
var success = true;
|
var success = true;
|
||||||
std.fs.cwd().deleteFile(exe_path) catch {
|
std.fs.cwd().deleteFile(exe_path) catch {
|
||||||
std.debug.print("warn: ly executable not found.", .{});
|
std.debug.print("warn: ly executable not found\n", .{});
|
||||||
success = false;
|
success = false;
|
||||||
};
|
};
|
||||||
if (success) std.debug.print("info: deleted {s}\n", .{exe_path});
|
if (success) std.debug.print("info: deleted {s}\n", .{exe_path});
|
||||||
|
|
||||||
try deleteFile(allocator, "/etc/pam.d/ly", "ly pam file not found");
|
try deleteFile(allocator, config_directory, "/pam.d/ly", "ly pam file not found");
|
||||||
try deleteFile(allocator, "/usr/lib/systemd/system/ly.service", "systemd service not found");
|
try deleteFile(allocator, prefix_directory, "/lib/systemd/system/ly.service", "systemd service not found");
|
||||||
try deleteFile(allocator, "/etc/init.d/ly", "openrc service not found");
|
try deleteFile(allocator, config_directory, "/init.d/ly", "openrc service not found");
|
||||||
try deleteTree(allocator, "/etc/sv/ly", "runit service not found");
|
try deleteTree(allocator, config_directory, "/sv/ly", "runit service not found");
|
||||||
try deleteTree(allocator, "/etc/s6/sv/ly-srv", "s6 service not found");
|
try deleteTree(allocator, config_directory, "/s6/sv/ly-srv", "s6 service not found");
|
||||||
try deleteFile(allocator, "/etc/s6/adminsv/default/contents.d/ly-srv", "s6 admin service not found");
|
try deleteFile(allocator, config_directory, "/s6/adminsv/default/contents.d/ly-srv", "s6 admin service not found");
|
||||||
try deleteFile(allocator, "/etc/dinit.d/ly", "dinit service not found");
|
try deleteFile(allocator, config_directory, "/dinit.d/ly", "dinit service not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getVersionStr(b: *std.Build, name: []const u8, version: std.SemanticVersion) ![]const u8 {
|
fn getVersionStr(b: *std.Build, name: []const u8, version: std.SemanticVersion) ![]const u8 {
|
||||||
|
@ -360,34 +406,78 @@ fn installFile(
|
||||||
std.debug.print("info: installed {s}/{s}\n", .{ destination_directory_path, destination_file });
|
std.debug.print("info: installed {s}/{s}\n", .{ destination_directory_path, destination_file });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn patchFile(allocator: std.mem.Allocator, source_file: []const u8, patch_map: PatchMap) ![]const u8 {
|
||||||
|
var file = try std.fs.cwd().openFile(source_file, .{});
|
||||||
|
defer file.close();
|
||||||
|
|
||||||
|
const reader = file.reader();
|
||||||
|
var text = try reader.readAllAlloc(allocator, std.math.maxInt(u16));
|
||||||
|
|
||||||
|
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(
|
||||||
|
text: []const u8,
|
||||||
|
destination_directory: std.fs.Dir,
|
||||||
|
destination_directory_path: []const u8,
|
||||||
|
destination_file: []const u8,
|
||||||
|
options: std.fs.File.CreateFlags,
|
||||||
|
) !void {
|
||||||
|
var file = try destination_directory.createFile(destination_file, options);
|
||||||
|
defer file.close();
|
||||||
|
|
||||||
|
const writer = file.writer();
|
||||||
|
try writer.writeAll(text);
|
||||||
|
|
||||||
|
std.debug.print("info: installed {s}/{s}\n", .{ destination_directory_path, destination_file });
|
||||||
|
}
|
||||||
|
|
||||||
fn deleteFile(
|
fn deleteFile(
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
|
prefix: []const u8,
|
||||||
file: []const u8,
|
file: []const u8,
|
||||||
warning: []const u8,
|
warning: []const u8,
|
||||||
) !void {
|
) !void {
|
||||||
const path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, file });
|
const path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix, file });
|
||||||
var success = true;
|
|
||||||
|
|
||||||
std.fs.cwd().deleteFile(path) catch {
|
std.fs.cwd().deleteFile(path) catch |err| {
|
||||||
|
if (err == error.FileNotFound) {
|
||||||
std.debug.print("warn: {s}\n", .{warning});
|
std.debug.print("warn: {s}\n", .{warning});
|
||||||
success = false;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (success) std.debug.print("info: deleted {s}\n", .{path});
|
std.debug.print("info: deleted {s}\n", .{path});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deleteTree(
|
fn deleteTree(
|
||||||
allocator: std.mem.Allocator,
|
allocator: std.mem.Allocator,
|
||||||
|
prefix: []const u8,
|
||||||
directory: []const u8,
|
directory: []const u8,
|
||||||
warning: []const u8,
|
warning: []const u8,
|
||||||
) !void {
|
) !void {
|
||||||
const path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, directory });
|
const path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix, directory });
|
||||||
var success = true;
|
|
||||||
|
|
||||||
std.fs.cwd().deleteTree(path) catch {
|
var dir = std.fs.cwd().openDir(path, .{}) catch |err| {
|
||||||
|
if (err == error.FileNotFound) {
|
||||||
std.debug.print("warn: {s}\n", .{warning});
|
std.debug.print("warn: {s}\n", .{warning});
|
||||||
success = false;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (success) std.debug.print("info: deleted {s}\n", .{path});
|
return err;
|
||||||
|
};
|
||||||
|
dir.close();
|
||||||
|
|
||||||
|
try std.fs.cwd().deleteTree(path);
|
||||||
|
|
||||||
|
std.debug.print("info: deleted {s}\n", .{path});
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ save = true
|
||||||
# New save files are now loaded from the same directory as the config
|
# New save files are now loaded from the same directory as the config
|
||||||
# Currently used to migrate old save files to the new version
|
# Currently used to migrate old save files to the new version
|
||||||
# File in which to save and load the default desktop and login
|
# File in which to save and load the default desktop and login
|
||||||
save_file = /etc/ly/save
|
save_file = $CONFIG_DIRECTORY/ly/save
|
||||||
|
|
||||||
# Remove power management command hints
|
# Remove power management command hints
|
||||||
hide_key_hints = false
|
hide_key_hints = false
|
||||||
|
@ -124,11 +124,11 @@ restart_cmd = /sbin/shutdown -r now
|
||||||
sleep_cmd = null
|
sleep_cmd = null
|
||||||
|
|
||||||
# Active language
|
# Active language
|
||||||
# Available languages are found in /etc/ly/lang/
|
# Available languages are found in $CONFIG_DIRECTORY/ly/lang/
|
||||||
lang = en
|
lang = en
|
||||||
|
|
||||||
# TTY in use
|
# TTY in use
|
||||||
tty = 2
|
tty = $DEFAULT_TTY
|
||||||
|
|
||||||
# Console path
|
# Console path
|
||||||
console_dev = /dev/console
|
console_dev = /dev/console
|
||||||
|
@ -147,35 +147,35 @@ numlock = false
|
||||||
service_name = ly
|
service_name = ly
|
||||||
|
|
||||||
# Terminal reset command (tput is faster)
|
# Terminal reset command (tput is faster)
|
||||||
term_reset_cmd = /usr/bin/tput reset
|
term_reset_cmd = $PREFIX_DIRECTORY/bin/tput reset
|
||||||
|
|
||||||
# Terminal restore cursor command
|
# Terminal restore cursor command
|
||||||
term_restore_cursor_cmd = /usr/bin/tput cnorm
|
term_restore_cursor_cmd = $PREFIX_DIRECTORY/bin/tput cnorm
|
||||||
|
|
||||||
# Cookie generator
|
# Cookie generator
|
||||||
mcookie_cmd = /usr/bin/mcookie
|
mcookie_cmd = $PREFIX_DIRECTORY/bin/mcookie
|
||||||
|
|
||||||
# Wayland setup command
|
# Wayland setup command
|
||||||
wayland_cmd = /etc/ly/wsetup.sh
|
wayland_cmd = $CONFIG_DIRECTORY/ly/wsetup.sh
|
||||||
|
|
||||||
# Wayland desktop environments
|
# Wayland desktop environments
|
||||||
waylandsessions = /usr/share/wayland-sessions
|
waylandsessions = $PREFIX_DIRECTORY/share/wayland-sessions
|
||||||
|
|
||||||
# xinitrc
|
# xinitrc
|
||||||
# If null, the xinitrc session will be hidden
|
# If null, the xinitrc session will be hidden
|
||||||
xinitrc = ~/.xinitrc
|
xinitrc = ~/.xinitrc
|
||||||
|
|
||||||
# Xorg server command
|
# Xorg server command
|
||||||
x_cmd = /usr/bin/X
|
x_cmd = $PREFIX_DIRECTORY/bin/X
|
||||||
|
|
||||||
# Xorg setup command
|
# Xorg setup command
|
||||||
x_cmd_setup = /etc/ly/xsetup.sh
|
x_cmd_setup = $CONFIG_DIRECTORY/ly/xsetup.sh
|
||||||
|
|
||||||
# Xorg xauthority edition tool
|
# Xorg xauthority edition tool
|
||||||
xauth_cmd = /usr/bin/xauth
|
xauth_cmd = $PREFIX_DIRECTORY/bin/xauth
|
||||||
|
|
||||||
# Xorg desktop environments
|
# Xorg desktop environments
|
||||||
xsessions = /usr/share/xsessions
|
xsessions = $PREFIX_DIRECTORY/share/xsessions
|
||||||
|
|
||||||
# Brightness control
|
# Brightness control
|
||||||
brightness_down_key = F5
|
brightness_down_key = F5
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
type = process
|
type = process
|
||||||
restart = true
|
restart = true
|
||||||
smooth-recovery = true
|
smooth-recovery = true
|
||||||
# note: /usr/bin/ly-dm when installing from pacman on artix, /usr/bin/ly when building from source
|
command = $PREFIX_DIRECTORY/bin/$EXE_NAME
|
||||||
command = /usr/bin/ly
|
|
||||||
depends-on = loginready
|
depends-on = loginready
|
||||||
termsignal = HUP
|
termsignal = HUP
|
||||||
# ly needs access to the console while loginready already occupies it
|
# ly needs access to the console while loginready already occupies it
|
||||||
|
|
|
@ -23,13 +23,13 @@ fi
|
||||||
CONFTTY=$(cat /etc/ly/config.ini | sed -n 's/^tty.*=[^1-9]*// p')
|
CONFTTY=$(cat /etc/ly/config.ini | sed -n 's/^tty.*=[^1-9]*// p')
|
||||||
|
|
||||||
## The execution vars
|
## The execution vars
|
||||||
# If CONFTTY is empty then default to 2
|
# If CONFTTY is empty then default to $DEFAULT_TTY
|
||||||
TTY="tty${CONFTTY:-2}"
|
TTY="tty${CONFTTY:-$DEFAULT_TTY}"
|
||||||
TERM=linux
|
TERM=linux
|
||||||
BAUD=38400
|
BAUD=38400
|
||||||
# If we don't have getty then we should have agetty
|
# If we don't have getty then we should have agetty
|
||||||
command=${commandB:-$commandUL}
|
command=${commandB:-$commandUL}
|
||||||
command_args_foreground="-nl /usr/bin/ly $TTY $BAUD $TERM"
|
command_args_foreground="-nl $PREFIX_DIRECTORY/bin/$EXE_NAME $TTY $BAUD $TERM"
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
after agetty
|
after agetty
|
||||||
|
|
|
@ -8,5 +8,5 @@ fi
|
||||||
BAUD_RATE=38400
|
BAUD_RATE=38400
|
||||||
TERM_NAME=linux
|
TERM_NAME=linux
|
||||||
|
|
||||||
auxtty=$(/bin/cat /etc/ly/config.ini 2>/dev/null 1| /bin/sed -n 's/\(^[[:space:]]*tty[[:space:]]*=[[:space:]]*\)\([[:digit:]][[:digit:]]*\)\(.*\)/\2/p')
|
auxtty=$(/bin/cat $CONFIG_DIRECTORY/ly/config.ini 2>/dev/null 1| /bin/sed -n 's/\(^[[:space:]]*tty[[:space:]]*=[[:space:]]*\)\([[:digit:]][[:digit:]]*\)\(.*\)/\2/p')
|
||||||
TTY=tty${auxtty:-2}
|
TTY=tty${auxtty:-$DEFAULT_TTY}
|
||||||
|
|
|
@ -10,4 +10,4 @@ elif [ -x /sbin/agetty -o -x /bin/agetty ]; then
|
||||||
GETTY=agetty
|
GETTY=agetty
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec setsid ${GETTY} ${GETTY_ARGS} -nl /usr/bin/ly "${TTY}" "${BAUD_RATE}" "${TERM_NAME}"
|
exec setsid ${GETTY} ${GETTY_ARGS} -nl $PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME "${TTY}" "${BAUD_RATE}" "${TERM_NAME}"
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/execlineb -P
|
#!/bin/execlineb -P
|
||||||
exec agetty -L -8 -n -l /usr/bin/ly tty2 115200
|
exec agetty -L -8 -n -l $PREFIX_DIRECTORY/bin/$EXE_NAME tty$DEFAULT_TTY 115200
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=TUI display manager
|
Description=TUI display manager
|
||||||
After=systemd-user-sessions.service plymouth-quit-wait.service
|
After=systemd-user-sessions.service plymouth-quit-wait.service
|
||||||
After=getty@tty2.service
|
After=getty@tty$DEFAULT_TTY.service
|
||||||
Conflicts=getty@tty2.service
|
Conflicts=getty@tty$DEFAULT_TTY.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=idle
|
Type=idle
|
||||||
ExecStart=/usr/bin/ly
|
ExecStart=$PREFIX_DIRECTORY/bin/$EXECUTABLE_NAME
|
||||||
StandardInput=tty
|
StandardInput=tty
|
||||||
TTYPath=/dev/tty2
|
TTYPath=/dev/tty$DEFAULT_TTY
|
||||||
TTYReset=yes
|
TTYReset=yes
|
||||||
TTYVHangup=yes
|
TTYVHangup=yes
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ case $SHELL in
|
||||||
*/bash)
|
*/bash)
|
||||||
[ -z "$BASH" ] && exec $SHELL $0 "$@"
|
[ -z "$BASH" ] && exec $SHELL $0 "$@"
|
||||||
set +o posix
|
set +o posix
|
||||||
[ -f /etc/profile ] && . /etc/profile
|
[ -f $CONFIG_DIRECTORY/profile ] && . $CONFIG_DIRECTORY/profile
|
||||||
if [ -f $HOME/.bash_profile ]; then
|
if [ -f $HOME/.bash_profile ]; then
|
||||||
. $HOME/.bash_profile
|
. $HOME/.bash_profile
|
||||||
elif [ -f $HOME/.bash_login ]; then
|
elif [ -f $HOME/.bash_login ]; then
|
||||||
|
@ -21,7 +21,7 @@ case $SHELL in
|
||||||
;;
|
;;
|
||||||
*/zsh)
|
*/zsh)
|
||||||
[ -z "$ZSH_NAME" ] && exec $SHELL $0 "$@"
|
[ -z "$ZSH_NAME" ] && exec $SHELL $0 "$@"
|
||||||
[ -d /etc/zsh ] && zdir=/etc/zsh || zdir=/etc
|
[ -d $CONFIG_DIRECTORY/zsh ] && zdir=$CONFIG_DIRECTORY/zsh || zdir=$CONFIG_DIRECTORY
|
||||||
zhome=${ZDOTDIR:-$HOME}
|
zhome=${ZDOTDIR:-$HOME}
|
||||||
# zshenv is always sourced automatically.
|
# zshenv is always sourced automatically.
|
||||||
[ -f $zdir/zprofile ] && . $zdir/zprofile
|
[ -f $zdir/zprofile ] && . $zdir/zprofile
|
||||||
|
@ -34,12 +34,12 @@ case $SHELL in
|
||||||
# [t]cshrc is always sourced automatically.
|
# [t]cshrc is always sourced automatically.
|
||||||
# Note that sourcing csh.login after .cshrc is non-standard.
|
# Note that sourcing csh.login after .cshrc is non-standard.
|
||||||
wlsess_tmp=`mktemp /tmp/wlsess-env-XXXXXX`
|
wlsess_tmp=`mktemp /tmp/wlsess-env-XXXXXX`
|
||||||
$SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c 'export -p' >! $wlsess_tmp"
|
$SHELL -c "if (-f $CONFIG_DIRECTORY/csh.login) source $CONFIG_DIRECTORY/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c 'export -p' >! $wlsess_tmp"
|
||||||
. $wlsess_tmp
|
. $wlsess_tmp
|
||||||
rm -f $wlsess_tmp
|
rm -f $wlsess_tmp
|
||||||
;;
|
;;
|
||||||
*/fish)
|
*/fish)
|
||||||
[ -f /etc/profile ] && . /etc/profile
|
[ -f $CONFIG_DIRECTORY/profile ] && . $CONFIG_DIRECTORY/profile
|
||||||
[ -f $HOME/.profile ] && . $HOME/.profile
|
[ -f $HOME/.profile ] && . $HOME/.profile
|
||||||
xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX`
|
xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX`
|
||||||
$SHELL --login -c "/bin/sh -c 'export -p' > $xsess_tmp"
|
$SHELL --login -c "/bin/sh -c 'export -p' > $xsess_tmp"
|
||||||
|
@ -47,7 +47,7 @@ case $SHELL in
|
||||||
rm -f $xsess_tmp
|
rm -f $xsess_tmp
|
||||||
;;
|
;;
|
||||||
*) # Plain sh, ksh, and anything we do not know.
|
*) # Plain sh, ksh, and anything we do not know.
|
||||||
[ -f /etc/profile ] && . /etc/profile
|
[ -f $CONFIG_DIRECTORY/profile ] && . $CONFIG_DIRECTORY/profile
|
||||||
[ -f $HOME/.profile ] && . $HOME/.profile
|
[ -f $HOME/.profile ] && . $HOME/.profile
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -10,7 +10,7 @@ case $SHELL in
|
||||||
*/bash)
|
*/bash)
|
||||||
[ -z "$BASH" ] && exec $SHELL $0 "$@"
|
[ -z "$BASH" ] && exec $SHELL $0 "$@"
|
||||||
set +o posix
|
set +o posix
|
||||||
[ -f /etc/profile ] && . /etc/profile
|
[ -f $CONFIG_DIRECTORY/profile ] && . $CONFIG_DIRECTORY/profile
|
||||||
if [ -f $HOME/.bash_profile ]; then
|
if [ -f $HOME/.bash_profile ]; then
|
||||||
. $HOME/.bash_profile
|
. $HOME/.bash_profile
|
||||||
elif [ -f $HOME/.bash_login ]; then
|
elif [ -f $HOME/.bash_login ]; then
|
||||||
|
@ -21,7 +21,7 @@ case $SHELL in
|
||||||
;;
|
;;
|
||||||
*/zsh)
|
*/zsh)
|
||||||
[ -z "$ZSH_NAME" ] && exec $SHELL $0 "$@"
|
[ -z "$ZSH_NAME" ] && exec $SHELL $0 "$@"
|
||||||
[ -d /etc/zsh ] && zdir=/etc/zsh || zdir=/etc
|
[ -d $CONFIG_DIRECTORY/zsh ] && zdir=$CONFIG_DIRECTORY/zsh || zdir=$CONFIG_DIRECTORY
|
||||||
zhome=${ZDOTDIR:-$HOME}
|
zhome=${ZDOTDIR:-$HOME}
|
||||||
# zshenv is always sourced automatically.
|
# zshenv is always sourced automatically.
|
||||||
[ -f $zdir/zprofile ] && . $zdir/zprofile
|
[ -f $zdir/zprofile ] && . $zdir/zprofile
|
||||||
|
@ -34,12 +34,12 @@ case $SHELL in
|
||||||
# [t]cshrc is always sourced automatically.
|
# [t]cshrc is always sourced automatically.
|
||||||
# Note that sourcing csh.login after .cshrc is non-standard.
|
# Note that sourcing csh.login after .cshrc is non-standard.
|
||||||
xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX`
|
xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX`
|
||||||
$SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c 'export -p' >! $xsess_tmp"
|
$SHELL -c "if (-f $CONFIG_DIRECTORY/csh.login) source $CONFIG_DIRECTORY/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c 'export -p' >! $xsess_tmp"
|
||||||
. $xsess_tmp
|
. $xsess_tmp
|
||||||
rm -f $xsess_tmp
|
rm -f $xsess_tmp
|
||||||
;;
|
;;
|
||||||
*/fish)
|
*/fish)
|
||||||
[ -f /etc/profile ] && . /etc/profile
|
[ -f $CONFIG_DIRECTORY/profile ] && . $CONFIG_DIRECTORY/profile
|
||||||
[ -f $HOME/.profile ] && . $HOME/.profile
|
[ -f $HOME/.profile ] && . $HOME/.profile
|
||||||
xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX`
|
xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX`
|
||||||
$SHELL --login -c "/bin/sh -c 'export -p' > $xsess_tmp"
|
$SHELL --login -c "/bin/sh -c 'export -p' > $xsess_tmp"
|
||||||
|
@ -47,17 +47,17 @@ case $SHELL in
|
||||||
rm -f $xsess_tmp
|
rm -f $xsess_tmp
|
||||||
;;
|
;;
|
||||||
*) # Plain sh, ksh, and anything we do not know.
|
*) # Plain sh, ksh, and anything we do not know.
|
||||||
[ -f /etc/profile ] && . /etc/profile
|
[ -f $CONFIG_DIRECTORY/profile ] && . $CONFIG_DIRECTORY/profile
|
||||||
[ -f $HOME/.profile ] && . $HOME/.profile
|
[ -f $HOME/.profile ] && . $HOME/.profile
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ -f /etc/xprofile ] && . /etc/xprofile
|
[ -f $CONFIG_DIRECTORY/xprofile ] && . $CONFIG_DIRECTORY/xprofile
|
||||||
[ -f $HOME/.xprofile ] && . $HOME/.xprofile
|
[ -f $HOME/.xprofile ] && . $HOME/.xprofile
|
||||||
|
|
||||||
# run all system xinitrc shell scripts.
|
# run all system xinitrc shell scripts.
|
||||||
if [ -d /etc/X11/xinit/xinitrc.d ]; then
|
if [ -d $CONFIG_DIRECTORY/X11/xinit/xinitrc.d ]; then
|
||||||
for i in /etc/X11/xinit/xinitrc.d/* ; do
|
for i in $CONFIG_DIRECTORY/X11/xinit/xinitrc.d/* ; do
|
||||||
if [ -x "$i" ]; then
|
if [ -x "$i" ]; then
|
||||||
. "$i"
|
. "$i"
|
||||||
fi
|
fi
|
||||||
|
@ -67,8 +67,8 @@ fi
|
||||||
# Load Xsession scripts
|
# Load Xsession scripts
|
||||||
# OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
|
# OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
|
||||||
# by the scripts to work
|
# by the scripts to work
|
||||||
xsessionddir="/etc/X11/Xsession.d"
|
xsessionddir="$CONFIG_DIRECTORY/X11/Xsession.d"
|
||||||
OPTIONFILE=/etc/X11/Xsession.options
|
OPTIONFILE=$CONFIG_DIRECTORY/X11/Xsession.options
|
||||||
USERXSESSION=$HOME/.xsession
|
USERXSESSION=$HOME/.xsession
|
||||||
USERXSESSIONRC=$HOME/.xsessionrc
|
USERXSESSIONRC=$HOME/.xsessionrc
|
||||||
ALTUSERXSESSION=$HOME/.Xsession
|
ALTUSERXSESSION=$HOME/.Xsession
|
||||||
|
@ -83,12 +83,12 @@ if [ -d "$xsessionddir" ]; then
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d /etc/X11/Xresources ]; then
|
if [ -d $CONFIG_DIRECTORY/X11/Xresources ]; then
|
||||||
for i in /etc/X11/Xresources/*; do
|
for i in $CONFIG_DIRECTORY/X11/Xresources/*; do
|
||||||
[ -f $i ] && xrdb -merge $i
|
[ -f $i ] && xrdb -merge $i
|
||||||
done
|
done
|
||||||
elif [ -f /etc/X11/Xresources ]; then
|
elif [ -f $CONFIG_DIRECTORY/X11/Xresources ]; then
|
||||||
xrdb -merge /etc/X11/Xresources
|
xrdb -merge $CONFIG_DIRECTORY/X11/Xresources
|
||||||
fi
|
fi
|
||||||
[ -f $HOME/.Xresources ] && xrdb -merge $HOME/.Xresources
|
[ -f $HOME/.Xresources ] && xrdb -merge $HOME/.Xresources
|
||||||
[ -f $XDG_CONFIG_HOME/X11/Xresources ] && xrdb -merge $XDG_CONFIG_HOME/X11/Xresources
|
[ -f $XDG_CONFIG_HOME/X11/Xresources ] && xrdb -merge $XDG_CONFIG_HOME/X11/Xresources
|
||||||
|
|
|
@ -46,11 +46,11 @@ term_restore_cursor_cmd: []const u8 = "/usr/bin/tput cnorm",
|
||||||
tty: u8 = build_options.tty,
|
tty: u8 = build_options.tty,
|
||||||
vi_mode: bool = false,
|
vi_mode: bool = false,
|
||||||
vi_default_mode: ViMode = .normal,
|
vi_default_mode: ViMode = .normal,
|
||||||
wayland_cmd: []const u8 = build_options.data_directory ++ "/wsetup.sh",
|
wayland_cmd: []const u8 = build_options.config_directory ++ "/ly/wsetup.sh",
|
||||||
waylandsessions: []const u8 = "/usr/share/wayland-sessions",
|
waylandsessions: []const u8 = "/usr/share/wayland-sessions",
|
||||||
x_cmd: []const u8 = "/usr/bin/X",
|
x_cmd: []const u8 = "/usr/bin/X",
|
||||||
xinitrc: ?[]const u8 = "~/.xinitrc",
|
xinitrc: ?[]const u8 = "~/.xinitrc",
|
||||||
x_cmd_setup: []const u8 = build_options.data_directory ++ "/xsetup.sh",
|
x_cmd_setup: []const u8 = build_options.config_directory ++ "/ly/xsetup.sh",
|
||||||
xauth_cmd: []const u8 = "/usr/bin/xauth",
|
xauth_cmd: []const u8 = "/usr/bin/xauth",
|
||||||
xsessions: []const u8 = "/usr/share/xsessions",
|
xsessions: []const u8 = "/usr/share/xsessions",
|
||||||
brightness_down_key: []const u8 = "F5",
|
brightness_down_key: []const u8 = "F5",
|
||||||
|
|
|
@ -107,7 +107,7 @@ pub fn main() !void {
|
||||||
var save_ini = Ini(Save).init(allocator);
|
var save_ini = Ini(Save).init(allocator);
|
||||||
defer save_ini.deinit();
|
defer save_ini.deinit();
|
||||||
|
|
||||||
var save_path: []const u8 = build_options.data_directory ++ "/save.ini";
|
var save_path: []const u8 = build_options.config_directory ++ "/ly/save.ini";
|
||||||
var save_path_alloc = false;
|
var save_path_alloc = false;
|
||||||
defer {
|
defer {
|
||||||
if (save_path_alloc) allocator.free(save_path);
|
if (save_path_alloc) allocator.free(save_path);
|
||||||
|
@ -151,14 +151,14 @@ pub fn main() !void {
|
||||||
// };
|
// };
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
const config_path = build_options.data_directory ++ "/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, comment_characters, migrator.configFieldHandler) catch _config: {
|
||||||
config_load_failed = true;
|
config_load_failed = true;
|
||||||
break :_config Config{};
|
break :_config Config{};
|
||||||
};
|
};
|
||||||
|
|
||||||
const lang_path = try std.fmt.allocPrint(allocator, "{s}/lang/{s}.ini", .{ build_options.data_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, comment_characters, null) catch Lang{};
|
||||||
|
|
Loading…
Reference in New Issue