🚧 Start port to ESM

This commit is contained in:
Simon Schneegans
2023-07-12 09:59:53 +02:00
parent 3a03c86fbc
commit 8a0c29a52f
30 changed files with 266 additions and 356 deletions
+5 -6
View File
@@ -12,15 +12,14 @@
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
// SPDX-License-Identifier: GPL-3.0-or-later
'use strict';
//'use strict';
const {Gio, GLib, GObject} = imports.gi;
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
//////////////////////////////////////////////////////////////////////////////////////////
// Burn-My-Windows allows applying different sets of effect settings under specific //
@@ -31,7 +30,7 @@ const utils = Me.imports.src.utils;
// via Gio.Settings objects. //
//////////////////////////////////////////////////////////////////////////////////////////
var ProfileManager = class {
export class ProfileManager {
// ------------------------------------------------------------------------- constructor
constructor() {
+10 -17
View File
@@ -14,13 +14,13 @@
'use strict';
const {Gio, Shell, GObject, Clutter, Meta} = imports.gi;
const ByteArray = imports.byteArray;
import Gio from 'gi://Gio';
import Shell from 'gi://Shell';
import GObject from 'gi://GObject';
import Clutter from 'gi://Clutter';
import Meta from 'gi://Meta';
const Main = imports.ui.main;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
import {shellVersionIsAtLeast, getStringResource} from './utils.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This is the base class for all shaders of Burn-My-Windows. It automagically loads //
@@ -47,7 +47,7 @@ const utils = Me.imports.src.utils;
// used to clean up any resources.
//////////////////////////////////////////////////////////////////////////////////////////
var Shader = GObject.registerClass(
export var Shader = GObject.registerClass(
{
Signals: {
'begin-animation': {
@@ -186,7 +186,7 @@ var Shader = GObject.registerClass(
// to undo this. It is a pity that we have to do this here, as it is not really
// required to be done each frame. But it's the only place where we can do it.
// https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2650
if (utils.shellVersionIsAtLeast(44, 2)) {
if (shellVersionIsAtLeast(44, 2)) {
this.get_pipeline().set_blend(
'RGBA = ADD (SRC_COLOR * (SRC_COLOR[A]), DST_COLOR * (1-SRC_COLOR[A]))');
}
@@ -197,18 +197,11 @@ var Shader = GObject.registerClass(
// --------------------------------------------------------------------- private stuff
// This loads the file at 'path' contained in the extension's resources to a
// JavaScript string.
_loadStringResource(path) {
const data = Gio.resources_lookup_data(path, 0);
return ByteArray.toString(ByteArray.fromGBytes(data));
}
// This loads a GLSL file from the extension's resources to a JavaScript string. The
// code from "common.glsl" is prepended automatically.
_loadShaderResource(path) {
let common = this._loadStringResource('/shaders/common.glsl');
let code = this._loadStringResource(path);
let common = getStringResource('/shaders/common.glsl');
let code = getStringResource(path);
// Add a trailing newline. Else the GLSL compiler complains...
return common + '\n' + code + '\n';
+4 -6
View File
@@ -14,10 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
import GObject from 'gi://GObject';
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
import {Shader} from './Shader.js';
//////////////////////////////////////////////////////////////////////////////////////////
// Each effect of Burn-My-Windows owns an instance of this class. It is used to created //
@@ -25,7 +24,7 @@ const Me = imports.misc.extensionUtils.getCurrentExtension();
// possible in order to avoid memory leaks. //
//////////////////////////////////////////////////////////////////////////////////////////
var ShaderFactory = class {
export class ShaderFactory {
// Creates a new ShaderFactory. Requires the nick of the effect and a callback function
// which will be called whenever a new shader is created.
@@ -62,8 +61,7 @@ var ShaderFactory = class {
// Only try to register the new type once.
if (GObject.type_from_name(typeName) == null) {
const outerThis = this;
GObject.registerClass({GTypeName: typeName},
class Shader extends Me.imports.src.Shader.Shader {
GObject.registerClass({GTypeName: typeName}, class ShaderImp extends Shader {
// This will actually load the GLSL source code from the resources.
_init() {
super._init(outerThis._nick);
+7 -6
View File
@@ -15,12 +15,13 @@
'use strict';
const {Gio, GLib} = imports.gi;
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
const Main = imports.ui.main;
const LookingGlass = imports.ui.lookingGlass;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
import {getStringResource} from './utils.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This is based on the window-picking functionality of the Blur-My-Shell extension. //
@@ -29,12 +30,12 @@ const utils = Me.imports.src.utils;
// picking. //
//////////////////////////////////////////////////////////////////////////////////////////
var WindowPicker = class WindowPicker {
export class WindowPicker {
// ------------------------------------------------------------------------- constructor
constructor() {
const iFace = utils.getStringResource(
'/interfaces/org.gnome.shell.extensions.burn-my-windows.xml');
const iFace =
getStringResource('/interfaces/org.gnome.shell.extensions.burn-my-windows.xml');
this._dbus = Gio.DBusExportedObject.wrapJSObject(iFace, this);
}
+2 -5
View File
@@ -16,10 +16,7 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by violently sucking it into the void of magic. //
@@ -28,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Apparition = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -5
View File
@@ -16,10 +16,7 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect shatters the window into pieces. For an explanation how this works, look //
@@ -40,7 +37,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var BrokenGlass = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect melts your windows. Inspired by the legendary screen transitions of the //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Doom = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TOS. //
@@ -30,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var EnergizeA = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TNG. //
@@ -30,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var EnergizeB = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+3 -7
View File
@@ -14,14 +14,11 @@
'use strict';
const {Gio} = imports.gi;
import Gio from 'gi://Gio';
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect is a homage to the good old Compiz days. However, it is implemented //
@@ -34,8 +31,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Fire = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect fades the window to transparency with subtle 3D effects. //
@@ -30,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Glide = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect applies some intentional graphics issues to your windows. //
@@ -30,7 +25,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Glitch = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect overlays a glowing hexagonal grid over the window. The grid cells then //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Hexagon = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect burns windows to ashes. The fire starts at a random position at the //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Incinerate = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// The Matrix shader multiplies a grid of random letters with some gradients which are //
@@ -34,7 +29,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Matrix = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect paints your windows with a thick paint brush. //
@@ -32,7 +27,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var PaintBrush = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This simple effect pixelates the window texture and hides the pixels in a wheel-like //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var PixelWheel = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect pixelates the window texture and hides the pixels radially, starting //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var PixelWipe = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect pixelates the window texture and randomly hides pixels until //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Pixelate = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This ridiculous effect teleports your windows from and to alternative dimensions. //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Portal = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effects dissolves your windows into a cloud of dust. For this, it uses an //
@@ -36,7 +31,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var SnapOfDisintegration = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect tears your windows apart with a series of violent scratches! //
@@ -32,7 +27,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var TRexAttack = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by making it first transparent from top and bottom //
@@ -32,7 +27,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var TVEffect = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect combines the Glitch and the TV Effect. Credits go to Kurt Wilson //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var TVGlitch = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+2 -7
View File
@@ -14,14 +14,9 @@
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
import {ShaderFactory} from '../ShaderFactory.js';
//////////////////////////////////////////////////////////////////////////////////////////
// This effect lets your windows be carried to the realm of dreams by some little //
@@ -31,7 +26,7 @@ const ShaderFactory = Me.imports.src.ShaderFactory.ShaderFactory;
// The effect class can be used to get some metadata (like the effect's name or supported
// GNOME Shell versions), to initialize the respective page of the settings dialog, as
// well as to create the actual shader for the effect.
var Wisps = class {
export default class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
+26 -29
View File
@@ -14,18 +14,15 @@
'use strict';
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const ProfileManager = Me.imports.src.ProfileManager.ProfileManager;
const utils = Me.imports.src.utils;
import {ProfileManager} from './ProfileManager.js';
import {debug, executeCommand} from './utils.js';
// Migrating from pre-27 versions is pretty involved. Before, all settings were stored in
// the standard Gio.Settings backend. Now, there are effect profiles. Depending on the
// settings one or two profiles may be required.
async function fromVersion26() {
return utils
.executeCommand(['dconf', 'dump', '/org/gnome/shell/extensions/burn-my-windows/'])
.catch(r => utils.debug('Failed to get old settings for effect migration: ' + r))
export async function fromVersion26() {
return executeCommand(['dconf', 'dump', '/org/gnome/shell/extensions/burn-my-windows/'])
.catch(r => debug('Failed to get old settings for effect migration: ' + r))
.then(r => {
// If there were no settings before, we do not have to migrate anything. Just use
// the new defaults.
@@ -33,7 +30,7 @@ async function fromVersion26() {
return;
}
utils.debug('Starting Burn-My-Windows profile migration (old version <= 26)!');
debug('Starting Burn-My-Windows profile migration (old version <= 26)!');
// We use this to write the new profiles.
const profileManager = new ProfileManager();
@@ -41,19 +38,19 @@ async function fromVersion26() {
// The default value of this was false, so not-present is equal to false.
const destroyDialogs = r.includes('destroy-dialogs=true');
if (!destroyDialogs) {
utils.debug('Only normal windows will be burned by the new profile(s).');
debug('Only normal windows will be burned by the new profile(s).');
}
// The default value of this was false, so not-present is equal to false.
const disableOnBattery = r.includes('disable-on-battery=true');
if (disableOnBattery) {
utils.debug('The new profile(s) will not be active on battery.');
debug('The new profile(s) will not be active on battery.');
}
// The default value of this was false, so not-present is equal to false.
const disableOnPowerSave = r.includes('disable-on-power-save=true');
if (disableOnPowerSave) {
utils.debug('The new profile(s) will not be active in power-save mode.');
debug('The new profile(s) will not be active in power-save mode.');
}
// Remove some unnecessary lines.
@@ -88,21 +85,21 @@ async function fromVersion26() {
}
// Print all effects we've found.
utils.debug('Enabled open effects: ' + openEffects);
utils.debug('Enabled close effects: ' + closeEffects);
debug('Enabled open effects: ' + openEffects);
debug('Enabled close effects: ' + closeEffects);
// If the same effects were used for opening and closing windows or there is either
// no opening or no closing animation configured, only one profile is required. Else
// we have to create two new profiles.
const numProfiles = openEffects.join() == closeEffects.join() ? 1 : 2;
if (numProfiles == 1) {
utils.debug('Only one profile is required.');
debug('Only one profile is required.');
} else if (closeEffects.length == 0) {
utils.debug('Only a window-open profile is required.');
debug('Only a window-open profile is required.');
} else if (openEffects.length == 0) {
utils.debug('Only a window-close profile is required.');
debug('Only a window-close profile is required.');
} else {
utils.debug('Two profiles are required.');
debug('Two profiles are required.');
}
// Remove all open / close lines.
@@ -143,8 +140,8 @@ async function fromVersion26() {
// Print and save the new profile.
const profile = profileLines.join('\n');
utils.debug('The new profile:');
utils.debug(profile);
debug('The new profile:');
debug(profile);
profileManager.createProfile(profile);
@@ -165,8 +162,8 @@ async function fromVersion26() {
// Print and save the new profile.
const profile = profileLines.join('\n');
utils.debug('The new window-open profile:');
utils.debug(profile);
debug('The new window-open profile:');
debug(profile);
profileManager.createProfile(profile);
@@ -187,8 +184,8 @@ async function fromVersion26() {
// Print and save the new profile.
const profile = profileLines.join('\n');
utils.debug('The new window-close profile:');
utils.debug(profile);
debug('The new window-close profile:');
debug(profile);
profileManager.createProfile(profile);
@@ -216,14 +213,14 @@ async function fromVersion26() {
const openProfile = openProfileLines.join('\n');
const closeProfile = closeProfileLines.join('\n');
utils.debug('The new open-window profile:');
utils.debug(openProfile);
utils.debug('The new close-window profile:');
utils.debug(closeProfile);
debug('The new open-window profile:');
debug(openProfile);
debug('The new close-window profile:');
debug(closeProfile);
profileManager.createProfile(openProfile);
profileManager.createProfile(closeProfile);
}
})
.catch(r => utils.debug('Failed to migrate settings: ' + r));
.catch(r => debug('Failed to migrate settings: ' + r));
}
+14 -15
View File
@@ -14,13 +14,14 @@
'use strict';
const {Gtk, Gio} = imports.gi;
const ByteArray = imports.byteArray;
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import GLib from 'gi://GLib';
// libadwaita is available starting with GNOME Shell 42.
let Adw = null;
try {
Adw = imports.gi.Adw;
Adw = await import('gi://Adw');
} catch (e) {
// Nothing to do.
}
@@ -39,12 +40,10 @@ function toNumericVersion(x) {
return x;
}
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Config = imports.misc.config;
const [GS_MAJOR, GS_MINOR] = Config.PACKAGE_VERSION.split('.').map(toNumericVersion);
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const _ = imports.gettext.domain('burn-my-windows').gettext;
// This method can be used to write a message to GNOME Shell's log. This is enhances
@@ -54,7 +53,7 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
// journalctl -f -o cat | grep -E 'particle-effects|'
// This method is based on a similar script from the Fly-Pie GNOME Shell extension which
// os published under the MIT License (https://github.com/Schneegans/Fly-Pie).
function debug(message) {
export function debug(message) {
const stack = new Error().stack.split('\n');
// Remove debug() function call from stack.
@@ -68,31 +67,31 @@ function debug(message) {
}
// This method simply returns true if we are currently using GTK4.
function isGTK4() {
export function isGTK4() {
return Gtk.get_major_version() == 4;
}
// Starting with GNOME Shell 42, the settings dialog uses libadwaita (at least most of
// the time - it seems that pop!_OS does not support libadwaita even on GNOME 42).
function isADW() {
export function isADW() {
return Adw && shellVersionIsAtLeast(42, 'beta');
}
// This method returns 'gtk3', 'gtk4', or 'adw' depending on the currently used GTK / and
// or libadwaita version.
function getUIDir() {
export function getUIDir() {
return isADW() ? 'adw' : (isGTK4() ? 'gtk4' : 'gtk3');
}
// This method returns true if the current GNOME Shell version matches the given
// arguments.
function shellVersionIs(major, minor) {
export function shellVersionIs(major, minor) {
return GS_MAJOR == major && GS_MINOR == toNumericVersion(minor);
}
// This method returns true if the current GNOME Shell version is at least as high as the
// given arguments. Supports "alpha" and "beta" for the minor version number.
function shellVersionIsAtLeast(major, minor) {
export function shellVersionIsAtLeast(major, minor) {
if (GS_MAJOR > major) {
return true;
}
@@ -106,9 +105,9 @@ function shellVersionIsAtLeast(major, minor) {
// Reads the contents of a file contained in the global resources archive. The data
// is returned as a string.
function getStringResource(path) {
export function getStringResource(path) {
const data = Gio.resources_lookup_data(path, 0);
return ByteArray.toString(ByteArray.fromGBytes(data));
return new TextDecoder().decode(data.get_data());
}
// Executes a command asynchronously and returns the output from 'stdout' on success or
@@ -116,7 +115,7 @@ function getStringResource(path) {
// 'stdin' and cancellable can be used to stop the process before it finishes.
// This is directly taken from here:
// https://gjs.guide/guides/gio/subprocesses.html#complete-examples
async function executeCommand(argv, input = null, cancellable = null) {
export async function executeCommand(argv, input = null, cancellable = null) {
let cancelId = 0;
let flags = (Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE);