mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-14 05:43:47 +01:00
29 lines
639 B
Zig
29 lines
639 B
Zig
//! Utilities regarding the system daemon (systemd)
|
|
|
|
const std = @import("std");
|
|
|
|
pub const SystemDaemon = enum {
|
|
none,
|
|
systemd,
|
|
};
|
|
|
|
pub fn getCurrentSystemDaemon() !SystemDaemon {
|
|
const cache = struct {
|
|
var daemon: ?SystemDaemon = null;
|
|
};
|
|
|
|
if (cache.daemon) |d|
|
|
return d;
|
|
|
|
const systemd_stat: ?std.fs.File.Stat = std.fs.cwd().statFile("/etc/systemd") catch |e| blk: {
|
|
if (e == error.FileNotFound) {
|
|
break :blk null;
|
|
}
|
|
|
|
return e;
|
|
};
|
|
|
|
const daemon: SystemDaemon = if (systemd_stat) |_| .systemd else .none;
|
|
cache.daemon = daemon;
|
|
return daemon;
|
|
}
|