config: allow waylandsessions and xsessions to be set to null (#954)

`waylandsessions` and `xsessions` are currently non-optional string fields, so there is no clean way to disable session type discovery for users who do not use Wayland or X11. Setting them to a nonexistent path works but produces log errors on every startup.

This change makes both fields optional (`?[]const u8`), consistent with other nullable config fields such as `xinitrc`. Setting either to `null` in `config.ini` cleanly skips crawling for that session type with no side effects.

Co-authored-by: Jackson Delahunt <jackson@stemn.com>
Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/954
Reviewed-by: AnErrupTion <anerruption+codeberg@disroot.org>
Co-authored-by: Jackson Delahunt <sabrehagen@noreply.codeberg.org>
Co-committed-by: Jackson Delahunt <sabrehagen@noreply.codeberg.org>
This commit is contained in:
Jackson Delahunt
2026-03-29 08:32:27 +02:00
committed by AnErrupTion
parent 142476041d
commit 10a873acb9
3 changed files with 25 additions and 19 deletions

View File

@@ -363,6 +363,7 @@ vi_mode = false
# Wayland desktop environments # Wayland desktop environments
# You can specify multiple directories, # You can specify multiple directories,
# e.g. $PREFIX_DIRECTORY/share/wayland-sessions:$PREFIX_DIRECTORY/local/share/wayland-sessions # e.g. $PREFIX_DIRECTORY/share/wayland-sessions:$PREFIX_DIRECTORY/local/share/wayland-sessions
# If null, Wayland sessions will not be shown
waylandsessions = $PREFIX_DIRECTORY/share/wayland-sessions waylandsessions = $PREFIX_DIRECTORY/share/wayland-sessions
# Xorg server command # Xorg server command
@@ -384,6 +385,7 @@ xinitrc = ~/.xinitrc
# Xorg desktop environments # Xorg desktop environments
# You can specify multiple directories, # You can specify multiple directories,
# e.g. $PREFIX_DIRECTORY/share/xsessions:$PREFIX_DIRECTORY/local/share/xsessions # e.g. $PREFIX_DIRECTORY/share/xsessions:$PREFIX_DIRECTORY/local/share/xsessions
# If null, X11 sessions will not be shown
xsessions = $PREFIX_DIRECTORY/share/xsessions xsessions = $PREFIX_DIRECTORY/share/xsessions
# Custom Commands and Labels: # Custom Commands and Labels:

View File

@@ -92,9 +92,9 @@ start_cmd: ?[]const u8 = null,
text_in_center: bool = false, text_in_center: bool = false,
vi_default_mode: ViMode = .normal, vi_default_mode: ViMode = .normal,
vi_mode: bool = false, vi_mode: bool = false,
waylandsessions: []const u8 = build_options.prefix_directory ++ "/share/wayland-sessions", waylandsessions: ?[]const u8 = build_options.prefix_directory ++ "/share/wayland-sessions",
x_cmd: []const u8 = build_options.prefix_directory ++ "/bin/X", x_cmd: []const u8 = build_options.prefix_directory ++ "/bin/X",
x_vt: ?u8 = null, x_vt: ?u8 = null,
xauth_cmd: []const u8 = build_options.prefix_directory ++ "/bin/xauth", xauth_cmd: []const u8 = build_options.prefix_directory ++ "/bin/xauth",
xinitrc: ?[]const u8 = "~/.xinitrc", xinitrc: ?[]const u8 = "~/.xinitrc",
xsessions: []const u8 = build_options.prefix_directory ++ "/share/xsessions", xsessions: ?[]const u8 = build_options.prefix_directory ++ "/share/xsessions",

View File

@@ -769,32 +769,36 @@ pub fn main() !void {
var has_crawl_error = false; var has_crawl_error = false;
// Crawl session directories (Wayland, X11 and custom respectively) // Crawl session directories (Wayland, X11 and custom respectively)
var wayland_session_dirs = std.mem.splitScalar(u8, state.config.waylandsessions, ':'); if (state.config.waylandsessions) |waylandsessions| {
while (wayland_session_dirs.next()) |dir| { var wayland_session_dirs = std.mem.splitScalar(u8, waylandsessions, ':');
crawl(&state.session, state.lang, dir, .wayland) catch |err| { while (wayland_session_dirs.next()) |dir| {
has_crawl_error = true; crawl(&state.session, state.lang, dir, .wayland) catch |err| {
try state.log_file.err(
"sys",
"failed to crawl wayland session directory '{s}': {s}",
.{ dir, @errorName(err) },
);
};
}
if (build_options.enable_x11_support) {
var x_session_dirs = std.mem.splitScalar(u8, state.config.xsessions, ':');
while (x_session_dirs.next()) |dir| {
crawl(&state.session, state.lang, dir, .x11) catch |err| {
has_crawl_error = true; has_crawl_error = true;
try state.log_file.err( try state.log_file.err(
"sys", "sys",
"failed to crawl x11 session directory '{s}': {s}", "failed to crawl wayland session directory '{s}': {s}",
.{ dir, @errorName(err) }, .{ dir, @errorName(err) },
); );
}; };
} }
} }
if (build_options.enable_x11_support) {
if (state.config.xsessions) |xsessions| {
var x_session_dirs = std.mem.splitScalar(u8, xsessions, ':');
while (x_session_dirs.next()) |dir| {
crawl(&state.session, state.lang, dir, .x11) catch |err| {
has_crawl_error = true;
try state.log_file.err(
"sys",
"failed to crawl x11 session directory '{s}': {s}",
.{ dir, @errorName(err) },
);
};
}
}
}
var custom_session_dirs = std.mem.splitScalar(u8, state.config.custom_sessions, ':'); var custom_session_dirs = std.mem.splitScalar(u8, state.config.custom_sessions, ':');
while (custom_session_dirs.next()) |dir| { while (custom_session_dirs.next()) |dir| {
crawl(&state.session, state.lang, dir, .custom) catch |err| { crawl(&state.session, state.lang, dir, .custom) catch |err| {