mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2025-03-03 03:19:58 +01:00
randomwallpaper uses feh
This commit is contained in:
parent
8b49e0cf88
commit
a5ac3020f9
3 changed files with 10 additions and 62 deletions
8
justfile
8
justfile
|
@ -8,17 +8,13 @@ yaml-language-server
|
|||
"
|
||||
|
||||
install-scripts target=(`echo $HOME` + "/.local/bin"):
|
||||
cd scripts && zig build-exe \
|
||||
-lc -lX11 -lXinerama \
|
||||
randomwallpaper.zig \
|
||||
-femit-bin={{target}}/randomwallpaper
|
||||
|
||||
opam install --yes clap
|
||||
cd scripts/playtwitch && dune build
|
||||
chmod -R +w scripts/playtwitch
|
||||
cp scripts/playtwitch/_build/default/playtwitch.exe {{target}}/playtwitch
|
||||
|
||||
ln -sf \
|
||||
`pwd`/scripts/{start-joshuto,withjava} \
|
||||
`pwd`/scripts/{start-joshuto,withjava,randomwallpaper} \
|
||||
{{target}}
|
||||
|
||||
install-lsps-paru:
|
||||
|
|
8
scripts/randomwallpaper
Executable file
8
scripts/randomwallpaper
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
mons=$(xrandr --listactivemonitors | wc -l)
|
||||
mons=$((mons-1))
|
||||
|
||||
feh --bg-fill $(
|
||||
fd -L '\.(png|jpg)' /usr/share/backgrounds/ ~/.local/share/backgrounds/ \
|
||||
| shuf | head -n 2
|
||||
)
|
|
@ -1,56 +0,0 @@
|
|||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const c = @cImport({
|
||||
@cInclude("X11/Xlib.h");
|
||||
@cInclude("X11/extensions/Xinerama.h");
|
||||
});
|
||||
const Display = c.struct__XDisplay;
|
||||
|
||||
pub fn main() !void {
|
||||
var alloc = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
if (c.XOpenDisplay(null)) |display| {
|
||||
defer _ = c.XCloseDisplay(display);
|
||||
|
||||
var dummy1: c_int = undefined;
|
||||
var dummy2: c_int = undefined;
|
||||
if (c.XineramaQueryExtension(display, &dummy1, &dummy2) != 0 and c.XineramaIsActive(display) != 0) {
|
||||
try updateWallpapers(display, alloc.allocator());
|
||||
} else {
|
||||
return error.@"No Xinerama!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn updateWallpapers(display: *Display, alloc: mem.Allocator) !void {
|
||||
var heads: c_int = 0;
|
||||
const info = c.XineramaQueryScreens(display, &heads);
|
||||
defer _ = c.XFree(info);
|
||||
|
||||
var children = try alloc.alloc(*std.ChildProcess, @intCast(usize, heads));
|
||||
defer alloc.free(children);
|
||||
|
||||
var i: usize = 0;
|
||||
while (i < heads) {
|
||||
const head = info[i];
|
||||
|
||||
std.log.info("Setting wallpaper for screen {} with size {}x{}\n", .{ i, head.width, head.height });
|
||||
|
||||
var buf: [10]u8 = undefined;
|
||||
|
||||
const args = [_][]const u8{ "nitrogen", "--random", "--set-zoom-fill", try std.fmt.bufPrint(&buf, "--head={}", .{i}) };
|
||||
var child = try std.ChildProcess.init(&args, alloc);
|
||||
try child.spawn();
|
||||
|
||||
children[i] = child;
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
for (children) |child| {
|
||||
_ = try child.wait();
|
||||
}
|
||||
|
||||
for (children) |child| {
|
||||
child.deinit();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue