6 Commits

Author SHA1 Message Date
AnErrupTion
4b9ea3d7cb Backport: Possibly fix .Xresources not being loaded
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2025-03-06 21:18:33 +01:00
AnErrupTion
83984dc493 Backport: Don't set XDG_CURRENT_DESKTOP and XDG_SESSION_DESKTOP if they're empty
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2025-03-05 22:54:34 +01:00
AnErrupTion
a9449742d6 Backport: Try to create /etc/pam.d and /usr/bin everytime when installing
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2025-03-05 22:52:34 +01:00
AnErrupTion
ea2dec50f5 Update README.md
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2024-08-02 19:40:25 +02:00
AnErrupTion
fadbbf676a Support Zig 0.13.0
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2024-08-02 19:40:09 +02:00
AnErrupTion
042aa50ff0 Start Ly v1.0.3 development cycle
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2024-08-02 19:37:11 +02:00
7 changed files with 43 additions and 27 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
zig-cache/
zig-out/
valgrind.log
.zig-cache

View File

@@ -1,10 +1,24 @@
const std = @import("std");
const builtin = @import("builtin");
const ly_version = std.SemanticVersion{ .major = 1, .minor = 0, .patch = 2 };
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) {
@@ -160,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 {
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();
@@ -207,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 {
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();
@@ -220,7 +235,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;

View File

@@ -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",

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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 => {