mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
turns out passing in the -u flag didn't actually work before...
Additionally, in the case that the directory doesn't exist mezzaluna will default back to the config at ~/.config/mez/
This commit is contained in:
parent
fd997e8219
commit
f60a2c5c37
3 changed files with 34 additions and 46 deletions
|
|
@ -48,33 +48,12 @@ pub fn loadRuntimeDir(self: *zlua.Lua) !void {
|
|||
}
|
||||
|
||||
pub fn setBaseConfig(self: *zlua.Lua, path: []const u8) !void {
|
||||
{
|
||||
_ = try self.getGlobal("mez");
|
||||
defer self.pop(1);
|
||||
_ = self.getField(-1, "path");
|
||||
defer self.pop(1);
|
||||
const new_path = try std.fs.path.join(gpa, &[_][]const u8{ path, "init.lua" });
|
||||
defer gpa.free(new_path);
|
||||
_ = self.pushString(new_path);
|
||||
self.setField(-2, "config");
|
||||
}
|
||||
{
|
||||
_ = try self.getGlobal("mez");
|
||||
defer self.pop(1);
|
||||
_ = self.getField(-1, "path");
|
||||
defer self.pop(1);
|
||||
const cur_path = self.toString(-1) catch "";
|
||||
|
||||
const unsentinel: []const u8 = std.mem.span(cur_path.ptr);
|
||||
const new_path = try std.mem.concat(gpa, u8, &[_][]const u8{
|
||||
unsentinel,
|
||||
";",
|
||||
path,
|
||||
});
|
||||
defer gpa.free(new_path);
|
||||
_ = self.pushString(new_path);
|
||||
_ = self.setField(-2, "path");
|
||||
}
|
||||
_ = try self.getGlobal("mez");
|
||||
defer self.pop(1);
|
||||
_ = self.getField(-1, "path");
|
||||
defer self.pop(1);
|
||||
_ = self.pushString(path);
|
||||
self.setField(-2, "config");
|
||||
}
|
||||
|
||||
fn loadBaseConfig(self: *zlua.Lua) !void {
|
||||
|
|
@ -160,7 +139,12 @@ pub fn init(self: *Lua, cfg: Config) !void {
|
|||
|
||||
openMezLibs(self.state);
|
||||
|
||||
if (!cfg.enabled) try setBaseConfig(self.state, "");
|
||||
if (!cfg.enabled) {
|
||||
try setBaseConfig(self.state, "");
|
||||
} else if (cfg.path) |path| {
|
||||
defer gpa.free(path);
|
||||
try setBaseConfig(self.state, path);
|
||||
}
|
||||
loadRuntimeDir(self.state) catch |err| if (err == error.LuaRuntime) {
|
||||
std.log.warn("{s}", .{try self.state.toString(-1)});
|
||||
};
|
||||
|
|
@ -169,10 +153,6 @@ pub fn init(self: *Lua, cfg: Config) !void {
|
|||
std.log.warn("{s}", .{try self.state.toString(-1)});
|
||||
};
|
||||
|
||||
if (cfg.path) |path| {
|
||||
defer gpa.free(path);
|
||||
try setBaseConfig(self.state, path);
|
||||
}
|
||||
if (cfg.enabled) {
|
||||
loadConfigDir(self.state) catch |err| if (err == error.LuaRuntime) {
|
||||
std.log.warn("{s}", .{try self.state.toString(-1)});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue