Files
kryon/tests/system_theme_linux_behavior.zi
T
waozi 605855a1cd Follow the desktop theme: read the GTK palette and install the classic style in it
SystemTheme parses a GTK theme's @define-color palette; SystemThemeLinux finds
the configured theme (Xfce xfconf, GTK settings.ini, GTK_THEME); SystemStyle
installs the embedded classic pack with the palette's colors. This replaces the
system theme the legacy C runtime had.
2026-09-28 19:50:44 -03:00

42 lines
1.4 KiB
Ziran

#import "byte_text_linux"
#import "c_string"
#import "system_theme"
#import "system_theme_linux"
libc :: #system_library "libc";
GetEnvironment :: (name: *u8) -> *u8 #foreign libc "getenv";
#program_export
main :: () -> s32 {
key: [16]u8
CopyCString("SCENARIO", key[:])
scenario: *u8 = GetEnvironment(*key[0])
if scenario == null { return 90 }
which: string = TextFromCString(scenario)
palette: SystemPalette = SystemPaletteRead()
if which == "xfce-dark" {
// xfconf names the theme; its CSS gives the colors.
if SystemThemeName() != "Fake-Dark" { return 1 }
if !palette.found || !palette.dark { return 2 }
if palette.background != cast(u32)0x161925FF || palette.selected != cast(u32)0xc50ed2FF { return 3 }
return 0
}
if which == "gtk-light" {
// No xfconf: settings.ini names a light theme.
if SystemThemeName() != "Fake-Light" { return 4 }
if !palette.found || palette.dark || palette.background != cast(u32)0xf6f5f4FF { return 5 }
return 0
}
if which == "env-dark" {
// Only GTK_THEME, naming a theme that is not installed.
if SystemThemeName() != "Missing" { return 6 }
if palette.found || !palette.dark { return 7 }
return 0
}
if which == "none" {
if SystemThemeName() != "" || palette.found || palette.dark { return 8 }
return 0
}
return 91
}