Skip to content

Commit 09dc10e

Browse files
authored
Merging utility scripts into a root Makefile (#1011)
This is a tentative change which removes a few of the shell scripts at the repo root, by merging them into a single Makefile. Feedback is welcome!
2 parents 19e6f88 + ae718bf commit 09dc10e

File tree

7 files changed

+134
-95
lines changed

7 files changed

+134
-95
lines changed

Makefile

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ Clone the repo and check out the branch for the Gnome Shell version you're runni
2727
- 40-41 ([EOL](https://release.gnome.org/calendar/#releases)): https://github.com/paperwm/PaperWM/tree/gnome-40
2828
- 3.28-3.38 ([EOL](https://release.gnome.org/calendar/#releases)): https://github.com/paperwm/PaperWM/tree/gnome-3.38
2929

30-
then run the [`install.sh`](https://github.com/paperwm/PaperWM/blob/release/install.sh) script
30+
then run the [`make install`](https://github.com/paperwm/PaperWM/blob/release/install.sh)
3131
from the repository. The installer will create a link to the repo in
3232
`~/.local/share/gnome-shell/extensions`. It will then ask if you want to enable PaperWM.
3333
```bash
34-
./install.sh # install, load and enable paperwm
34+
make install # install, load and enable paperwm
3535
```
36+
37+
Running the extension will automatically install a user config file as described in [User configuration & development](#user-configuration--development).
38+
3639
> #### ➡️ You'll need to restart Gnome shell after installing PaperWM, e.g. logout then login, or restart in place with an `alt-F2` and entering `r` (X11 only).
3740
>
3841
> After logging back in, you can then enable PaperWM via the `Extensions` application, or by running the following command from the command-line:
@@ -44,10 +47,7 @@ from the repository. The installer will create a link to the repo in
4447
4548
#### Uninstall PaperWM (if installed via source)
4649

47-
To uninstall simply run `./uninstall.sh`.
48-
49-
Running the extension will automatically install a user config file as described in [User configuration & development](#user-configuration--development).
50-
50+
To uninstall simply run `make uninstall`.
5151

5252
### Try without installing
5353

default.nix

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,11 @@ stdenv.mkDerivation {
88
version = "unstable";
99
src = ./.;
1010

11+
makeFlags = [ "SOURCE=$(src)" "EXT_DIR=$(out)/share/gnome-shell/extensions" ];
12+
1113
nativeBuildInputs = with pkgs;
1214
[ glib
1315
];
14-
buildPhase = ''
15-
make -C schemas gschemas.compiled
16-
'';
17-
18-
installPhase = ''
19-
mkdir -p $out/share/gnome-shell/extensions
20-
cp -r -T . $out/share/gnome-shell/extensions/${uuid}
21-
'';
2216

2317
passthru = {
2418
extensionPortalSlug = "paperwm";

generate-extension-zip.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

install.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

lib.mk

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# COLORS
2+
GREEN := $(shell tput setaf 2 2>/dev/null)
3+
YELLOW := $(shell tput setaf 3 2>/dev/null)
4+
BOLD := $(shell tput bold 2>/dev/null)
5+
RESET := $(shell tput sgr0 2>/dev/null)
6+
7+
define rich_echo
8+
printf "${BOLD}$(1)${RESET}\t$(2)\n"
9+
endef
10+
11+
12+
TARGET_MAX_CHAR_NUM=20
13+
## Show this message
14+
help:
15+
@echo ''
16+
@echo 'Usage:'
17+
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
18+
@echo ''
19+
@echo 'Targets:'
20+
@awk '/^[a-zA-Z\-_0-9]+:/ { \
21+
helpMessage = match(lastLine, /^## (.*)/); \
22+
if (helpMessage) { \
23+
helpCommand = substr($$1, 0, index($$1, ":")-1); \
24+
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
25+
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
26+
} \
27+
} \
28+
{ lastLine = $$0 }' $(MAKEFILE_LIST)

uninstall.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)