#!/usr/bin/make -f

STAGING = $(CURDIR)/debian/staging

%:
	dh $@

override_dh_auto_build:
	mkdir -p $(STAGING)/bin
	printf '#!/bin/sh\necho "GNOME Shell 48"\n' > $(STAGING)/bin/gnome-shell
	chmod +x $(STAGING)/bin/gnome-shell
	cd $(CURDIR) && HOME=$(STAGING) PATH=$(STAGING)/bin:$(PATH) python3 install.py --all

override_dh_install:
	for variant in blue-dark blue-light gray-dark gray-light green-dark green-light \
	               purple-dark purple-light red-dark red-light yellow-dark yellow-light; do \
		pkgdir=$(CURDIR)/debian/marble-shell-theme-$$variant; \
		themedir=$$pkgdir/usr/share/themes; \
		mkdir -p $$themedir; \
		color=$$(echo $$variant | sed 's/-dark//;s/-light//'); \
		mode=$$(echo $$variant | grep -o 'dark\|light'); \
		srcname=Marble-$$color-$$mode; \
		cp -r $(STAGING)/.themes/$$srcname $$themedir/; \
	done

override_dh_auto_clean:
	rm -rf $(STAGING)
	dh_auto_clean
