mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-14 09:33:52 +01:00
mzteriver: better border colors and reinit support
This commit is contained in:
parent
5ba7cc86f6
commit
336fe9d864
3 changed files with 53 additions and 28 deletions
|
@ -7,15 +7,26 @@ pub fn build(b: *std.Build) !void {
|
|||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const cg_opt = try common.confgenGet(struct { nvidia: bool = false, term: struct { command: [:0]const u8 }, commands: struct {
|
||||
file_manager: [:0]const u8,
|
||||
browser: [:0]const u8,
|
||||
}, cursor: struct {
|
||||
theme: [:0]const u8,
|
||||
size: u32,
|
||||
} }, "../..", b.allocator);
|
||||
const cg_opt = try common.confgenGet(struct {
|
||||
catppuccin: struct {
|
||||
red: [:0]const u8,
|
||||
sky: [:0]const u8,
|
||||
},
|
||||
nvidia: bool = false,
|
||||
term: struct { command: [:0]const u8 },
|
||||
commands: struct {
|
||||
file_manager: [:0]const u8,
|
||||
browser: [:0]const u8,
|
||||
},
|
||||
cursor: struct {
|
||||
theme: [:0]const u8,
|
||||
size: u32,
|
||||
},
|
||||
}, "../..", b.allocator);
|
||||
|
||||
const opts = b.addOptions();
|
||||
opts.addOption([:0]const u8, "catppuccin_red", cg_opt.catppuccin.red);
|
||||
opts.addOption([:0]const u8, "catppuccin_sky", cg_opt.catppuccin.sky);
|
||||
opts.addOption(bool, "nvidia", cg_opt.nvidia);
|
||||
opts.addOption([:0]const u8, "term_command", cg_opt.term.command);
|
||||
opts.addOption([:0]const u8, "file_manager_command", cg_opt.commands.file_manager);
|
||||
|
|
|
@ -5,7 +5,7 @@ const log = std.log.scoped(.mzteriver);
|
|||
|
||||
const Connection = @import("Connection.zig");
|
||||
|
||||
pub fn init(alloc: std.mem.Allocator) !void {
|
||||
pub fn init(alloc: std.mem.Allocator, initial: bool) !void {
|
||||
const con = try Connection.init();
|
||||
defer con.deinit();
|
||||
|
||||
|
@ -145,8 +145,8 @@ pub fn init(alloc: std.mem.Allocator) !void {
|
|||
|
||||
try con.runCommand(&.{ "set-repeat", "50", "300" });
|
||||
|
||||
try con.runCommand(&.{ "border-color-focused", "0x880000" });
|
||||
try con.runCommand(&.{ "border-color-unfocused", "0x660000" });
|
||||
try con.runCommand(&.{ "border-color-focused", "0x" ++ opts.catppuccin_red });
|
||||
try con.runCommand(&.{ "border-color-unfocused", "0x" ++ opts.catppuccin_sky });
|
||||
|
||||
try con.runCommand(&.{ "hide-cursor", "when-typing", "enabled" });
|
||||
|
||||
|
@ -170,7 +170,10 @@ pub fn init(alloc: std.mem.Allocator) !void {
|
|||
);
|
||||
defer alloc.free(init_path);
|
||||
|
||||
var init_child = std.process.Child.init(&.{init_path}, alloc);
|
||||
var init_child = std.process.Child.init(
|
||||
&.{ init_path, if (initial) "init" else "reinit" },
|
||||
alloc,
|
||||
);
|
||||
const term = init_child.spawnAndWait() catch |e| switch (e) {
|
||||
error.FileNotFound => b: {
|
||||
log.info("no river_init", .{});
|
||||
|
@ -184,7 +187,7 @@ pub fn init(alloc: std.mem.Allocator) !void {
|
|||
return error.InitBorked;
|
||||
}
|
||||
|
||||
log.info("configuration finished, spawning processes", .{});
|
||||
log.info("configuration finished, initial: {}", .{initial});
|
||||
|
||||
// tell confgenfs we're now using river
|
||||
confgenfs: {
|
||||
|
@ -205,21 +208,25 @@ pub fn init(alloc: std.mem.Allocator) !void {
|
|||
);
|
||||
}
|
||||
|
||||
var child_arena = std.heap.ArenaAllocator.init(alloc);
|
||||
defer child_arena.deinit();
|
||||
if (initial) {
|
||||
std.log.info("spawning processes", .{});
|
||||
|
||||
// spawn background processes
|
||||
inline for (.{
|
||||
.{"wlbg"},
|
||||
.{"waybar"},
|
||||
.{ "dbus-update-activation-environment", "DISPLAY", "XAUTHORITY", "WAYLAND_DISPLAY", "XDG_CURRENT_DESKTOP" },
|
||||
.{ "systemctl", "--user", "import-environment", "DISPLAY", "XAUTHORITY", "WAYLAND_DISPLAY", "XDG_CURRENT_DESKTOP" },
|
||||
.{ "rivertile", "-view-padding", "6", "-outer-padding", "6" },
|
||||
}) |argv| {
|
||||
// TODO: wonk
|
||||
// We use an arena here to prevent leaks because process.Child apparently doesn't support
|
||||
// detaching.
|
||||
var child = std.process.Child.init(&argv, child_arena.allocator());
|
||||
try child.spawn();
|
||||
var child_arena = std.heap.ArenaAllocator.init(alloc);
|
||||
defer child_arena.deinit();
|
||||
|
||||
// spawn background processes
|
||||
inline for (.{
|
||||
.{"wlbg"},
|
||||
.{"waybar"},
|
||||
.{ "dbus-update-activation-environment", "DISPLAY", "XAUTHORITY", "WAYLAND_DISPLAY", "XDG_CURRENT_DESKTOP" },
|
||||
.{ "systemctl", "--user", "import-environment", "DISPLAY", "XAUTHORITY", "WAYLAND_DISPLAY", "XDG_CURRENT_DESKTOP" },
|
||||
.{ "rivertile", "-view-padding", "6", "-outer-padding", "6" },
|
||||
}) |argv| {
|
||||
// TODO: wonk
|
||||
// We use an arena here to prevent leaks because process.Child apparently doesn't support
|
||||
// detaching.
|
||||
var child = std.process.Child.init(&argv, child_arena.allocator());
|
||||
try child.spawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ const opts = @import("opts");
|
|||
|
||||
const log = std.log.scoped(.mzteriver);
|
||||
|
||||
const init = @import("init.zig").init;
|
||||
|
||||
pub const std_options = std.Options{
|
||||
.log_level = switch (@import("builtin").mode) {
|
||||
.Debug => .debug,
|
||||
|
@ -21,7 +23,12 @@ pub fn main() !void {
|
|||
(std.os.argv.len >= 2 and std.mem.orderZ(u8, std.os.argv[1], "init") == .eq))
|
||||
{
|
||||
log.info("running in init mode", .{});
|
||||
try @import("init.zig").init(alloc);
|
||||
try init(alloc, true);
|
||||
} else if (std.mem.endsWith(u8, std.mem.span(std.os.argv[0]), "reinit") or
|
||||
(std.os.argv.len >= 2 and std.mem.orderZ(u8, std.os.argv[1], "reinit") == .eq))
|
||||
{
|
||||
log.info("running in reinit mode", .{});
|
||||
try init(alloc, false);
|
||||
} else {
|
||||
log.info("running in launch mode", .{});
|
||||
|
||||
|
|
Loading…
Reference in a new issue