mzteinit env handles GUI-related vars

This commit is contained in:
LordMZTE 2023-06-03 16:33:47 +02:00
parent dc2c20364e
commit 5c3a01289c
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
2 changed files with 42 additions and 1 deletions

View file

@ -3,7 +3,7 @@ const sysdaemon = @import("sysdaemon.zig");
const log = std.log.scoped(.env);
const delimitedWriter = @import("delimeted_writer.zig").delimitedWriter;
const delimitedWriter = @import("delimited_writer.zig").delimitedWriter;
/// Initialize the environment.
/// Returns true if the environment should be transferred to the system daemon.
@ -66,6 +66,47 @@ pub fn populateEnvironment(env: *std.process.EnvMap) !bool {
try env.put("_JAVA_OPTIONS", bufstream.getWritten());
}
// GUI options
{
try env.put("QT_QPA_PLATFORMTHEME", "gtk2");
try env.put("GTK_THEME", "Dracula");
// icon path
icons: {
const path = "/usr/share/icons/Dracula/scalable";
var dir = std.fs.openIterableDirAbsolute(path, .{}) catch {
log.warn(
"Couldn't open dracula icons directory @ `{s}`, not setting ICONPATH",
.{path},
);
break :icons;
};
defer dir.close();
var bufstream = std.io.fixedBufferStream(&buf);
var b = delimitedWriter(bufstream.writer(), ':');
var iter = dir.iterate();
while (try iter.next()) |entry| {
if (entry.kind != .directory)
continue;
const dpath = try std.fs.path.join(alloc, &.{ path, entry.name });
defer alloc.free(dpath);
try b.push(dpath);
}
try env.put("ICONPATH", bufstream.getWritten());
}
}
// Rofi path
try env.put(
"ROFI_PLUGIN_PATH",
try std.fmt.bufPrint(&sbuf, "/usr/lib/rofi:{s}/.local/lib/rofi", .{home}),
);
// PATH
{
var bufstream = std.io.fixedBufferStream(&buf);