Compare commits

..

No commits in common. "365933e39ec4cf7c46861d75356dfc24fa6f5230" and "002630995dcc308e759dcd45530e09b75551eafb" have entirely different histories.

5 changed files with 10 additions and 48 deletions

View File

@ -1,13 +1,13 @@
const std = @import("std");
const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 0, .build = "dev" };
const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 0 };
pub fn build(b: *std.Build) void {
const data_directory = b.option([]const u8, "data_directory", "Specify a default data directory (default is /etc/ly)");
const build_options = b.addOptions();
build_options.addOption([]const u8, "data_directory", data_directory orelse "/etc/ly");
const version_str = b.fmt("{d}.{d}.{d}-{s}", .{ ly_version.major, ly_version.minor, ly_version.patch, ly_version.build.? });
const version_str = b.fmt("{d}.{d}.{d}", .{ ly_version.major, ly_version.minor, ly_version.patch });
build_options.addOption([]const u8, "version", version_str);

View File

@ -1,2 +1,4 @@
const Save = @This();
user: ?[]const u8 = null,
session_index: ?u64 = null,

View File

@ -1,30 +0,0 @@
const std = @import("std");
const ini = @import("zigini");
const Save = @import("Save.zig");
const Allocator = std.mem.Allocator;
pub fn tryMigrateSaveFile(allocator: Allocator, path: []const u8) Save {
var file = std.fs.openFileAbsolute(path, .{ .mode = .read_write }) catch return .{};
defer file.close();
const reader = file.reader();
const user_length = reader.readIntLittle(u64) catch return .{};
const user_buffer = allocator.alloc(u8, user_length) catch return .{};
defer allocator.free(user_buffer);
const read_user_length = reader.read(user_buffer) catch return .{};
if (read_user_length != user_length) return .{};
const session_index = reader.readIntLittle(u64) catch return .{};
const save = .{
.user = user_buffer,
.session_index = session_index,
};
ini.writeFromStruct(save, file.writer(), null) catch return save;
return save;
}

View File

@ -2,7 +2,6 @@ const std = @import("std");
const build_options = @import("build_options");
const builtin = @import("builtin");
const clap = @import("clap");
const ini = @import("zigini");
const auth = @import("auth.zig");
const bigclock = @import("bigclock.zig");
const interop = @import("interop.zig");
@ -13,9 +12,9 @@ const Desktop = @import("tui/components/Desktop.zig");
const Text = @import("tui/components/Text.zig");
const InfoLine = @import("tui/components/InfoLine.zig");
const Config = @import("config/Config.zig");
const ini = @import("zigini");
const Lang = @import("config/Lang.zig");
const Save = @import("config/Save.zig");
const migrator = @import("config/migrator.zig");
const ViMode = @import("enums.zig").ViMode;
const SharedError = @import("SharedError.zig");
const utils = @import("tui/utils.zig");
@ -67,7 +66,6 @@ pub fn main() !void {
// Load configuration file
var config_ini = Ini(Config).init(allocator);
defer config_ini.deinit();
var lang_ini = Ini(Lang).init(allocator);
defer lang_ini.deinit();
@ -129,7 +127,7 @@ pub fn main() !void {
_ = termbox.tb_select_output_mode(termbox.TB_OUTPUT_NORMAL);
termbox.tb_clear();
// Needed to reset termbox after auth
// we need this to reset it after auth.
const tb_termios = try std.os.tcgetattr(std.os.STDIN_FILENO);
// Initialize terminal buffer
@ -166,10 +164,7 @@ pub fn main() !void {
if (config.load) {
var save_ini = Ini(Save).init(allocator);
defer save_ini.deinit();
// If it fails, we try to migrate the potentially old save file. And if we can't do that, we just create
// a new save file
const save = save_ini.readToStruct(config.save_file) catch migrator.tryMigrateSaveFile(allocator, config.save_file);
const save = save_ini.readToStruct(config.save_file) catch Save{};
if (save.user) |user| {
try login.text.appendSlice(user);

View File

@ -71,7 +71,7 @@ pub fn addEnvironment(self: *Desktop, name: []const u8, cmd: []const u8, display
try self.environments.append(.{
.entry_ini = null,
.name = name,
.xdg_name = getXdgName(name),
.xdg_name = name, // TODO
.cmd = cmd,
.specifier = switch (display_server) {
.wayland => self.lang.wayland,
@ -88,7 +88,7 @@ pub fn addEnvironmentWithIni(self: *Desktop, entry_ini: Ini(Entry), name: []cons
try self.environments.append(.{
.entry_ini = entry_ini,
.name = name,
.xdg_name = getXdgName(name),
.xdg_name = name, // TODO
.cmd = cmd,
.specifier = switch (display_server) {
.wayland => self.lang.wayland,
@ -102,7 +102,7 @@ pub fn addEnvironmentWithIni(self: *Desktop, entry_ini: Ini(Entry), name: []cons
}
pub fn crawl(self: *Desktop, path: []const u8, display_server: DisplayServer) !void {
var iterable_directory = std.fs.openIterableDirAbsolute(path, .{}) catch return;
var iterable_directory = try std.fs.openIterableDirAbsolute(path, .{});
defer iterable_directory.close();
var iterator = iterable_directory.iterate();
@ -173,8 +173,3 @@ fn goRight(self: *Desktop) void {
self.current += 1;
}
fn getXdgName(name: []const u8) []const u8 {
// TODO
return name;
}