mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-23 05:54:20 +02:00
Added user XDG variables
This commit is contained in:
parent
04d4447273
commit
d12f29015c
1 changed files with 15 additions and 0 deletions
15
src/auth.zig
15
src/auth.zig
|
|
@ -198,6 +198,21 @@ fn initEnv(allocator: std.mem.Allocator, entry: interop.UsernameEntry, path_env:
|
|||
if (entry.home) |home| {
|
||||
try interop.setEnvironmentVariable(allocator, "HOME", home, true);
|
||||
try interop.setEnvironmentVariable(allocator, "PWD", home, true);
|
||||
|
||||
// set XDG env as per https://wiki.archlinux.org/title/XDG_Base_Directory
|
||||
const n = comptime 4;
|
||||
const xdgVars: [n][]const u8 = .{
|
||||
"XDG_CONFIG_HOME",
|
||||
"XDG_CACHE_HOME",
|
||||
"XDG_DATA_HOME",
|
||||
"XDG_STATE_HOME",
|
||||
};
|
||||
const xdgPaths: [n][]const u8 = .{".config", ".cache", ".local/share", ".local/state"};
|
||||
for (0..n) |i| {
|
||||
const value = try std.fmt.allocPrint(allocator, "{s}/{s}", .{ home, xdgPaths[i] });
|
||||
defer allocator.free(value);
|
||||
try interop.setEnvironmentVariable(allocator, xdgVars[i], value, false);
|
||||
}
|
||||
} else return error.NoHomeDirectory;
|
||||
|
||||
try interop.setEnvironmentVariable(allocator, "SHELL", entry.shell.?, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue