Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
98 changes: 98 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
ifdef $$XDG_DATA_HOME
XDG_DATA_HOME := $$XDG_DATA_HOME
else
XDG_DATA_HOME := ${HOME}/.local/share
endif

SOURCE := $$PWD
EXT_ID := [email protected]
EXT_DIR := $(XDG_DATA_HOME)/gnome-shell/extensions
TARGET := $(EXT_DIR)/$(EXT_ID)

CONFIG_FILES = config/user.js config/user.css
GSCHEMA_FILES = schemas/org.gnome.shell.extensions.paperwm.gschema.xml
JS_FILES = $(wildcard *.js)
UI_FILES = $(wildcard *.ui)
RESOURCE_FILES = $(wildcard resources/*)

RELEASE_FILES = $(JS_FILES) $(UI_FILES) $(RESOURCE_FILES) \
$(CONFIG_FILES) $(GSCHEMA_FILES) \
schemas/gschemas.compiled \
metadata.json \
stylesheet.css \
LICENSE

ZIP := zip

ifneq (,$(shell command -v gnome-extensions))
GNOME_EXT_DISABLE := gnome-extensions disable
else
GNOME_EXT_DISABLE := gnome-shell-extension-tool --disable
endif

## Update compiled files
all: $(RELEASE_FILES)

## Install PaperWM on this system
install: schemas/gschemas.compiled
@if [[ ! -L "$(TARGET)" && -d "$(TARGET)" ]]; \
then \
echo; \
echo "INSTALL FAILED:"; \
echo; \
echo "A previous (non-symlinked) installation of PaperWM already exists at:"; \
echo "'$(TARGET)'."; \
echo; \
echo "Please remove the installed version from that path and re-run this install script."; \
echo; \
exit 1; \
fi
@$(call rich_echo,"MKDIR","$(EXT_DIR)")
@mkdir -p $(EXT_DIR)
@$(call rich_echo,"LINK","$(EXT_ID)")
@ln -snf $(SOURCE) $(TARGET)
@echo
@echo "INSTALL SUCCESSFUL:"
@echo
@echo "If this is the first time installing PaperWM, then please logout/login"
@echo "and enable the PaperWM extension, either with the GNOME Extensions application,"
@echo "or manually by executing the following command from a terminal:"
@echo
@echo "gnome-extensions enable $(EXT_ID)"
@echo

## Uninstall PaperWM from this system
uninstall:
@$(call rich_echo,"GNOME_EXT_DISABLE", "$(EXT_ID)")
@$(GNOME_EXT_DISABLE) $(EXT_ID)
@if [[ `readlink -f $(TARGET)` != `readlink -f $$PWD` ]]; \
then \
echo "'$(TARGET)' does not link to '$$PWD', refusing to remove."; \
exit 1 \
fi
@if [ -L $(TARGET) ]; \
then \
$(call rich_echo,"RM", "$(TARGET)") \
rm $(EXT); \
else \
read -p "Remove $(TARGET)? (y/N): " -n 1 -r \
echo \
[[ $$REPLY =~ ^[Yy]$ ]] && rm -rf $(TARGET) \
fi


## Generate a release zip for review on GNOME Extensions
release: $(EXT_ID).zip


$(EXT_ID).zip: $(RELEASE_FILES)
@$(call rich_echo,"ZIP","$@")
@$(ZIP) -r $@ $^

schemas/gschemas.compiled: $(GSCHEMA_FILES)
@$(call rich_echo,"MAKE","$@")
@$(MAKE) -C schemas gschemas.compiled

.PHONY: install uninstall release

include lib.mk
10 changes: 2 additions & 8 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@ stdenv.mkDerivation {
version = "unstable";
src = ./.;

makeFlags = [ "SOURCE=$(src)" "EXT_DIR=$(out)/share/gnome-shell/extensions" ];

nativeBuildInputs = with pkgs;
[ glib
];
buildPhase = ''
make -C schemas gschemas.compiled
'';

installPhase = ''
mkdir -p $out/share/gnome-shell/extensions
cp -r -T . $out/share/gnome-shell/extensions/${uuid}
'';

passthru = {
extensionPortalSlug = "paperwm";
Expand Down
15 changes: 0 additions & 15 deletions generate-extension-zip.sh

This file was deleted.

36 changes: 0 additions & 36 deletions install.sh

This file was deleted.

28 changes: 28 additions & 0 deletions lib.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# COLORS
GREEN := $(shell tput setaf 2 2>/dev/null)
YELLOW := $(shell tput setaf 3 2>/dev/null)
BOLD := $(shell tput bold 2>/dev/null)
RESET := $(shell tput sgr0 2>/dev/null)

define rich_echo
printf "${BOLD}$(1)${RESET}\t$(2)\n"
endef


TARGET_MAX_CHAR_NUM=20
## Show this message
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
30 changes: 0 additions & 30 deletions uninstall.sh

This file was deleted.