From 52ad6f2435f3a2ca459a2eaec4fc0f367a6014d3 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Sat, 6 Aug 2022 11:14:39 +0200 Subject: [PATCH] dont use .fehbg --- .config/i3/config | 2 +- scripts/randomwallpaper/src/main.zig | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.config/i3/config b/.config/i3/config index 5549797..6f49868 100755 --- a/.config/i3/config +++ b/.config/i3/config @@ -210,7 +210,7 @@ bindsym $mod+u gaps inner current plus 5 bindsym $mod+Shift+u gaps inner current minus 5 # background -exec --no-startup-id ~/.fehbg +exec --no-startup-id randomwallpaper # compositor exec picom -f -i 1 -c diff --git a/scripts/randomwallpaper/src/main.zig b/scripts/randomwallpaper/src/main.zig index fa17fa2..1d33f27 100644 --- a/scripts/randomwallpaper/src/main.zig +++ b/scripts/randomwallpaper/src/main.zig @@ -20,20 +20,28 @@ pub fn main() !u8 { try walkLocalWps(&walker, home_s); - var feh_argv = try alloc.alloc([]const u8, @intCast(usize, 2 + screens)); - defer alloc.free(feh_argv); + const feh_baseargs = [_][]const u8{ + "feh", + "--no-fehbg", + "--bg-fill", + }; - feh_argv[0] = "feh"; - feh_argv[1] = "--bg-fill"; + var feh_argv = try alloc.alloc( + []const u8, + feh_baseargs.len + @intCast(usize, screens), + ); + defer alloc.free(feh_argv); + std.mem.copy([]const u8, feh_argv, &feh_baseargs); const rand = std.rand.DefaultPrng.init(std.crypto.random.int(u64)).random(); var i: u31 = 0; while (i < screens) : (i += 1) { const idx = rand.uintAtMost(usize, walker.files.items.len - 1); - feh_argv[2 + i] = walker.files.items[idx]; + feh_argv[feh_baseargs.len + i] = walker.files.items[idx]; } + std.log.info("feh argv: {s}", .{feh_argv}); const term = try std.ChildProcess.init(feh_argv, alloc).spawnAndWait(); const exit = switch (term) {