diff --git a/Makefile b/Makefile index dec7c663..1a17f2a9 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ endif SOURCE := $$PWD EXT_ID := paperwm@paperwm.github.com -EXT_DIR := $(XDG_DATA_HOME)/gnome-shell/extensions +EXT_DIR := $(if $(DESTDIR),$(DESTDIR)/usr/share,$(XDG_DATA_HOME))/gnome-shell/extensions TARGET := $(EXT_DIR)/$(EXT_ID) CONFIG_FILES = config/user.js config/user.css @@ -15,11 +15,12 @@ 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 \ +EXT_FILES = $(JS_FILES) $(UI_FILES) $(RESOURCE_FILES) \ + $(CONFIG_FILES) \ + metadata.json \ + stylesheet.css +RELEASE_FILES = $(EXT_FILES) \ + $(GSCHEMA_FILES) schemas/gschemas.compiled \ LICENSE ZIP := zip @@ -33,7 +34,7 @@ endif ## Update compiled files all: $(RELEASE_FILES) -## Install PaperWM on this system +## Install PaperWM for this user install: schemas/gschemas.compiled @if [[ ! -L "$(TARGET)" && -d "$(TARGET)" ]]; \ then \ @@ -61,25 +62,33 @@ install: schemas/gschemas.compiled @echo "gnome-extensions enable $(EXT_ID)" @echo -## Uninstall PaperWM from this system +## Uninstall PaperWM for this user uninstall: @$(call rich_echo,"GNOME_EXT_DISABLE", "$(EXT_ID)") @$(GNOME_EXT_DISABLE) $(EXT_ID) - @if [[ `readlink -f $(TARGET)` != `readlink -f $$PWD` ]]; \ + @if [ -z "$(DESTDIR)" ] && [ ! `readlink -f $(TARGET)` = `readlink -f $$PWD` ]; \ then \ - echo "'$(TARGET)' does not link to '$$PWD', refusing to remove."; \ - exit 1 \ + echo "'$(TARGET)' does not link to '$$PWD' and '$(DESTDIR)' undefined,"; \ + echo "refusing to remove."; \ + exit 1; \ fi @if [ -L $(TARGET) ]; \ then \ - $(call rich_echo,"RM", "$(TARGET)") \ + $(call rich_echo,"RM", "$(TARGET)"); \ rm $(EXT); \ else \ - read -p "Remove $(TARGET)? (y/N): " -n 1 -r \ - echo \ - [[ $$REPLY =~ ^[Yy]$ ]] && rm -rf $(TARGET) \ + echo "Remove $(TARGET)? (y/N): "; \ + read REPLY; \ + [ "$$REPLY" = "Y" ] || [ "$$REPLY" = "y" ] && rm -rf $(TARGET); \ fi +## Install in system-wide location +install-system: + for f in $(EXT_FILES); do \ + install -D -p -m 0644 $$f "$(TARGET)/$$f"; \ + done + install -d "$(DESTDIR)/usr/share/glib-2.0/schemas" + install -p -m 0644 $(GSCHEMA_FILES) "$(DESTDIR)/usr/share/glib-2.0/schemas/" ## Generate a release zip for review on GNOME Extensions release: $(EXT_ID).zip @@ -93,6 +102,6 @@ schemas/gschemas.compiled: $(GSCHEMA_FILES) @$(call rich_echo,"MAKE","$@") @$(MAKE) -C schemas gschemas.compiled -.PHONY: install uninstall release +.PHONY: install install-system uninstall release include lib.mk diff --git a/README.md b/README.md index d9945c1e..a8c92160 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,7 @@ Clone the repo and check out the branch for the GNOME Shell version you're runni - 40-41 ([EOL](https://release.gnome.org/calendar/#releases)): https://github.com/paperwm/PaperWM/tree/gnome-40 - 3.28-3.38 ([EOL](https://release.gnome.org/calendar/#releases)): https://github.com/paperwm/PaperWM/tree/gnome-3.38 -then run the [`make install`](https://github.com/paperwm/PaperWM/blob/release/install.sh) -from the repository. The installer will create a link to the repo in +then run [`make install`] from the repository. The installer will create a link to the repo in `~/.local/share/gnome-shell/extensions`. It will then ask if you want to enable PaperWM. ```bash make install # install, load and enable paperwm diff --git a/schemas/Makefile b/schemas/Makefile index 7009a953..ea82e5f1 100644 --- a/schemas/Makefile +++ b/schemas/Makefile @@ -1,4 +1,2 @@ -gschemas.compiled: phony +gschemas.compiled: *.gschema.xml glib-compile-schemas . - -.PHONY: phony diff --git a/workspace.js b/workspace.js index 73fdf659..fe6de158 100644 --- a/workspace.js +++ b/workspace.js @@ -12,11 +12,22 @@ const WORKSPACE_KEY = 'org.gnome.shell.extensions.paperwm.workspace'; export class WorkspaceSettings { constructor(extension) { this.workspaceSettingsCache = {}; - this.schemaSource = Gio.SettingsSchemaSource.new_from_directory( - GLib.build_filenamev([extension.path, "schemas"]), - Gio.SettingsSchemaSource.get_default(), - false - ); + + console.debug("Extension path " + extension.dir.get_parent().get_path()); + console.debug("XDG_DATA_DIR=" + GLib.get_user_data_dir()); + if (extension.dir.get_parent().get_parent().get_parent().get_path() == GLib.get_user_data_dir()) { + console.debug("We are installed in $XDG_DATA_HOME"); + this.schemaSource = Gio.SettingsSchemaSource.new_from_directory( + GLib.build_filenamev([extension.path, "schemas"]), + Gio.SettingsSchemaSource.get_default(), + false + ); + } else { + // assume we are installed system-wide and our schema source is in + // the default schema. + console.debug("We are installed in system $PREFIX."); + this.schemaSource = Gio.SettingsSchemaSource.get_default(); + } this.workspaceList = new Gio.Settings({ settings_schema: this.getSchemaSource().lookup(WORKSPACE_LIST_KEY, true),