Merge branch 'master' of codeberg.org:fairyglade/ly

This commit is contained in:
AnErrupTion 2025-08-05 08:26:38 +02:00
commit 7353e75d78
No known key found for this signature in database
3 changed files with 12 additions and 6 deletions

View File

@ -253,7 +253,8 @@ service_name = ly
# This will contain stdout and stderr of Wayland sessions # This will contain stdout and stderr of Wayland sessions
# By default it's saved in the user's home directory # By default it's saved in the user's home directory
# Important: due to technical limitations, X11 and shell sessions aren't supported, which # Important: due to technical limitations, X11 and shell sessions aren't supported, which
# means you won't get any logs from those sessions # means you won't get any logs from those sessions.
# If null, no session log will be created
session_log = ly-session.log session_log = ly-session.log
# Setup command # Setup command

View File

@ -15,7 +15,7 @@ pub const AuthOptions = struct {
tty: u8, tty: u8,
service_name: [:0]const u8, service_name: [:0]const u8,
path: ?[:0]const u8, path: ?[:0]const u8,
session_log: []const u8, session_log: ?[]const u8,
xauth_cmd: []const u8, xauth_cmd: []const u8,
setup_cmd: []const u8, setup_cmd: []const u8,
login_cmd: ?[]const u8, login_cmd: ?[]const u8,
@ -399,8 +399,11 @@ fn executeShellCmd(shell: [*:0]const u8, options: AuthOptions) !void {
} }
fn executeWaylandCmd(shell: [*:0]const u8, options: AuthOptions, desktop_cmd: []const u8) !void { fn executeWaylandCmd(shell: [*:0]const u8, options: AuthOptions, desktop_cmd: []const u8) !void {
const log_file = try redirectStandardStreams(options.session_log, true); var maybe_log_file: ?std.fs.File = null;
defer log_file.close(); if (options.session_log) |log_path| {
maybe_log_file = try redirectStandardStreams(log_path, true);
}
defer if (maybe_log_file) |log_file| log_file.close();
var cmd_buffer: [1024]u8 = undefined; var cmd_buffer: [1024]u8 = undefined;
const cmd_str = try std.fmt.bufPrintZ(&cmd_buffer, "{s} {s} {s}", .{ options.setup_cmd, options.login_cmd orelse "", desktop_cmd }); const cmd_str = try std.fmt.bufPrintZ(&cmd_buffer, "{s} {s} {s}", .{ options.setup_cmd, options.login_cmd orelse "", desktop_cmd });
@ -470,7 +473,9 @@ fn executeCustomCmd(shell: [*:0]const u8, options: AuthOptions, is_terminal: boo
// For custom desktop entries, the "Terminal" value here determines if // For custom desktop entries, the "Terminal" value here determines if
// we redirect standard output & error or not. That is, we redirect only // we redirect standard output & error or not. That is, we redirect only
// if it's equal to false (so if it's not running in a TTY). // if it's equal to false (so if it's not running in a TTY).
maybe_log_file = try redirectStandardStreams(options.session_log, true); if (options.session_log) |log_path| {
maybe_log_file = try redirectStandardStreams(log_path, true);
}
} }
defer if (maybe_log_file) |log_file| log_file.close(); defer if (maybe_log_file) |log_file| log_file.close();

View File

@ -66,7 +66,7 @@ restart_cmd: []const u8 = "/sbin/shutdown -r now",
restart_key: []const u8 = "F2", restart_key: []const u8 = "F2",
save: bool = true, save: bool = true,
service_name: [:0]const u8 = "ly", service_name: [:0]const u8 = "ly",
session_log: []const u8 = "ly-session.log", session_log: ?[]const u8 = "ly-session.log",
setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh", setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh",
shutdown_cmd: []const u8 = "/sbin/shutdown -a now", shutdown_cmd: []const u8 = "/sbin/shutdown -a now",
shutdown_key: []const u8 = "F1", shutdown_key: []const u8 = "F1",