Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: build system rework #67

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake;
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.directory
.kate-swp
dist/**
.direnv/
108 changes: 108 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/usr/bin/env bash

set -ea pipefail

check_command_exists() {
command_name="${*}"

if ! command -v "$command_name" >/dev/null 2>&1; then
echo "Error: Dependency '$command_name' is not met."
echo "Exiting.."
exit 1
fi
}

check_command_exists "whiskers"
check_command_exists "tar"

build_template() {
template="$1"
overrides="$2"
empty="{}"
overrides="${overrides:-$empty}"
echo "Building $template"
whiskers $template --overrides "${overrides}"
echo "Done"
echo
}

build_aurorae_theme() {
flavor="$1"
accent="$2"
style="$3"

dist="./dist/Catppuccin-$flavor-$accent"

cp -r ./Resources/Aurorae/"Catppuccin$flavor"-"$style" "$dist"

if [ "$flavor" == "Latte" ]; then
cp ./Resources/Aurorae/Common/CatppuccinLatte-"$style"rc "$dist"/Catppuccin"$flavor"-"$style"rc
else
cp ./Resources/Aurorae/Common/Catppuccin-"$style"rc "$dist"/Catppuccin"$flavor"-"$style"rc
fi

case "$style" in
Modern)
case "$flavor" in
Mocha) storeCode="2135229" ;;
Macchiato) storeCode="2135227" ;;
Frappe) storeCode="2135225" ;;
Latte) storeCode="2135223" ;;
esac
;;
Classic)
case "$FLAVOUR" in
Mocha) storeCode="2135228" ;;
Macchiato) storeCode="2135226" ;;
Frappe) storeCode="2135224" ;;
Latte) storeCode="2135222" ;;
esac
;;
*) echo "Not a valid Window decoration" ;;
esac

build_template templates/look-and-feel/defaults.tera
build_template templates/look-and-feel/metadata.json.tera "{ \"storeCode\": \"$storeCode\" }"
build_template templates/look-and-feel/metadata.desktop.tera "{ \"storeCode\": \"$storeCode\" }"
}

build_splash_screen() {
flavor="$1"
accent="$2"

dist="./dist/Catppuccin-$flavor-$accent/Splash"
mkdir -p "$dist"/contents/previews
mkdir -p "$dist"/contents/splash/images

# Add CTP Logo
if [ "$flavour" == "latte" ]; then
cp ./Resources/splash-screen/contents/splash/images/Latte_Logo.png "$dist"/contents/splash/images/Logo.png
else
cp ./Resources/splash-screen/contents/splash/images/Logo.png "$dist"/contents/splash/images/Logo.png
fi

cp ./Resources/splash-previews/"$flavor".png "$dist"/contents/previews/splash.png
}

render_templates() {
build_template templates/palette.tera

build_template templates/splash-screen/busywidget.tera
build_template templates/splash-screen/splash-qml.tera
}

render_templates

flavors="Mocha Frappe Macchiato Latte"
accents="Rosewater Flamingo Pink Mauve Red Maroon Peach Yellow Green Teal Sky Sapphire Blue Lavender"
for flavor in $flavors;
do
for accent in $accents;
do
build_aurorae_theme "$flavor" "$accent" "Modern"
build_aurorae_theme "$flavor" "$accent" "Classic"
build_splash_screen "$flavor" "$accent"

cp -r ./Resources/LookAndFeel/Catppuccin-"$flavor"-Global/* ./dist/Catppuccin-"$flavor"-"$accent"
done
done
118 changes: 118 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
whiskers.url = "github:catppuccin/whiskers";
};

outputs =
{ self, nixpkgs, whiskers, ... }:
let
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];

forEachSystem =
function:
nixpkgs.lib.genAttrs systems (
system:
function {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
}
);
in
{
devShells = forEachSystem (
{ pkgs, system }:
{
default = pkgs.mkShell { packages = with pkgs; [ whiskers.packages.${system}.default ]; };
}
);

formatter = forEachSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
};

nixConfig = {
extra-substituters = [ "https://catppuccin.cachix.org" ];
extra-trusted-public-keys = [
"catppuccin.cachix.org-1:noG/4HkbhJb+lUAdKrph6LaozJvAeEEZj4N732IysmU="
];
};
}
27 changes: 27 additions & 0 deletions templates/look-and-feel/defaults.tera
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
whiskers:
version: 2.3.0
matrix:
- flavor
- accent
- style: [ "Modern", "Classic" ]
filename: "dist/Catppuccin-{{ flavor.identifier | capitalize }}-{{ accent | capitalize }}/contents/defaults"
---
{%- set accent = flavor.colors[accent] -%}
[kdeglobals][General]
ColorScheme=Catppuccin{{ flavor.name }}{{ accent }}

[kcminputrc][Mouse]
cursorTheme=Catppuccin{{ flavor.name }}{{ accent }}

[kwinrc][org.kde.kdecoration2]
ButtonsOnLeft=
ButtonsOnRight=IAX
library=org.kde.kwin.aurorae
theme=__aurorae__svg__Catppuccin{{ flavor.name }}-{{ style }}

[plasmarc][Theme]
name=default

[KSplash]
Theme=Catppuccin{{ flavor.name }}{{ accent }}-splash
22 changes: 22 additions & 0 deletions templates/look-and-feel/metadata.desktop.tera
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
whiskers:
version: 2.3.0
matrix:
- flavor
- accent
filename: "dist/Catppuccin-{{ flavor.identifier | capitalize }}-{{ accent | capitalize }}/metadata.desktop"
---
{%- set accent = flavor.colors[accent] -%}
[Desktop Entry]
Comment=A theme based on Catppuccin's {{ flavor.name }} flavour
Name=Catppuccin {{ flavor.name }} {{ accent.name }}
X-KDE-PluginInfo-Author=KDE-Catppuccin
X-KDE-PluginInfo-Category=Global Themes (Plasma 6)
X-KDE-PluginInfo-Email=core@catppuccin.com
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-PluginInfo-License=MIT
X-KDE-PluginInfo-Name=Catppuccin-{{ flavor.name }}-{{ accent.name }}
X-KDE-PluginInfo-Version=0.2.6
X-KDE-PluginInfo-Website=github.com/catppuccin/KDE
X-KDE-ServiceTypes=Plasma/LookAndFeel
X-KPackage-Dependencies=kns://aurorae.knsrc/api.kde-look.org/{{ storeCode }}
31 changes: 31 additions & 0 deletions templates/look-and-feel/metadata.json.tera
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
whiskers:
version: 2.3.0
matrix:
- flavor
- accent
filename: "dist/Catppuccin-{{ flavor.identifier | capitalize }}-{{ accent | capitalize }}/metadata.desktop"
---
{%- set accent = flavor.colors[accent] -%}
{
"KPackageStructure": "Plasma/LookAndFeel",
"KPlugin": {
"Authors": [
{
"Email": "core@catppuccin.com",
"Name": "Catppuccin"
}
],
"Category": "Global Themes (Plasma 6)",
"Dependencies": [
],
"EnabledByDefault": true,
"Id": "Catppuccin-{{ flavor.name }}-{{ accent.name }}",
"License": "MIT",
"Name": "Catppuccin {{ flavor.name }} {{ accent.name }}",
"Version": "0.2.6"
},
"X-KPackage-Dependencies": [
"kns://aurorae.knsrc/api.kde-look.org/{{ storeCode }}"
]
}
Loading
Loading