diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee0dde27..564ffc26 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ name: "Generate test artifacts" on: + workflow_dispatch: pull_request: types: [opened, reopened, synchronize] diff --git a/build.py b/build.py index e886b10a..bc957661 100755 --- a/build.py +++ b/build.py @@ -49,10 +49,7 @@ class Suffix: IS_DARK = Suffix(true_value="-Dark", test=lambda ctx: ctx.flavor.dark) IS_LIGHT = Suffix(true_value="-Light", test=lambda ctx: not ctx.flavor.dark) IS_WINDOW_NORMAL = Suffix(true_value="-Normal", test=lambda ctx: ctx.tweaks.has('normal')) -DARK_LIGHT = Suffix( - true_value="-Dark", false_value="-Light", test=lambda ctx: ctx.flavor.dark -) - +DARK_LIGHT = Suffix(true_value="-Dark", false_value="-Light", test=lambda ctx: ctx.flavor.dark) @dataclass class BuildContext: @@ -63,6 +60,7 @@ class BuildContext: accent: Color size: Literal["standard"] | Literal["compact"] tweaks: Tweaks + temp_tweaks_file: str # Add a temporary tweaks file attribute def output_dir(self) -> str: return f"{self.build_root}/{self.build_id()}" @@ -165,16 +163,6 @@ def build(ctx: BuildContext): f"{SRC_DIR}/main/metacity-1/metacity-theme-3{ctx.apply_suffix(IS_WINDOW_NORMAL)}.xml", f"{output_dir}/metacity-1/metacity-theme-3.xml", ) - # FIXME: Symlinks aren't working as intended - # FIXME: Do we need them? - # os.symlink( - # f"{output_dir}/metacity-1/metacity-theme-3.xml", - # f"{output_dir}/metacity-1/metacity-theme-2.xml", - # ) - # os.symlink( - # f"{output_dir}/metacity-1/metacity-theme-3.xml", - # f"{output_dir}/metacity-1/metacity-theme-1.xml", - # ) os.makedirs(f"{output_dir}/xfwm4", exist_ok=True) shutil.copyfile( @@ -207,10 +195,8 @@ def build(ctx: BuildContext): f"{SRC_DIR}/main/plank/theme-Dark-Catppuccin/", f"{output_dir}/plank" ) - -def init_tweaks_temp(): - shutil.copyfile(f"{SRC_DIR}/sass/_tweaks.scss", f"{SRC_DIR}/sass/_tweaks-temp.scss") - +def init_tweaks_temp(temp_file): + shutil.copyfile(f"{SRC_DIR}/sass/_tweaks.scss", temp_file) def subst_text(path, _from, to): with open(path, "r+") as f: @@ -223,20 +209,20 @@ def subst_text(path, _from, to): GS_VERSION = "46-0" -def gnome_shell_version(): +def gnome_shell_version(temp_file): shutil.copyfile( f"{SRC_DIR}/sass/gnome-shell/_common.scss", - f"{SRC_DIR}/sass/gnome-shell/_common-temp.scss", + temp_file, ) subst_text( - f"{SRC_DIR}/sass/gnome-shell/_common-temp.scss", + temp_file, "@import 'widgets-40-0';", f"@import 'widgets-{GS_VERSION}';", ) if GS_VERSION == "3-28": subst_text( - f"{SRC_DIR}/sass/gnome-shell/_common-temp.scss", + temp_file, "@import 'extensions-40-0';", f"@import 'extensions-{GS_VERSION}';", ) @@ -265,37 +251,36 @@ def translate_accent(ctp_accent: Color): return ctp_to_colloid[ctp_accent.identifier] -def write_tweak(key, default, value): +def write_tweak(key, default, value, temp_file): subst_text( - f"{SRC_DIR}/sass/_tweaks-temp.scss", f"\\${key}: {default}", f"${key}: {value}" + temp_file, f"\\${key}: {default}", f"${key}: {value}" ) def apply_tweaks(ctx: BuildContext): - write_tweak("theme", "'default'", f"'{translate_accent(ctx.accent)}'") + write_tweak("theme", "'default'", f"'{translate_accent(ctx.accent)}'", ctx.temp_tweaks_file) if ctx.size == "compact": - write_tweak("compact", "'false'", "'true'") + write_tweak("compact", "'false'", "'true'", ctx.temp_tweaks_file) subst_text( - f"{SRC_DIR}/sass/_tweaks-temp.scss", + ctx.temp_tweaks_file, "@import 'color-palette-default';", f"@import 'color-palette-catppuccin-{ctx.flavor.identifier}';", ) - write_tweak("colorscheme", "'default'", "'catppuccin'") + write_tweak("colorscheme", "'default'", "'catppuccin'", ctx.temp_tweaks_file) if ctx.tweaks.has("black"): - write_tweak("blackness", "'false'", "'true'") + write_tweak("blackness", "'false'", "'true'", ctx.temp_tweaks_file) if ctx.tweaks.has("rimless"): - write_tweak("rimless", "'false'", "'true'") + write_tweak("rimless", "'false'", "'true'", ctx.temp_tweaks_file) if ctx.tweaks.has("normal"): - write_tweak("window_button", "'mac'", "'normal'") + write_tweak("window_button", "'mac'", "'normal'", ctx.temp_tweaks_file) if ctx.tweaks.has("float"): - write_tweak("float", "'false'", "'true'") - + write_tweak("float", "'false'", "'true'", ctx.temp_tweaks_file) def make_assets(ctx: BuildContext): output_dir = ctx.output_dir() @@ -482,7 +467,6 @@ def apply_colloid_patches(): return logger.info("Applying patches...") - # Change into colloid for patch in [ "plank-dark.patch", "plank-light.patch", @@ -601,6 +585,7 @@ def parse_args(): def process_accent(args, palette, accent): + temp_file = f"{SRC_DIR}/sass/_tweaks-temp-{accent.identifier}.scss" tweaks = Tweaks(tweaks=args.tweaks) if args.zip: @@ -616,12 +601,13 @@ def process_accent(args, palette, accent): size=args.size, tweaks=tweaks, output_format=output_format, + temp_tweaks_file=temp_file, # Pass the temporary file to context ) logger.info("Building temp tweaks file") - init_tweaks_temp() + init_tweaks_temp(temp_file) logger.info("Inserting gnome-shell imports") - gnome_shell_version() + gnome_shell_version(temp_file) logger.info("Building main theme") build_theme(ctx) logger.info(f"Completed {palette.identifier} with {accent.identifier}")