From 5cdd6af7386e9d8cb60e854d17cc79c1ac55d3f4 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Wed, 3 Jul 2024 09:52:00 +0200 Subject: [PATCH 01/25] Start Ly v1.0.1 development cycle Signed-off-by: AnErrupTion --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 65c06a2..1d747f1 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,6 @@ const std = @import("std"); -const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 0 }; +const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 1 }; var dest_directory: []const u8 = undefined; var data_directory: []const u8 = undefined; var exe_name: []const u8 = undefined; From 53d252232f465e7b8cb099ae2678ea195c299827 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Wed, 3 Jul 2024 09:52:24 +0200 Subject: [PATCH 02/25] Backport: Fix dest_directory embedded in binary Signed-off-by: AnErrupTion --- build.zig | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/build.zig b/build.zig index 1d747f1..adcbfcc 100644 --- a/build.zig +++ b/build.zig @@ -6,13 +6,15 @@ var data_directory: []const u8 = undefined; var exe_name: []const u8 = undefined; pub fn build(b: *std.Build) !void { - dest_directory = b.option([]const u8, "dest_directory", "Specify a dest directory for installation") orelse ""; - data_directory = b.option([]const u8, "data_directory", "Specify a default data directory (default is /etc/ly)") orelse "/etc/ly"; - data_directory = try std.fs.path.join(b.allocator, &[_][]const u8{ dest_directory, data_directory }); + dest_directory = b.option([]const u8, "dest_directory", "Specify a destination directory for installation") orelse ""; + data_directory = b.option([]const u8, "data_directory", "Specify a default data directory (default is /etc/ly). This path gets embedded into the binary") orelse "/etc/ly"; exe_name = b.option([]const u8, "name", "Specify installed executable file name (default is ly)") orelse "ly"; + const bin_directory = try b.allocator.dupe(u8, data_directory); + data_directory = try std.fs.path.join(b.allocator, &[_][]const u8{ dest_directory, data_directory }); + const build_options = b.addOptions(); - build_options.addOption([]const u8, "data_directory", data_directory); + build_options.addOption([]const u8, "data_directory", bin_directory); const version_str = try getVersionStr(b, "ly", ly_version); @@ -113,7 +115,7 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type { .Openrc => { const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/init.d" }); std.fs.cwd().makePath(service_path) catch {}; - var service_dir = std.fs.openDirAbsolute(service_path, .{}) catch unreachable; + var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable; defer service_dir.close(); try std.fs.cwd().copyFile("res/ly-openrc", service_dir, exe_name, .{ .override_mode = 755 }); @@ -121,7 +123,7 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type { .Runit => { const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/sv/ly" }); std.fs.cwd().makePath(service_path) catch {}; - var service_dir = std.fs.openDirAbsolute(service_path, .{}) catch unreachable; + var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable; defer service_dir.close(); try std.fs.cwd().copyFile("res/ly-runit-service/conf", service_dir, "conf", .{}); @@ -131,7 +133,7 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type { .Systemd => { const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/usr/lib/systemd/system" }); std.fs.cwd().makePath(service_path) catch {}; - var service_dir = std.fs.openDirAbsolute(service_path, .{}) catch unreachable; + var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable; defer service_dir.close(); try std.fs.cwd().copyFile("res/ly.service", service_dir, "ly.service", .{ .override_mode = 644 }); @@ -161,14 +163,14 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void { }; } - var executable_dir = std.fs.openDirAbsolute(exe_path, .{}) catch unreachable; + var executable_dir = std.fs.cwd().openDir(exe_path, .{}) catch unreachable; defer executable_dir.close(); try current_dir.copyFile("zig-out/bin/ly", executable_dir, exe_name, .{}); } { - var config_dir = std.fs.openDirAbsolute(data_directory, .{}) catch unreachable; + var config_dir = std.fs.cwd().openDir(data_directory, .{}) catch unreachable; defer config_dir.close(); if (install_config) { @@ -179,7 +181,7 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void { } { - var lang_dir = std.fs.openDirAbsolute(lang_path, .{}) catch unreachable; + var lang_dir = std.fs.cwd().openDir(lang_path, .{}) catch unreachable; defer lang_dir.close(); try current_dir.copyFile("res/lang/cat.ini", lang_dir, "cat.ini", .{}); @@ -208,7 +210,7 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void { }; } - var pam_dir = std.fs.openDirAbsolute(pam_path, .{}) catch unreachable; + var pam_dir = std.fs.cwd().openDir(pam_path, .{}) catch unreachable; defer pam_dir.close(); try current_dir.copyFile("res/pam.d/ly", pam_dir, "ly", .{ .override_mode = 644 }); @@ -217,27 +219,27 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void { pub fn uninstallall(step: *std.Build.Step, progress: *std.Progress.Node) !void { _ = progress; - try std.fs.deleteTreeAbsolute(data_directory); + try std.fs.cwd().deleteTree(data_directory); const allocator = step.owner.allocator; const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/usr/bin/", exe_name }); - try std.fs.deleteFileAbsolute(exe_path); + try std.fs.cwd().deleteFile(exe_path); const pam_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/pam.d/ly" }); - try std.fs.deleteFileAbsolute(pam_path); + try std.fs.cwd().deleteFile(pam_path); const systemd_service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/usr/lib/systemd/system/ly.service" }); - std.fs.deleteFileAbsolute(systemd_service_path) catch { + std.fs.cwd().deleteFile(systemd_service_path) catch { std.debug.print("warn: systemd service not found.\n", .{}); }; const openrc_service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/init.d/ly" }); - std.fs.deleteFileAbsolute(openrc_service_path) catch { + std.fs.cwd().deleteFile(openrc_service_path) catch { std.debug.print("warn: openrc service not found.\n", .{}); }; const runit_service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/sv/ly" }); - std.fs.deleteTreeAbsolute(runit_service_path) catch { + std.fs.cwd().deleteTree(runit_service_path) catch { std.debug.print("warn: runit service not found.\n", .{}); }; } From 6b7e7be387de486a7f5a314a35d3f798c18355bd Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 26 Jul 2024 19:32:30 +0200 Subject: [PATCH 03/25] Backport: Use octal prefix for file modes in build.zig Signed-off-by: AnErrupTion --- build.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index adcbfcc..6cbe1a4 100644 --- a/build.zig +++ b/build.zig @@ -118,7 +118,7 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type { var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable; defer service_dir.close(); - try std.fs.cwd().copyFile("res/ly-openrc", service_dir, exe_name, .{ .override_mode = 755 }); + try std.fs.cwd().copyFile("res/ly-openrc", service_dir, exe_name, .{ .override_mode = 0o755 }); }, .Runit => { const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/sv/ly" }); @@ -136,7 +136,7 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type { var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable; defer service_dir.close(); - try std.fs.cwd().copyFile("res/ly.service", service_dir, "ly.service", .{ .override_mode = 644 }); + try std.fs.cwd().copyFile("res/ly.service", service_dir, "ly.service", .{ .override_mode = 0o644 }); }, } } @@ -213,7 +213,7 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void { var pam_dir = std.fs.cwd().openDir(pam_path, .{}) catch unreachable; defer pam_dir.close(); - try current_dir.copyFile("res/pam.d/ly", pam_dir, "ly", .{ .override_mode = 644 }); + try current_dir.copyFile("res/pam.d/ly", pam_dir, "ly", .{ .override_mode = 0o644 }); } } From 8e534c7bcd1b9130eb26a4c86edcd746a91d0c21 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 26 Jul 2024 19:34:12 +0200 Subject: [PATCH 04/25] Backport: Fix incorrect shebang in xsetup.sh Signed-off-by: AnErrupTion --- res/xsetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/xsetup.sh b/res/xsetup.sh index 487a078..9418530 100755 --- a/res/xsetup.sh +++ b/res/xsetup.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # Xsession - run as user # Copyright (C) 2016 Pier Luigi Fiorini From 391104cf342c0820e28d92baf1f2ed097b53379c Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 26 Jul 2024 19:34:46 +0200 Subject: [PATCH 05/25] Backport: Fix documentation issue about DOOM animation Signed-off-by: AnErrupTion --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 1402122..b323c0d 100644 --- a/readme.md +++ b/readme.md @@ -132,7 +132,7 @@ then you have to disable getty, so it doesn't respawn on top of ly # ln -s /etc/sv/ly /var/service/ ``` -By default, ly will run on tty2. To change the tty it must be set in `/etc/ly/config.ini` +By default, ly will run on tty2. To change the tty it must be set in `/etc/ly/config.ini` You should as well disable your existing display manager service if needed, e.g.: @@ -196,7 +196,7 @@ Take a look at your .xsession if X doesn't start, as it can interfere ## PSX DOOM fire animation To enable the famous PSX DOOM fire described by [Fabien Sanglard](http://fabiensanglard.net/doom_fire_psx/index.html), -just uncomment `animate = true` in `/etc/ly/config.ini`. You may also +just set `animation = doom` in `/etc/ly/config.ini`. You may also disable the main box borders with `hide_borders = true`. ## Additional Information From a042749a72bc0765b18e16bc7b6195251cc085b3 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 26 Jul 2024 21:59:21 +0200 Subject: [PATCH 06/25] Backport: Make runit run and finish scripts executable Signed-off-by: AnErrupTion --- build.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 6cbe1a4..8535cfb 100644 --- a/build.zig +++ b/build.zig @@ -127,8 +127,8 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type { defer service_dir.close(); try std.fs.cwd().copyFile("res/ly-runit-service/conf", service_dir, "conf", .{}); - try std.fs.cwd().copyFile("res/ly-runit-service/finish", service_dir, "finish", .{}); - try std.fs.cwd().copyFile("res/ly-runit-service/run", service_dir, "run", .{}); + try std.fs.cwd().copyFile("res/ly-runit-service/finish", service_dir, "finish", .{ .override_mode = 0o755 }); + try std.fs.cwd().copyFile("res/ly-runit-service/run", service_dir, "run", .{ .override_mode = 0o755 }); }, .Systemd => { const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/usr/lib/systemd/system" }); From d87344330a2234366ff7f420a981dee76521e7a2 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sat, 27 Jul 2024 14:18:09 +0200 Subject: [PATCH 07/25] Start Ly v1.0.2 development cycle Signed-off-by: AnErrupTion --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 8535cfb..4452475 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,6 @@ const std = @import("std"); -const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 1 }; +const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 2 }; var dest_directory: []const u8 = undefined; var data_directory: []const u8 = undefined; var exe_name: []const u8 = undefined; From a807e8e11c3d3364767ea4b1a3611be57cfaa6de Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sat, 27 Jul 2024 14:25:30 +0200 Subject: [PATCH 08/25] Backport: Use default PRNG and retrieve better seed Signed-off-by: AnErrupTion --- src/main.zig | 9 ++++++++- src/tui/TerminalBuffer.zig | 8 +++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.zig b/src/main.zig index 6171361..29a4a8c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -161,7 +161,14 @@ pub fn main() !void { // Initialize terminal buffer const labels_max_length = @max(lang.login.len, lang.password.len); - var buffer = TerminalBuffer.init(config, labels_max_length); + // Get a random seed for the PRNG (used by animations) + var seed: u64 = undefined; + try std.posix.getrandom(std.mem.asBytes(&seed)); + + var prng = std.Random.DefaultPrng.init(seed); + const random = prng.random(); + + var buffer = TerminalBuffer.init(config, labels_max_length, random); // Initialize components var desktop = try Desktop.init(allocator, &buffer, config.max_desktop_len, lang); diff --git a/src/tui/TerminalBuffer.zig b/src/tui/TerminalBuffer.zig index eec1a85..9692365 100644 --- a/src/tui/TerminalBuffer.zig +++ b/src/tui/TerminalBuffer.zig @@ -4,7 +4,7 @@ const interop = @import("../interop.zig"); const utils = @import("utils.zig"); const Config = @import("../config/Config.zig"); -const Random = std.rand.Random; +const Random = std.Random; const termbox = interop.termbox; @@ -35,11 +35,9 @@ box_height: u64, margin_box_v: u8, margin_box_h: u8, -pub fn init(config: Config, labels_max_length: u64) TerminalBuffer { - var prng = std.rand.Isaac64.init(@intCast(std.time.timestamp())); - +pub fn init(config: Config, labels_max_length: u64, random: Random) TerminalBuffer { return .{ - .random = prng.random(), + .random = random, .width = @intCast(termbox.tb_width()), .height = @intCast(termbox.tb_height()), .buffer = termbox.tb_cell_buffer(), From 10cd9615ef768a8caa6ed4462b3a2d72a31c77f7 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sat, 27 Jul 2024 21:07:41 +0200 Subject: [PATCH 09/25] Backport: Fix possible overflow with TTY ID Co-authored-by: Kevin Morris Signed-off-by: AnErrupTion --- src/auth.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth.zig b/src/auth.zig index dbbdfda..2da71ab 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -21,7 +21,7 @@ pub fn sessionSignalHandler(i: c_int) callconv(.C) void { } pub fn authenticate(config: Config, current_environment: Desktop.Environment, login: [:0]const u8, password: [:0]const u8) !void { - var tty_buffer: [2]u8 = undefined; + var tty_buffer: [3]u8 = undefined; const tty_str = try std.fmt.bufPrintZ(&tty_buffer, "{d}", .{config.tty}); // Set the XDG environment variables From 7ece95965b3c2ac961c306670c28066302055867 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sat, 27 Jul 2024 22:44:35 +0200 Subject: [PATCH 10/25] Backport: Fix ~/.profile not being loaded with Fish Signed-off-by: AnErrupTion --- res/wsetup.sh | 1 + res/xsetup.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/res/wsetup.sh b/res/wsetup.sh index 68041a3..fd3a583 100755 --- a/res/wsetup.sh +++ b/res/wsetup.sh @@ -40,6 +40,7 @@ case $SHELL in ;; */fish) [ -f /etc/profile ] && . /etc/profile + [ -f $HOME/.profile ] && . $HOME/.profile xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX` $SHELL --login -c "/bin/sh -c 'export -p' > $xsess_tmp" . $xsess_tmp diff --git a/res/xsetup.sh b/res/xsetup.sh index 9418530..2c962f5 100755 --- a/res/xsetup.sh +++ b/res/xsetup.sh @@ -40,6 +40,7 @@ case $SHELL in ;; */fish) [ -f /etc/profile ] && . /etc/profile + [ -f $HOME/.profile ] && . $HOME/.profile xsess_tmp=`mktemp /tmp/xsess-env-XXXXXX` $SHELL --login -c "/bin/sh -c 'export -p' > $xsess_tmp" . $xsess_tmp From 802ad6bbed84859e2cfab25191dc3f89d3420f9f Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sat, 27 Jul 2024 22:45:20 +0200 Subject: [PATCH 11/25] Backport: Set PAM_TTY Signed-off-by: AnErrupTion --- src/auth.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/auth.zig b/src/auth.zig index 2da71ab..b55c9d2 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -24,6 +24,9 @@ pub fn authenticate(config: Config, current_environment: Desktop.Environment, lo var tty_buffer: [3]u8 = undefined; const tty_str = try std.fmt.bufPrintZ(&tty_buffer, "{d}", .{config.tty}); + var pam_tty_buffer: [6]u8 = undefined; + const pam_tty_str = try std.fmt.bufPrintZ(&pam_tty_buffer, "tty{d}", .{config.tty}); + // Set the XDG environment variables setXdgSessionEnv(current_environment.display_server); try setXdgEnv(tty_str, current_environment.xdg_session_desktop, current_environment.xdg_desktop_names orelse ""); @@ -41,6 +44,10 @@ pub fn authenticate(config: Config, current_environment: Desktop.Environment, lo if (status != interop.pam.PAM_SUCCESS) return pamDiagnose(status); defer _ = interop.pam.pam_end(handle, status); + // Set PAM_TTY as the current TTY. This is required in case it isn't being set by another PAM module + status = interop.pam.pam_set_item(handle, interop.pam.PAM_TTY, pam_tty_str.ptr); + if (status != interop.pam.PAM_SUCCESS) return pamDiagnose(status); + // Do the PAM routine status = interop.pam.pam_authenticate(handle, 0); if (status != interop.pam.PAM_SUCCESS) return pamDiagnose(status); From 5796720a9ce7a1ab996eadf746af94df16cd78b6 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Sun, 28 Jul 2024 11:35:23 +0200 Subject: [PATCH 12/25] Backport: Add missing supervise symlink on runit Signed-off-by: AnErrupTion --- build.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.zig b/build.zig index 4452475..083bd2a 100644 --- a/build.zig +++ b/build.zig @@ -126,9 +126,12 @@ pub fn ServiceInstaller(comptime init_system: InitSystem) type { var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable; defer service_dir.close(); + const supervise_path = try std.fs.path.join(allocator, &[_][]const u8{ service_path, "supervise" }); + try std.fs.cwd().copyFile("res/ly-runit-service/conf", service_dir, "conf", .{}); try std.fs.cwd().copyFile("res/ly-runit-service/finish", service_dir, "finish", .{ .override_mode = 0o755 }); try std.fs.cwd().copyFile("res/ly-runit-service/run", service_dir, "run", .{ .override_mode = 0o755 }); + try std.fs.cwd().symLink("/run/runit/supervise.ly", supervise_path, .{}); }, .Systemd => { const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/usr/lib/systemd/system" }); From 67fd024f6a52dde0ce4092dcb8453ccb2cbeaca5 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 29 Jul 2024 13:35:04 +0200 Subject: [PATCH 13/25] Revert "Redirect stderr to systemd journal in service (#621)" This reverts commit 3d8d8d67df7c8db9becc918e65113fd1b6394be5. Signed-off-by: AnErrupTion --- res/ly.service | 1 - 1 file changed, 1 deletion(-) diff --git a/res/ly.service b/res/ly.service index 09c1559..2fd120a 100644 --- a/res/ly.service +++ b/res/ly.service @@ -7,7 +7,6 @@ Conflicts=getty@tty2.service [Service] Type=idle ExecStart=/usr/bin/ly -StandardError=journal StandardInput=tty TTYPath=/dev/tty2 TTYReset=yes From 9374d2df32d9d964da43cd02bc41dcc3097e6a46 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 29 Jul 2024 14:19:47 +0200 Subject: [PATCH 14/25] Backport: Fix clock & bigclock not updating without input Signed-off-by: AnErrupTion --- src/main.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.zig b/src/main.zig index 29a4a8c..1a692de 100644 --- a/src/main.zig +++ b/src/main.zig @@ -433,8 +433,6 @@ pub fn main() !void { desktop.draw(); login.draw(); password.drawMasked(config.asterisk); - - update = animate; } else { std.time.sleep(std.time.ns_per_ms * 10); update = buffer.cascade(); @@ -467,6 +465,8 @@ pub fn main() !void { const event_error = if (timeout == -1) termbox.tb_poll_event(&event) else termbox.tb_peek_event(&event, timeout); + update = timeout != -1; + if (event_error < 0 or event.type != termbox.TB_EVENT_KEY) continue; switch (event.key) { From 75cc971f9c7596349d79b6cd138afda30269c19a Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Tue, 30 Jul 2024 09:51:42 +0200 Subject: [PATCH 15/25] Backport: Update zigini (fixes incorrect comment parsing) Signed-off-by: AnErrupTion --- build.zig.zon | 4 ++-- src/config/migrator.zig | 12 ++++++++++++ src/main.zig | 19 ++++++++++--------- src/tui/components/Desktop.zig | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 85900c9..ba6345e 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -8,8 +8,8 @@ .hash = "122014e73fd712190e109950837b97f6143f02d7e2b6986e1db70b6f4aadb5ba6a0d", }, .zigini = .{ - .url = "https://github.com/Kawaii-Ash/zigini/archive/ce1f322482099db058f5d9fdd05fbfa255d79723.tar.gz", - .hash = "1220e7a99793a0430e0a7c0b938cb3c98321035bc297e21cd0e2413cf740b4923b9f", + .url = "https://github.com/Kawaii-Ash/zigini/archive/bdb6fd15c6dcedb0c6c2a46381f2d298e2f05fff.tar.gz", + .hash = "12203feb831e21bec081af6aae70dd19b127f1627aa55f3415bd1fa476c174a511cc", }, }, .paths = .{""}, diff --git a/src/config/migrator.zig b/src/config/migrator.zig index 0ae6001..377ee1a 100644 --- a/src/config/migrator.zig +++ b/src/config/migrator.zig @@ -1,7 +1,19 @@ +// The migrator ensures compatibility with <=0.6.0 configuration files + const std = @import("std"); const ini = @import("zigini"); const Save = @import("Save.zig"); +pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniField { + var mapped_field = field; + + if (std.mem.eql(u8, field.key, "blank_password")) { + mapped_field.key = "clear_password"; + } + + return mapped_field; +} + pub fn tryMigrateSaveFile(user_buf: *[32]u8, path: []const u8) Save { var save = Save{}; diff --git a/src/main.zig b/src/main.zig index 1a692de..b0e9a96 100644 --- a/src/main.zig +++ b/src/main.zig @@ -90,8 +90,7 @@ pub fn main() !void { if (save_path_alloc) allocator.free(save_path); } - // Compatibility with v0.6.0 - const mapped_config_fields = .{.{ "blank_password", "clear_password" }}; + const comment_characters = "#"; if (res.args.config) |s| { const trailing_slash = if (s[s.len - 1] != '/') "/" else ""; @@ -99,31 +98,33 @@ pub fn main() !void { const config_path = try std.fmt.allocPrint(allocator, "{s}{s}config.ini", .{ s, trailing_slash }); defer allocator.free(config_path); - config = config_ini.readFileToStructWithMap(config_path, mapped_config_fields) catch Config{}; + config = config_ini.readFileToStruct(config_path, comment_characters, migrator.configFieldHandler) catch Config{}; const lang_path = try std.fmt.allocPrint(allocator, "{s}{s}lang/{s}.ini", .{ s, trailing_slash, config.lang }); defer allocator.free(lang_path); - lang = lang_ini.readFileToStruct(lang_path) catch Lang{}; + lang = lang_ini.readFileToStruct(lang_path, comment_characters, null) catch Lang{}; if (config.load) { save_path = try std.fmt.allocPrint(allocator, "{s}{s}save.ini", .{ s, trailing_slash }); save_path_alloc = true; var user_buf: [32]u8 = undefined; - save = save_ini.readFileToStruct(save_path) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file); + save = save_ini.readFileToStruct(save_path, comment_characters, null) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file); } } else { - config = config_ini.readFileToStructWithMap(build_options.data_directory ++ "/config.ini", mapped_config_fields) catch Config{}; + const config_path = build_options.data_directory ++ "/config.ini"; + + config = config_ini.readFileToStruct(config_path, comment_characters, migrator.configFieldHandler) catch Config{}; const lang_path = try std.fmt.allocPrint(allocator, "{s}/lang/{s}.ini", .{ build_options.data_directory, config.lang }); defer allocator.free(lang_path); - lang = lang_ini.readFileToStruct(lang_path) catch Lang{}; + lang = lang_ini.readFileToStruct(lang_path, comment_characters, null) catch Lang{}; if (config.load) { var user_buf: [32]u8 = undefined; - save = save_ini.readFileToStruct(save_path) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file); + save = save_ini.readFileToStruct(save_path, comment_characters, null) catch migrator.tryMigrateSaveFile(&user_buf, config.save_file); } } @@ -541,7 +542,7 @@ pub fn main() !void { .user = login.text.items, .session_index = desktop.current, }; - ini.writeFromStruct(save_data, file.writer(), null) catch break :save_last_settings; + ini.writeFromStruct(save_data, file.writer(), null, true, .{}) catch break :save_last_settings; } var shared_err = try SharedError.init(); diff --git a/src/tui/components/Desktop.zig b/src/tui/components/Desktop.zig index 98870d0..5bbaf60 100644 --- a/src/tui/components/Desktop.zig +++ b/src/tui/components/Desktop.zig @@ -150,7 +150,7 @@ pub fn crawl(self: *Desktop, path: []const u8, display_server: DisplayServer) !v const entry_path = try std.fmt.allocPrint(self.allocator, "{s}/{s}", .{ path, item.name }); defer self.allocator.free(entry_path); var entry_ini = Ini(Entry).init(self.allocator); - _ = try entry_ini.readFileToStruct(entry_path); + _ = try entry_ini.readFileToStruct(entry_path, "#", null); errdefer entry_ini.deinit(); var xdg_session_desktop: []const u8 = undefined; From 40d180da632d925f92ae61b436ec9d51a44f668b Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Tue, 30 Jul 2024 12:04:25 +0200 Subject: [PATCH 16/25] Backport: Only shutdown or restart after deinitializing everything Signed-off-by: AnErrupTion --- src/main.zig | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/main.zig b/src/main.zig index b0e9a96..ddee718 100644 --- a/src/main.zig +++ b/src/main.zig @@ -21,6 +21,7 @@ const utils = @import("tui/utils.zig"); const Ini = ini.Ini; const termbox = interop.termbox; +const temporary_allocator = std.heap.page_allocator; var session_pid: std.posix.pid_t = -1; pub fn signalHandler(i: c_int) callconv(.C) void { @@ -38,11 +39,32 @@ pub fn signalHandler(i: c_int) callconv(.C) void { } pub fn main() !void { + var shutdown = false; + var restart = false; + var shutdown_cmd: []const u8 = undefined; + var restart_cmd: []const u8 = undefined; + + const stderr = std.io.getStdErr().writer(); + + defer { + // If we can't shutdown or restart due to an error, we print it to standard error. If that fails, just bail out + if (shutdown) { + const shutdown_error = std.process.execv(temporary_allocator, &[_][]const u8{ "/bin/sh", "-c", shutdown_cmd }); + stderr.print("error: couldn't shutdown: {any}\n", .{shutdown_error}) catch std.process.exit(1); + } else if (restart) { + const restart_error = std.process.execv(temporary_allocator, &[_][]const u8{ "/bin/sh", "-c", restart_cmd }); + stderr.print("error: couldn't restart: {any}\n", .{restart_error}) catch std.process.exit(1); + } else { + // The user has quit Ly using Ctrl+C + temporary_allocator.free(shutdown_cmd); + temporary_allocator.free(restart_cmd); + } + } + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); - const stderr = std.io.getStdErr().writer(); // Load arguments const params = comptime clap.parseParamsComptime( @@ -128,6 +150,11 @@ pub fn main() !void { } } + // These strings only end up getting freed if the user quits Ly using Ctrl+C, which is fine since in the other cases + // we end up shutting down or restarting the system + shutdown_cmd = try temporary_allocator.dupe(u8, config.shutdown_cmd); + restart_cmd = try temporary_allocator.dupe(u8, config.restart_cmd); + interop.setNumlock(config.numlock) catch {}; if (config.initial_info_text) |text| { @@ -258,8 +285,6 @@ pub fn main() !void { var run = true; var update = true; var resolution_changed = false; - var shutdown = false; - var restart = false; var auth_fails: u64 = 0; // Switch to selected TTY if possible @@ -636,12 +661,6 @@ pub fn main() !void { }, } } - - if (shutdown) { - return std.process.execv(allocator, &[_][]const u8{ "/bin/sh", "-c", config.shutdown_cmd }); - } else if (restart) { - return std.process.execv(allocator, &[_][]const u8{ "/bin/sh", "-c", config.restart_cmd }); - } } fn getAuthErrorMsg(err: anyerror, lang: Lang) []const u8 { From 3ca2e8524b47b13ad36ed7ee1e4053b72be8fbd4 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Thu, 1 Aug 2024 13:20:23 +0200 Subject: [PATCH 17/25] Fix mcookie usage (fixes #669) Signed-off-by: AnErrupTion --- src/auth.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/auth.zig b/src/auth.zig index b55c9d2..1892c25 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -334,7 +334,7 @@ fn createXauthFile(pwd: [:0]const u8) ![:0]const u8 { return xauthority; } -pub fn mcookie(cmd: [:0]const u8) ![32]u8 { +pub fn mcookie(shell: [*:0]const u8, cmd: [:0]const u8) ![32]u8 { const pipe = try std.posix.pipe(); defer std.posix.close(pipe[1]); @@ -348,8 +348,8 @@ pub fn mcookie(cmd: [:0]const u8) ![32]u8 { std.posix.dup2(pipe[1], std.posix.STDOUT_FILENO) catch std.process.exit(1); std.posix.close(pipe[1]); - const args = [_:null]?[*:0]u8{}; - std.posix.execveZ(cmd.ptr, &args, std.c.environ) catch {}; + const args = [_:null]?[*:0]const u8{ shell, "-c", cmd }; + std.posix.execveZ(shell, &args, std.c.environ) catch {}; std.process.exit(1); } @@ -371,7 +371,7 @@ fn xauth(display_name: [:0]u8, shell: [*:0]const u8, pw_dir: [*:0]const u8, xaut _ = interop.setenv("XAUTHORITY", xauthority, 1); _ = interop.setenv("DISPLAY", display_name, 1); - const mcookie_output = try mcookie(mcookie_cmd); + const mcookie_output = try mcookie(shell, mcookie_cmd); const pid = try std.posix.fork(); if (pid == 0) { From 7300247e577b741d5e8f823e1b703f5e0ca20130 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Thu, 1 Aug 2024 13:29:34 +0200 Subject: [PATCH 18/25] Backport: Update zigini (fixes an escaping bug) Signed-off-by: AnErrupTion --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index ba6345e..557dcd9 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -8,8 +8,8 @@ .hash = "122014e73fd712190e109950837b97f6143f02d7e2b6986e1db70b6f4aadb5ba6a0d", }, .zigini = .{ - .url = "https://github.com/Kawaii-Ash/zigini/archive/bdb6fd15c6dcedb0c6c2a46381f2d298e2f05fff.tar.gz", - .hash = "12203feb831e21bec081af6aae70dd19b127f1627aa55f3415bd1fa476c174a511cc", + .url = "https://github.com/Kawaii-Ash/zigini/archive/0bba97a12582928e097f4074cc746c43351ba4c8.tar.gz", + .hash = "12209b971367b4066d40ecad4728e6fdffc4cc4f19356d424c2de57f5b69ac7a619a", }, }, .paths = .{""}, From 56202bc30e663d9b5ba584d170334f335bc49fd5 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Thu, 1 Aug 2024 18:02:03 +0200 Subject: [PATCH 19/25] Backport: Swap /usr/bin and /usr/sbin in PATH Signed-off-by: AnErrupTion --- res/config.ini | 14 +++++++------- src/config/Config.zig | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/res/config.ini b/res/config.ini index 68a39bb..e8fd099 100644 --- a/res/config.ini +++ b/res/config.ini @@ -30,12 +30,12 @@ vi_mode = false #define TB_CYAN 0x07 #define TB_WHITE 0x08 # -# Setting both to zero makes `bg` black and `fg` white. To set the actual color palette you are encouraged to use another tool -# such as [mkinitcpio-colors](https://github.com/evanpurkhiser/mkinitcpio-colors). Note that the color palette defined with -# `mkinitcpio-colors` takes 16 colors (0-15), only values 0-8 are valid for `ly` config and these values do not correspond -# exactly. For instance, in defining palettes with `mkinitcpio-colors` the order is black, dark red, dark green, brown, dark -# blue, dark purple, dark cyan, light gray, dark gray, bright red, bright green, yellow, bright blue, bright purple, bright -# cyan, and white, indexed in that order 0 through 15. For example, the color defined for white (indexed at 15 in the mkinitcpio +# Setting both to zero makes `bg` black and `fg` white. To set the actual color palette you are encouraged to use another tool +# such as [mkinitcpio-colors](https://github.com/evanpurkhiser/mkinitcpio-colors). Note that the color palette defined with +# `mkinitcpio-colors` takes 16 colors (0-15), only values 0-8 are valid for `ly` config and these values do not correspond +# exactly. For instance, in defining palettes with `mkinitcpio-colors` the order is black, dark red, dark green, brown, dark +# blue, dark purple, dark cyan, light gray, dark gray, bright red, bright green, yellow, bright blue, bright purple, bright +# cyan, and white, indexed in that order 0 through 15. For example, the color defined for white (indexed at 15 in the mkinitcpio # config) will be used by `ly` for `fg = 8`. # Background color id @@ -120,7 +120,7 @@ tty = 2 console_dev = /dev/console # Default path. If null, ly doesn't set a path. -path = /sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin +path = /sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin # Event timeout in milliseconds min_refresh_delta = 5 diff --git a/src/config/Config.zig b/src/config/Config.zig index bddda19..ad119c4 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -30,7 +30,7 @@ max_password_len: u8 = 255, mcookie_cmd: [:0]const u8 = "/usr/bin/mcookie", min_refresh_delta: u16 = 5, numlock: bool = false, -path: ?[:0]const u8 = "/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin", +path: ?[:0]const u8 = "/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin", restart_cmd: []const u8 = "/sbin/shutdown -r now", restart_key: []const u8 = "F2", save: bool = true, From 042aa50ff0ca5bff5996393022e98df3d8c9f6b2 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 2 Aug 2024 19:37:11 +0200 Subject: [PATCH 20/25] Start Ly v1.0.3 development cycle Signed-off-by: AnErrupTion --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 083bd2a..e1dae11 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,6 @@ const std = @import("std"); -const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 2 }; +const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 3 }; var dest_directory: []const u8 = undefined; var data_directory: []const u8 = undefined; var exe_name: []const u8 = undefined; From fadbbf676ad88e57cecffd501b5a4d4634064688 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 2 Aug 2024 19:40:09 +0200 Subject: [PATCH 21/25] Support Zig 0.13.0 Signed-off-by: AnErrupTion --- .gitignore | 3 ++- build.zig | 26 ++++++++++++++++++++------ build.zig.zon | 4 ++-- src/main.zig | 4 ++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 60f36fa..de08f4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ zig-cache/ zig-out/ -valgrind.log \ No newline at end of file +valgrind.log +.zig-cache diff --git a/build.zig b/build.zig index e1dae11..995536d 100644 --- a/build.zig +++ b/build.zig @@ -1,10 +1,24 @@ const std = @import("std"); +const builtin = @import("builtin"); + +const min_zig_string = "0.12.0"; +const current_zig = builtin.zig_version; + +// Implementing zig version detection through compile time +comptime { + const min_zig = std.SemanticVersion.parse(min_zig_string) catch unreachable; + if (current_zig.order(min_zig) == .lt) { + @compileError(std.fmt.comptimePrint("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig })); + } +} const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 3 }; var dest_directory: []const u8 = undefined; var data_directory: []const u8 = undefined; var exe_name: []const u8 = undefined; +const ProgressNode = if (current_zig.minor == 12) *std.Progress.Node else std.Progress.Node; + pub fn build(b: *std.Build) !void { dest_directory = b.option([]const u8, "dest_directory", "Specify a destination directory for installation") orelse ""; data_directory = b.option([]const u8, "data_directory", "Specify a default data directory (default is /etc/ly). This path gets embedded into the binary") orelse "/etc/ly"; @@ -25,7 +39,7 @@ pub fn build(b: *std.Build) !void { const exe = b.addExecutable(.{ .name = "ly", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); @@ -38,14 +52,14 @@ pub fn build(b: *std.Build) !void { const clap = b.dependency("clap", .{ .target = target, .optimize = optimize }); exe.root_module.addImport("clap", clap.module("clap")); - exe.addIncludePath(.{ .path = "include" }); + exe.addIncludePath(b.path("include")); exe.linkSystemLibrary("pam"); exe.linkSystemLibrary("xcb"); exe.linkLibC(); // HACK: Only fails with ReleaseSafe, so we'll override it. const translate_c = b.addTranslateC(.{ - .root_source_file = .{ .path = "include/termbox2.h" }, + .root_source_file = b.path("include/termbox2.h"), .target = target, .optimize = if (optimize == .ReleaseSafe) .ReleaseFast else optimize, }); @@ -94,7 +108,7 @@ pub fn build(b: *std.Build) !void { pub fn ExeInstaller(install_conf: bool) type { return struct { - pub fn make(step: *std.Build.Step, progress: *std.Progress.Node) !void { + pub fn make(step: *std.Build.Step, progress: ProgressNode) !void { _ = progress; try install_ly(step.owner.allocator, install_conf); } @@ -108,7 +122,7 @@ const InitSystem = enum { }; pub fn ServiceInstaller(comptime init_system: InitSystem) type { return struct { - pub fn make(step: *std.Build.Step, progress: *std.Progress.Node) !void { + pub fn make(step: *std.Build.Step, progress: ProgressNode) !void { _ = progress; const allocator = step.owner.allocator; switch (init_system) { @@ -220,7 +234,7 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void { } } -pub fn uninstallall(step: *std.Build.Step, progress: *std.Progress.Node) !void { +pub fn uninstallall(step: *std.Build.Step, progress: ProgressNode) !void { _ = progress; try std.fs.cwd().deleteTree(data_directory); const allocator = step.owner.allocator; diff --git a/build.zig.zon b/build.zig.zon index 557dcd9..c4c9cbd 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -4,8 +4,8 @@ .minimum_zig_version = "0.12.0", .dependencies = .{ .clap = .{ - .url = "https://github.com/Hejsil/zig-clap/archive/8c98e6404b22aafc0184e999d8f068b81cc22fa1.tar.gz", - .hash = "122014e73fd712190e109950837b97f6143f02d7e2b6986e1db70b6f4aadb5ba6a0d", + .url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.9.1.tar.gz", + .hash = "122062d301a203d003547b414237229b09a7980095061697349f8bef41be9c30266b", }, .zigini = .{ .url = "https://github.com/Kawaii-Ash/zigini/archive/0bba97a12582928e097f4074cc746c43351ba4c8.tar.gz", diff --git a/src/main.zig b/src/main.zig index ddee718..022ff54 100644 --- a/src/main.zig +++ b/src/main.zig @@ -512,7 +512,7 @@ pub fn main() !void { run = false; } else if (pressed_key == sleep_key) { if (config.sleep_cmd) |sleep_cmd| { - var sleep = std.ChildProcess.init(&[_][]const u8{ "/bin/sh", "-c", sleep_cmd }, allocator); + var sleep = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", sleep_cmd }, allocator); _ = sleep.spawnAndWait() catch .{}; } } @@ -617,7 +617,7 @@ pub fn main() !void { update = true; - var restore_cursor = std.ChildProcess.init(&[_][]const u8{ "/bin/sh", "-c", config.term_restore_cursor_cmd }, allocator); + var restore_cursor = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", config.term_restore_cursor_cmd }, allocator); _ = restore_cursor.spawnAndWait() catch .{}; }, else => { From ea2dec50f5430b1e31fb0c0657fde066abe6abe1 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Fri, 2 Aug 2024 19:40:25 +0200 Subject: [PATCH 22/25] Update README.md Signed-off-by: AnErrupTion --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index b323c0d..676d612 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@ Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD. ## Dependencies - Compile-time: - - zig 0.12.0 + - zig 0.12.0 or 0.13.0 - a C standard library - pam - xcb From a9449742d6392d2d03796093990e6649f3983a62 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Wed, 5 Mar 2025 22:52:34 +0100 Subject: [PATCH 23/25] Backport: Try to create /etc/pam.d and /usr/bin everytime when installing Signed-off-by: AnErrupTion --- build.zig | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index 995536d..17b7943 100644 --- a/build.zig +++ b/build.zig @@ -174,11 +174,11 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void { { const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/usr/bin" }); - if (!std.mem.eql(u8, dest_directory, "")) { - std.fs.cwd().makePath(exe_path) catch { + std.fs.cwd().makePath(exe_path) catch { + if (!std.mem.eql(u8, dest_directory, "")) { std.debug.print("warn: {s} already exists as a directory.\n", .{exe_path}); - }; - } + } + }; var executable_dir = std.fs.cwd().openDir(exe_path, .{}) catch unreachable; defer executable_dir.close(); @@ -221,11 +221,12 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void { { const pam_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, "/etc/pam.d" }); - if (!std.mem.eql(u8, dest_directory, "")) { - std.fs.cwd().makePath(pam_path) catch { + + std.fs.cwd().makePath(pam_path) catch { + if (!std.mem.eql(u8, dest_directory, "")) { std.debug.print("warn: {s} already exists as a directory.\n", .{pam_path}); - }; - } + } + }; var pam_dir = std.fs.cwd().openDir(pam_path, .{}) catch unreachable; defer pam_dir.close(); From 83984dc4933bbe0262fa5377eae6c61a9c825525 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Wed, 5 Mar 2025 22:54:34 +0100 Subject: [PATCH 24/25] Backport: Don't set XDG_CURRENT_DESKTOP and XDG_SESSION_DESKTOP if they're empty Signed-off-by: AnErrupTion --- src/auth.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auth.zig b/src/auth.zig index 1892c25..05ea61f 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -183,11 +183,11 @@ fn setXdgEnv(tty_str: [:0]u8, desktop_name: [:0]const u8, xdg_desktop_names: [:0 var uid_buffer: [10 + @sizeOf(u32) + 1]u8 = undefined; const uid_str = try std.fmt.bufPrintZ(&uid_buffer, "/run/user/{d}", .{uid}); - _ = interop.setenv("XDG_CURRENT_DESKTOP", xdg_desktop_names.ptr, 0); + if (!std.mem.eql(u8, xdg_desktop_names, "")) _ = interop.setenv("XDG_CURRENT_DESKTOP", xdg_desktop_names.ptr, 0); _ = interop.setenv("XDG_RUNTIME_DIR", uid_str.ptr, 0); _ = interop.setenv("XDG_SESSION_CLASS", "user", 0); _ = interop.setenv("XDG_SESSION_ID", "1", 0); - _ = interop.setenv("XDG_SESSION_DESKTOP", desktop_name.ptr, 0); + if (!std.mem.eql(u8, desktop_name, "")) _ = interop.setenv("XDG_SESSION_DESKTOP", desktop_name.ptr, 0); _ = interop.setenv("XDG_SEAT", "seat0", 0); _ = interop.setenv("XDG_VTNR", tty_str.ptr, 0); } From 4b9ea3d7cb12678c3e8dd0bad1261bcc66b14a96 Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Thu, 6 Mar 2025 21:18:33 +0100 Subject: [PATCH 25/25] Backport: Possibly fix .Xresources not being loaded Signed-off-by: AnErrupTion --- res/xsetup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/res/xsetup.sh b/res/xsetup.sh index 2c962f5..e73d357 100755 --- a/res/xsetup.sh +++ b/res/xsetup.sh @@ -83,6 +83,10 @@ if [ -d "$xsessionddir" ]; then done fi +if [ -f "$USERXSESSION" ]; then + . "$USERXSESSION" +fi + if [ -d /etc/X11/Xresources ]; then for i in /etc/X11/Xresources/*; do [ -f $i ] && xrdb -merge $i @@ -93,10 +97,6 @@ fi [ -f $HOME/.Xresources ] && xrdb -merge $HOME/.Xresources [ -f $XDG_CONFIG_HOME/X11/Xresources ] && xrdb -merge $XDG_CONFIG_HOME/X11/Xresources -if [ -f "$USERXSESSION" ]; then - . "$USERXSESSION" -fi - if [ -z "$*" ]; then exec xmessage -center -buttons OK:0 -default OK "Sorry, $DESKTOP_SESSION is no valid session." else