|
| 1 | +ifdef $$XDG_DATA_HOME |
| 2 | +XDG_DATA_HOME := $$XDG_DATA_HOME |
| 3 | +else |
| 4 | +XDG_DATA_HOME := ${HOME}/.local/share |
| 5 | +endif |
| 6 | + |
| 7 | +SOURCE := $$PWD |
| 8 | + |
| 9 | +EXT_DIR := $(XDG_DATA_HOME)/gnome-shell/extensions |
| 10 | +TARGET := $(EXT_DIR)/$(EXT_ID) |
| 11 | + |
| 12 | +CONFIG_FILES = config/user.js config/user.css |
| 13 | +GSCHEMA_FILES = schemas/org.gnome.shell.extensions.paperwm.gschema.xml |
| 14 | +JS_FILES = $(wildcard *.js) |
| 15 | +UI_FILES = $(wildcard *.ui) |
| 16 | +RESOURCE_FILES = $(wildcard resources/*) |
| 17 | + |
| 18 | +RELEASE_FILES = $(JS_FILES) $(UI_FILES) $(RESOURCE_FILES) \ |
| 19 | + $(CONFIG_FILES) $(GSCHEMA_FILES) \ |
| 20 | + schemas/gschemas.compiled \ |
| 21 | + metadata.json \ |
| 22 | + stylesheet.css \ |
| 23 | + LICENSE |
| 24 | + |
| 25 | +ZIP := zip |
| 26 | + |
| 27 | +ifneq (,$(shell command -v gnome-extensions)) |
| 28 | +GNOME_EXT_DISABLE := gnome-extensions disable |
| 29 | +else |
| 30 | +GNOME_EXT_DISABLE := gnome-shell-extension-tool --disable |
| 31 | +endif |
| 32 | + |
| 33 | +## Update compiled files |
| 34 | +all: $(RELEASE_FILES) |
| 35 | + |
| 36 | +## Install PaperWM on this system |
| 37 | +install: schemas/gschemas.compiled |
| 38 | + @if [[ ! -L "$(TARGET)" && -d "$(TARGET)" ]]; \ |
| 39 | + then \ |
| 40 | + echo; \ |
| 41 | + echo "INSTALL FAILED:"; \ |
| 42 | + echo; \ |
| 43 | + echo "A previous (non-symlinked) installation of PaperWM already exists at:"; \ |
| 44 | + echo "'$(TARGET)'."; \ |
| 45 | + echo; \ |
| 46 | + echo "Please remove the installed version from that path and re-run this install script."; \ |
| 47 | + echo; \ |
| 48 | + exit 1; \ |
| 49 | + fi |
| 50 | + @$(call rich_echo,"MKDIR","$(EXT_DIR)") |
| 51 | + @mkdir -p $(EXT_DIR) |
| 52 | + @$(call rich_echo,"LINK","$(EXT_ID)") |
| 53 | + @ln -snf $(SOURCE) $(TARGET) |
| 54 | + @echo |
| 55 | + @echo "INSTALL SUCCESSFUL:" |
| 56 | + @echo |
| 57 | + @echo "If this is the first time installing PaperWM, then please logout/login" |
| 58 | + @echo "and enable the PaperWM extension, either with the GNOME Extensions application," |
| 59 | + @echo "or manually by executing the following command from a terminal:" |
| 60 | + @echo |
| 61 | + @echo "gnome-extensions enable $(EXT_ID)" |
| 62 | + @echo |
| 63 | + |
| 64 | +## Uninstall PaperWM from this system |
| 65 | +uninstall: |
| 66 | + @$(call rich_echo,"GNOME_EXT_DISABLE", "$(EXT_ID)") |
| 67 | + @$(GNOME_EXT_DISABLE) $(EXT_ID) |
| 68 | + @if [[ `readlink -f $(TARGET)` != `readlink -f $$PWD` ]]; \ |
| 69 | + then \ |
| 70 | + echo "'$(TARGET)' does not link to '$$PWD', refusing to remove."; \ |
| 71 | + exit 1 \ |
| 72 | + fi |
| 73 | + @if [ -L $(TARGET) ]; \ |
| 74 | + then \ |
| 75 | + $(call rich_echo,"RM", "$(TARGET)") \ |
| 76 | + rm $(EXT); \ |
| 77 | + else \ |
| 78 | + read -p "Remove $(TARGET)? (y/N): " -n 1 -r \ |
| 79 | + echo \ |
| 80 | + [[ $$REPLY =~ ^[Yy]$ ]] && rm -rf $(TARGET) \ |
| 81 | + fi |
| 82 | + |
| 83 | + |
| 84 | +## Generate a release zip for review on GNOME Extensions |
| 85 | +release: $(EXT_ID).zip |
| 86 | + |
| 87 | + |
| 88 | +$(EXT_ID).zip: $(RELEASE_FILES) |
| 89 | + @$(call rich_echo,"ZIP","$@") |
| 90 | + @$(ZIP) -r $@ $^ |
| 91 | + |
| 92 | +schemas/gschemas.compiled: $(GSCHEMA_FILES) |
| 93 | + @$(call rich_echo,"MAKE","$@") |
| 94 | + @$(MAKE) -C schemas gschemas.compiled |
| 95 | + |
| 96 | +.PHONY: install uninstall release |
| 97 | + |
| 98 | +include lib.mk |
0 commit comments