mirror of https://github.com/fairyglade/ly.git
migrator changes, and small things
This commit is contained in:
parent
5a4c056f37
commit
d06f8e49b4
|
@ -179,12 +179,12 @@ fn setXdgSessionEnv(display_server: enums.DisplayServer) void {
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setXdgEnv(tty_str: [:0]u8, desktop_name: [:0]const u8, desktop_names: [:0]const u8) !void {
|
fn setXdgEnv(tty_str: [:0]u8, desktop_name: [:0]const u8, xdg_desktop_names: [:0]const u8) !void {
|
||||||
const uid = interop.getuid();
|
const uid = interop.getuid();
|
||||||
var uid_buffer: [10 + @sizeOf(u32) + 1]u8 = undefined;
|
var uid_buffer: [10 + @sizeOf(u32) + 1]u8 = undefined;
|
||||||
const uid_str = try std.fmt.bufPrintZ(&uid_buffer, "/run/user/{d}", .{uid});
|
const uid_str = try std.fmt.bufPrintZ(&uid_buffer, "/run/user/{d}", .{uid});
|
||||||
|
|
||||||
_ = interop.setenv("XDG_CURRENT_DESKTOP", desktop_names.ptr, 0);
|
_ = interop.setenv("XDG_CURRENT_DESKTOP", xdg_desktop_names.ptr, 0);
|
||||||
_ = interop.setenv("XDG_RUNTIME_DIR", uid_str.ptr, 0);
|
_ = interop.setenv("XDG_RUNTIME_DIR", uid_str.ptr, 0);
|
||||||
_ = interop.setenv("XDG_SESSION_CLASS", "user", 0);
|
_ = interop.setenv("XDG_SESSION_CLASS", "user", 0);
|
||||||
_ = interop.setenv("XDG_SESSION_ID", "1", 0);
|
_ = interop.setenv("XDG_SESSION_ID", "1", 0);
|
||||||
|
@ -407,7 +407,6 @@ fn executeX11Cmd(shell: [*:0]const u8, pw_dir: [*:0]const u8, config: Config, de
|
||||||
interop.xcb.xcb_disconnect(xcb);
|
interop.xcb.xcb_disconnect(xcb);
|
||||||
|
|
||||||
std.posix.kill(x_pid, 0) catch return;
|
std.posix.kill(x_pid, 0) catch return;
|
||||||
|
|
||||||
std.posix.kill(x_pid, std.posix.SIG.TERM) catch {};
|
std.posix.kill(x_pid, std.posix.SIG.TERM) catch {};
|
||||||
|
|
||||||
var status: c_int = 0;
|
var status: c_int = 0;
|
||||||
|
|
|
@ -2,10 +2,10 @@ const std = @import("std");
|
||||||
const ini = @import("zigini");
|
const ini = @import("zigini");
|
||||||
const Save = @import("Save.zig");
|
const Save = @import("Save.zig");
|
||||||
|
|
||||||
pub fn tryMigrateSaveFile(user_buf: *[32]u8, old_path: []const u8, new_path: []const u8) Save {
|
pub fn tryMigrateSaveFile(user_buf: *[32]u8, path: []const u8) Save {
|
||||||
var save = Save{};
|
var save = Save{};
|
||||||
|
|
||||||
var file = std.fs.openFileAbsolute(old_path, .{}) catch return save;
|
var file = std.fs.openFileAbsolute(path, .{}) catch return save;
|
||||||
defer file.close();
|
defer file.close();
|
||||||
|
|
||||||
const reader = file.reader();
|
const reader = file.reader();
|
||||||
|
@ -26,11 +26,5 @@ pub fn tryMigrateSaveFile(user_buf: *[32]u8, old_path: []const u8, new_path: []c
|
||||||
}
|
}
|
||||||
save.session_index = session_index;
|
save.session_index = session_index;
|
||||||
|
|
||||||
const new_save_file = std.fs.cwd().createFile(new_path, .{}) catch return save;
|
|
||||||
ini.writeFromStruct(save, new_save_file.writer(), null) catch return save;
|
|
||||||
|
|
||||||
// Delete old save file
|
|
||||||
std.fs.deleteFileAbsolute(old_path) catch {};
|
|
||||||
|
|
||||||
return save;
|
return save;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ pub fn main() !void {
|
||||||
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) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file, save_path);
|
save = save_ini.readFileToStruct(save_path) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
config = config_ini.readFileToStructWithMap(build_options.data_directory ++ "/config.ini", mapped_config_fields) catch Config{};
|
config = config_ini.readFileToStructWithMap(build_options.data_directory ++ "/config.ini", mapped_config_fields) catch Config{};
|
||||||
|
@ -123,7 +123,7 @@ pub fn main() !void {
|
||||||
|
|
||||||
if (config.load) {
|
if (config.load) {
|
||||||
var user_buf: [32]u8 = undefined;
|
var user_buf: [32]u8 = undefined;
|
||||||
save = save_ini.readFileToStruct(save_path) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file, save_path);
|
save = save_ini.readFileToStruct(save_path) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue