mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
core: function to detect the display type
This commit is contained in:
@ -39,6 +39,7 @@ pub fn run(alloc: Allocator) !u8 {
|
|||||||
try stdout.print(" - libxev : {}\n", .{xev.backend});
|
try stdout.print(" - libxev : {}\n", .{xev.backend});
|
||||||
if (comptime build_config.app_runtime == .gtk) {
|
if (comptime build_config.app_runtime == .gtk) {
|
||||||
try stdout.print(" - desktop env : {s}\n", .{@tagName(internal_os.desktopEnvironment())});
|
try stdout.print(" - desktop env : {s}\n", .{@tagName(internal_os.desktopEnvironment())});
|
||||||
|
try stdout.print(" - display type: {s}\n", .{@tagName(internal_os.displayType())});
|
||||||
try stdout.print(" - GTK version :\n", .{});
|
try stdout.print(" - GTK version :\n", .{});
|
||||||
try stdout.print(" build : {d}.{d}.{d}\n", .{
|
try stdout.print(" build : {d}.{d}.{d}\n", .{
|
||||||
gtk.GTK_MAJOR_VERSION,
|
gtk.GTK_MAJOR_VERSION,
|
||||||
|
@ -85,3 +85,30 @@ pub fn desktopEnvironment() DesktopEnvironment {
|
|||||||
else => .other,
|
else => .other,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const DisplayType = enum {
|
||||||
|
macos,
|
||||||
|
other,
|
||||||
|
wayland,
|
||||||
|
windows,
|
||||||
|
x11,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Detect what desktop environment we are running under. This is mainly used on
|
||||||
|
/// Linux to enable or disable GTK client-side decorations but there may be more
|
||||||
|
/// uses in the future.
|
||||||
|
pub fn displayType() DisplayType {
|
||||||
|
return switch (comptime builtin.os.tag) {
|
||||||
|
.macos => .macos,
|
||||||
|
.windows => .windows,
|
||||||
|
.linux => dt: {
|
||||||
|
if (@inComptime()) @compileError("Checking for the display type on Linux must be done at runtime.");
|
||||||
|
// use $XDG_SESSION_TYPE to determine what display type we are using on Linux
|
||||||
|
const dt = posix.getenv("XDG_SESSION_TYPE") orelse break :dt .other;
|
||||||
|
if (std.ascii.eqlIgnoreCase("wayland", dt)) break :dt .wayland;
|
||||||
|
if (std.ascii.eqlIgnoreCase("x11", dt)) break :dt .x11;
|
||||||
|
break :dt .other;
|
||||||
|
},
|
||||||
|
else => .other,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -33,6 +33,7 @@ pub const setenv = env.setenv;
|
|||||||
pub const unsetenv = env.unsetenv;
|
pub const unsetenv = env.unsetenv;
|
||||||
pub const launchedFromDesktop = desktop.launchedFromDesktop;
|
pub const launchedFromDesktop = desktop.launchedFromDesktop;
|
||||||
pub const desktopEnvironment = desktop.desktopEnvironment;
|
pub const desktopEnvironment = desktop.desktopEnvironment;
|
||||||
|
pub const displayType = desktop.displayType;
|
||||||
pub const rlimit = file.rlimit;
|
pub const rlimit = file.rlimit;
|
||||||
pub const fixMaxFiles = file.fixMaxFiles;
|
pub const fixMaxFiles = file.fixMaxFiles;
|
||||||
pub const restoreMaxFiles = file.restoreMaxFiles;
|
pub const restoreMaxFiles = file.restoreMaxFiles;
|
||||||
|
Reference in New Issue
Block a user