#!/usr/bin/make -f

kde := debian/whitesur-kde/usr/share
sddm := debian/sddm-theme-whitesur/usr/share/sddm/themes/WhiteSur

%:
	dh $@

# Upstream's install.sh, as root with its default options, minus the wallpapers
# the repack drops: every global theme and Plasma style (each Plasma style gets
# its own copy of the shared icons and weather dirs), the colour schemes, the
# WhiteSur Kvantum theme, and the round Aurorae decorations for both light/dark
# and WhiteSur/WhiteSurLiquid at every scale, each assembled from its
# decoration.svg, the shared button assets, the shared metadata renamed to the
# theme, and the family's rc file.
override_dh_auto_install:
	install -d $(kde)/plasma/look-and-feel $(kde)/plasma/desktoptheme $(kde)/color-schemes $(kde)/Kvantum $(kde)/aurorae/themes
	cp -a plasma/look-and-feel/com.github.vinceliuice.* $(kde)/plasma/look-and-feel/
	for style in WhiteSur WhiteSur-alt WhiteSur-dark WhiteSurLiquid WhiteSurLiquid-dark; do \
		cp -a "plasma/desktoptheme/$$style" $(kde)/plasma/desktoptheme/ || exit 1; \
		cp -a plasma/desktoptheme/icons plasma/desktoptheme/weather "$(kde)/plasma/desktoptheme/$$style/" || exit 1; \
	done
	install -m 0644 color-schemes/*.colors $(kde)/color-schemes/
	cp -a Kvantum/WhiteSur $(kde)/Kvantum/
	for name in WhiteSur WhiteSurLiquid; do \
		for color in "" -dark; do \
			for scale in "" _x1.25 _x1.5 _x1.75 _x2.0; do \
				theme="$(kde)/aurorae/themes/$$name$$color$$scale"; \
				install -d "$$theme" || exit 1; \
				install -m 0644 "aurorae/main/$$name$$color$$scale/decoration.svg" aurorae/common/assets$$color/*.svg \
					aurorae/metadata.desktop aurorae/metadata.json "$$theme/" || exit 1; \
				install -m 0644 "aurorae/main/$$name$${color}rc" "$$theme/$$name$$color$${scale}rc" || exit 1; \
				sed -i "s/WhiteSur/$$name$$color$$scale/g" "$$theme/metadata.desktop" "$$theme/metadata.json" || exit 1; \
			done; \
		done; \
	done
	install -d $(sddm)
	cp -a sddm/WhiteSur-6.2/. $(sddm)/
	rm -f $(sddm)/theme.conf.user
