From 224672f19b7e39d5cf5c5a987aff2ff959427c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Wed, 15 Nov 2023 12:29:31 +0100 Subject: [PATCH] Add support for Gnome 45, drop support for Gnome < 44 Because of their switch to standard JavaScript modules (ESM) that break support for older versions. See: https://blogs.gnome.org/shell-dev/2023/09/02/extensions-in-gnome-45/ https://gjs.guide/extensions/upgrading/gnome-shell-45.html --- README.md | 5 +++++ extension.js | 22 ++++++++++------------ metadata.json | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2d6c5a3..d3ce8b8 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,11 @@ In case it doesn't work, you may need to add your gnome version in gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell/Extensions/GnomeMagicWindow --method org.gnome.Shell.Extensions.GnomeMagicWindow.magic_key_pressed Terminator terminator ``` +## For Gnome versions < 45 + +Use this repo on commit b640974 or before, and read the README file from that +version. + ## For Gnome versions < 41 Use this repo on commit 26230da or before, and read the README file from that diff --git a/extension.js b/extension.js index 256e95f..f7e00ad 100644 --- a/extension.js +++ b/extension.js @@ -27,14 +27,16 @@ const BINDINGS = [ // }, ]; -const { Gio } = imports.gi; -const Main = imports.ui.main; -const Mainloop = imports.mainloop; -const Meta = imports.gi.Meta; -const Shell = imports.gi.Shell; -const Util = imports.misc.util; - -class Extension { +import Gio from 'gi://Gio'; +import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js'; +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +const Mainloop = imports.mainloop +import Meta from 'gi://Meta'; // const Meta = imports.gi.Meta; //TODO +import Shell from 'gi://Shell'; +import * as Util from 'resource:///org/gnome/shell/misc/util.js'; + + +export default class GnomeMagicWindowExtension extends Extension { enable() { this._dbus = Gio.DBusExportedObject.wrapJSObject(` @@ -129,7 +131,3 @@ class Extension { } } } - -function init() { - return new Extension(); -} diff --git a/metadata.json b/metadata.json index eacc3b9..5de0d9e 100644 --- a/metadata.json +++ b/metadata.json @@ -3,5 +3,5 @@ "description": "Bind a key to a specific program in Gnome Shell", "uuid": "gnome-magic-window@adrienverge", "url": "https://github.com/adrienverge/gnome-magic-window", - "shell-version": ["40", "41", "42", "43", "44"] + "shell-version": ["45"] }