summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Barisione <marco@barisione.org>2011-11-21 18:41:25 (GMT)
committerMarco Barisione <marco@barisione.org>2011-11-21 18:41:25 (GMT)
commit966982fde5fae441bfe4c8c991f6821e8f4ace49 (patch)
tree0f7690b9cca5990a77265a40f50d7d59e15d1d5b
parentf3a500859898871599cdf921a1d6752376cd2d97 (diff)
downloadshell-message-notifier-966982fde5fae441bfe4c8c991f6821e8f4ace49.tar.gz
shell-message-notifier-966982fde5fae441bfe4c8c991f6821e8f4ace49.tar.xz
Add make targets to enable/disable the extension
-rw-r--r--Makefile39
1 files changed, 38 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 01d23e7..af49ef2 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,10 @@ EXT_DIR="$(HOME)/.local/share/gnome-shell/extensions"
UUID=`cat metadata.json | grep uuid | sed -e 's/^\s*"uuid":\s*"\([^"]*\)",$$/\1/'`
FILES="README extension.js stylesheet.css metadata.json"
+SCHEMA="org.gnome.shell"
+KEY="enabled-extensions"
+STATUS=$$(gsettings get $(SCHEMA) $(KEY) | grep "$(UUID)" > /dev/null 2>&1; if [ $$? = "0" ]; then echo "enabled"; else echo "disabled"; fi)
+
all:
install:
@@ -10,9 +14,42 @@ install:
cp -f $$f $(EXT_DIR)/$(UUID)/$$f; \
done
-uninstall:
+uninstall: disable-internal
for f in "$(FILES)"; do \
rm $(EXT_DIR)/$(UUID)/$$f; \
done
rmdir $(EXT_DIR)/$(UUID)
+enable: disable-internal
+ @if [ ! -d "$(EXT_DIR)/$(UUID)" ]; then \
+ echo "Before enabling the extension you have to install it with 'make install'"; \
+ exit 1; \
+ fi
+ @curr_val=`gsettings get $(SCHEMA) $(KEY)`; \
+ full_id="'$(UUID)'"; \
+ other_extensions=`echo "$$curr_val" | sed -e "s/]$$//"`; \
+ new_val="$$other_extensions, $$full_id]"; \
+ new_val=`echo "$$new_val" | sed -e 's/\[, /[/'` ; \
+ gsettings set $(SCHEMA) $(KEY) "$$new_val"
+
+disable: disable-internal
+ @if [ $(STATUS) = "enabled" ]; then \
+ echo "I cannot disable the extension!"; \
+ exit 1; \
+ fi
+
+disable-internal:
+ @curr_val=`gsettings get $(SCHEMA) $(KEY)`; \
+ full_id="'$(UUID)'"; \
+ new_val=`echo "$$curr_val" | sed -e "s/$$full_id//"`; \
+ new_val=`echo "$$new_val" | sed -e 's/, ]/]/'` ; \
+ new_val=`echo "$$new_val" | sed -e 's/\[, /[/'` ; \
+ new_val=`echo "$$new_val" | sed -e 's/, ,/,/'` ; \
+ gsettings set $(SCHEMA) $(KEY) "$$new_val"
+
+status:
+ @if [ $(STATUS) = "enabled" ]; then \
+ echo "The extension is enabled"; \
+ else \
+ echo "The extension is disabled"; \
+ fi