~leon_plickat/nfm

nfm: Add config option to show hidden files at launch v2 APPLIED

Hugo Machet: 1
 Add config option to show hidden files at launch

 3 files changed, 14 insertions(+), 0 deletions(-)
#782387 alpine.yml success
#782388 freebsd.yml failed
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~leon_plickat/nfm/patches/33080/mbox | git am -3
Learn more about email & git

[PATCH nfm v2] Add config option to show hidden files at launch Export this patch

In main section:
  show-hidden: [true|false]. Defaults to false.
---
 example/config.ini |  1 +
 src/Config.zig     | 12 ++++++++++++
 src/nfm.zig        |  1 +
 3 files changed, 14 insertions(+)

diff --git a/example/config.ini b/example/config.ini
index faaec19915ac..6d82d9a8c7d2 100644
--- a/example/config.ini
+++ b/example/config.ini
@@ -4,6 +4,7 @@

[main]
opener = xdg-open;
show-hidden = false;

[keybinds]
j = cursor-move-down;
diff --git a/src/Config.zig b/src/Config.zig
index 2969bfc51b1c..ba04a02fe770 100644
--- a/src/Config.zig
+++ b/src/Config.zig
@@ -70,6 +70,7 @@ pub const KeyOperation = struct {
};

opener: ?[]const u8 = null,
show_hidden: bool = false,
keybinds: std.AutoHashMapUnmanaged(spoon.Input, KeyOperation) = .{},
bookmarks: std.AutoHashMapUnmanaged(spoon.Input, []const u8) = .{},
arena: heap.ArenaAllocator = undefined,
@@ -199,9 +200,20 @@ fn parseConfigFile(self: *Self) !?void {
    }
}

/// Boolean options authorized in the config file.
const bool_options = std.ComptimeStringMap(bool, .{
    .{ "true", true },
    .{ "false", false },
});

fn assignMain(self: *Self, variable: []const u8, value: []const u8, path: []const u8, line: usize) !void {
    if (mem.eql(u8, variable, "opener")) {
        self.opener = try context.gpa.dupe(u8, value);
    } else if (mem.eql(u8, variable, "show-hidden")) {
        self.show_hidden = bool_options.get(value) orelse {
            log.err("{s}:{}: Not a boolean: {s}", .{ path, line, value });
            return error.BadConfig;
        };
    } else {
        // TODO maybe try to find the closes approximation and recommend it to the user?
        log.err("{s}:{}: No variable '{s}' in section 'main'", .{ path, line, variable });
diff --git a/src/nfm.zig b/src/nfm.zig
index bcf1abcd7cb5..8c255a515239 100644
--- a/src/nfm.zig
+++ b/src/nfm.zig
@@ -274,6 +274,7 @@ pub fn main() !u8 {
        };
    };
    defer context.config.deinit();
    if (context.config.show_hidden) context.show_hidden = true;

    os.sigaction(os.SIG.TERM, &os.Sigaction{
        .handler = .{ .handler = handleSigTerm },
-- 
2.36.1
nfm/patches: FAILED in 53s

[Add config option to show hidden files at launch][0] v2 from [Hugo Machet][1]

[0]: https://lists.sr.ht/~leon_plickat/nfm/patches/33080
[1]: mailto:mail@hmachet.com

✗ #782388 FAILED  nfm/patches/freebsd.yml https://builds.sr.ht/~leon_plickat/job/782388
✓ #782387 SUCCESS nfm/patches/alpine.yml  https://builds.sr.ht/~leon_plickat/job/782387
Thanks!


Friendly greetings,
Leon Henrik Plickat