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:
@ -27,46 +27,47 @@ pub fn run(alloc: Allocator) !u8 {
|
|||||||
if (tty) try stdout.print("\x1b]8;;\x1b\\", .{});
|
if (tty) try stdout.print("\x1b]8;;\x1b\\", .{});
|
||||||
|
|
||||||
try stdout.print("Version\n", .{});
|
try stdout.print("Version\n", .{});
|
||||||
try stdout.print(" - version: {s}\n", .{build_config.version_string});
|
try stdout.print(" - version : {s}\n", .{build_config.version_string});
|
||||||
try stdout.print(" - channel: {s}\n", .{@tagName(build_config.release_channel)});
|
try stdout.print(" - channel : {s}\n", .{@tagName(build_config.release_channel)});
|
||||||
|
|
||||||
try stdout.print("Build Config\n", .{});
|
try stdout.print("Build Config\n", .{});
|
||||||
try stdout.print(" - Zig version: {s}\n", .{builtin.zig_version_string});
|
try stdout.print(" - Zig version : {s}\n", .{builtin.zig_version_string});
|
||||||
try stdout.print(" - build mode : {}\n", .{builtin.mode});
|
try stdout.print(" - build mode : {}\n", .{builtin.mode});
|
||||||
try stdout.print(" - app runtime: {}\n", .{build_config.app_runtime});
|
try stdout.print(" - app runtime : {}\n", .{build_config.app_runtime});
|
||||||
try stdout.print(" - font engine: {}\n", .{build_config.font_backend});
|
try stdout.print(" - font engine : {}\n", .{build_config.font_backend});
|
||||||
try stdout.print(" - renderer : {}\n", .{renderer.Renderer});
|
try stdout.print(" - renderer : {}\n", .{renderer.Renderer});
|
||||||
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(" - GTK version:\n", .{});
|
try stdout.print(" - display type: {s}\n", .{@tagName(internal_os.displayType())});
|
||||||
try stdout.print(" build : {d}.{d}.{d}\n", .{
|
try stdout.print(" - GTK version :\n", .{});
|
||||||
|
try stdout.print(" build : {d}.{d}.{d}\n", .{
|
||||||
gtk.GTK_MAJOR_VERSION,
|
gtk.GTK_MAJOR_VERSION,
|
||||||
gtk.GTK_MINOR_VERSION,
|
gtk.GTK_MINOR_VERSION,
|
||||||
gtk.GTK_MICRO_VERSION,
|
gtk.GTK_MICRO_VERSION,
|
||||||
});
|
});
|
||||||
try stdout.print(" runtime : {d}.{d}.{d}\n", .{
|
try stdout.print(" runtime : {d}.{d}.{d}\n", .{
|
||||||
gtk.gtk_get_major_version(),
|
gtk.gtk_get_major_version(),
|
||||||
gtk.gtk_get_minor_version(),
|
gtk.gtk_get_minor_version(),
|
||||||
gtk.gtk_get_micro_version(),
|
gtk.gtk_get_micro_version(),
|
||||||
});
|
});
|
||||||
if (comptime build_options.adwaita) {
|
if (comptime build_options.adwaita) {
|
||||||
try stdout.print(" - libadwaita : enabled\n", .{});
|
try stdout.print(" - libadwaita : enabled\n", .{});
|
||||||
try stdout.print(" build : {s}\n", .{
|
try stdout.print(" build : {s}\n", .{
|
||||||
gtk.ADW_VERSION_S,
|
gtk.ADW_VERSION_S,
|
||||||
});
|
});
|
||||||
try stdout.print(" runtime : {}.{}.{}\n", .{
|
try stdout.print(" runtime : {}.{}.{}\n", .{
|
||||||
gtk.adw_get_major_version(),
|
gtk.adw_get_major_version(),
|
||||||
gtk.adw_get_minor_version(),
|
gtk.adw_get_minor_version(),
|
||||||
gtk.adw_get_micro_version(),
|
gtk.adw_get_micro_version(),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
try stdout.print(" - libadwaita : disabled\n", .{});
|
try stdout.print(" - libadwaita : disabled\n", .{});
|
||||||
}
|
}
|
||||||
if (comptime build_options.x11) {
|
if (comptime build_options.x11) {
|
||||||
try stdout.print(" - libX11 : enabled\n", .{});
|
try stdout.print(" - libX11 : enabled\n", .{});
|
||||||
} else {
|
} else {
|
||||||
try stdout.print(" - libX11 : disabled\n", .{});
|
try stdout.print(" - libX11 : disabled\n", .{});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -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