♻️ Use more dynamic imports

This commit is contained in:
Simon Schneegans
2023-09-09 06:17:58 +02:00
parent 34a64e10fe
commit 0ccbb31d06
22 changed files with 91 additions and 69 deletions
+3
View File
@@ -169,6 +169,9 @@ const _ = imports.gettext.domain("burn-my-windows").gettext;
import * as utils from "../utils.js";
// We import the ShaderFactory only in the Shell process as it is not required in the
// preferences process. The preferences process does not create any shader instances, it
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly("./ShaderFactory.js");
//////////////////////////////////////////////////////////////////////////////////////////
+3
View File
@@ -18,6 +18,9 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
// preferences process. The preferences process does not create any shader instances, it
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
+6 -4
View File
@@ -18,7 +18,13 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect shatters the window into pieces. For an explanation how this works, look //
@@ -47,10 +53,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import these modules in this function as they are not available in the
// preferences process. This callback is only called within GNOME Shell's process.
const {Clutter, GdkPixbuf, Cogl} = imports.gi;
// Create the texture in the first call.
if (!this._shardTexture) {
const shardData = GdkPixbuf.Pixbuf.new_from_resource('/img/shards.png');
+3
View File
@@ -18,6 +18,9 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
// preferences process. The preferences process does not create any shader instances, it
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
+4 -5
View File
@@ -18,7 +18,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TOS. //
@@ -35,11 +39,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import Clutter in this function as it is not available in the preferences
// process. This creator function of the ShaderFactory is only called within GNOME
// Shell's process.
const Clutter = imports.gi.Clutter;
// Store uniform locations of newly created shaders.
shader._uColor = shader.get_uniform_location('uColor');
shader._uScale = shader.get_uniform_location('uScale');
+4 -5
View File
@@ -18,7 +18,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TNG. //
@@ -35,11 +39,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import Clutter in this function as it is not available in the preferences
// process. This creator function of the ShaderFactory is only called within GNOME
// Shell's process.
const Clutter = imports.gi.Clutter;
// Store uniform locations of newly created shaders.
shader._uColor = shader.get_uniform_location('uColor');
shader._uScale = shader.get_uniform_location('uScale');
+4 -5
View File
@@ -20,7 +20,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect is a homage to the good old Compiz days. However, it is implemented //
@@ -41,11 +45,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import Clutter in this function as it is not available in the preferences
// process. This creator function of the ShaderFactory is only called within GNOME
// Shell's process.
const Clutter = imports.gi.Clutter;
// Store all uniform locations.
shader._uGradient = [
shader.get_uniform_location('uGradient1'),
+3
View File
@@ -18,6 +18,9 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
// preferences process. The preferences process does not create any shader instances, it
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
+4 -5
View File
@@ -18,7 +18,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect applies some intentional graphics issues to your windows. //
@@ -35,11 +39,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import Clutter in this function as it is not available in the preferences
// process. This creator function of the ShaderFactory is only called within GNOME
// Shell's process.
const Clutter = imports.gi.Clutter;
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uColor = shader.get_uniform_location('uColor');
+4 -5
View File
@@ -18,7 +18,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect overlays a glowing hexagonal grid over the window. The grid cells then //
@@ -36,11 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import Clutter in this function as it is not available in the preferences
// process. This creator function of the ShaderFactory is only called within GNOME
// Shell's process.
const Clutter = imports.gi.Clutter;
// Store uniform locations of newly created shaders.
shader._uAdditiveBlending = shader.get_uniform_location('uAdditiveBlending');
shader._uSeed = shader.get_uniform_location('uSeed');
+4 -4
View File
@@ -18,7 +18,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect burns windows to ashes. The fire starts at a random position at the //
@@ -36,10 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import these modules in this function as they are not available in the
// preferences process. This callback is only called within GNOME Shell's process.
const {Clutter} = imports.gi;
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uColor = shader.get_uniform_location('uColor');
+6 -4
View File
@@ -18,7 +18,13 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// The Matrix shader multiplies a grid of random letters with some gradients which are //
@@ -39,10 +45,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import these modules in this function as they are not available in the
// preferences process. This callback is only called within GNOME Shell's process.
const {Clutter, GdkPixbuf, Cogl} = imports.gi;
// Create the texture in the first call.
if (!this._fontTexture) {
const fontData = GdkPixbuf.Pixbuf.new_from_resource('/img/matrixFont.png');
+6 -4
View File
@@ -18,7 +18,13 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect paints your windows with a thick paint brush. //
@@ -37,10 +43,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import these modules in this function as they are not available in the
// preferences process. This callback is only called within GNOME Shell's process.
const {Clutter, GdkPixbuf, Cogl} = imports.gi;
// Create the texture in the first call.
if (!this._brushTexture) {
const brushData = GdkPixbuf.Pixbuf.new_from_resource('/img/brush.png');
+3
View File
@@ -18,6 +18,9 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
// preferences process. The preferences process does not create any shader instances, it
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
+3
View File
@@ -18,6 +18,9 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
// preferences process. The preferences process does not create any shader instances, it
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
+3
View File
@@ -18,6 +18,9 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the
// preferences process. The preferences process does not create any shader instances, it
// only uses the static metadata of the effect.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
+4 -5
View File
@@ -18,7 +18,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This ridiculous effect teleports your windows from and to alternative dimensions. //
@@ -36,11 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import Clutter in this function as it is not available in the preferences
// process. This creator function of the ShaderFactory is only called within GNOME
// Shell's process.
const Clutter = imports.gi.Clutter;
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uColor = shader.get_uniform_location('uColor');
+6 -4
View File
@@ -18,7 +18,13 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// This effects dissolves your windows into a cloud of dust. For this, it uses an //
@@ -41,10 +47,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import these modules in this function as they are not available in the
// preferences process. This callback is only called within GNOME Shell's process.
const {Clutter, GdkPixbuf, Cogl} = imports.gi;
// Create the texture in the first call.
if (!this._dustTexture) {
const dustData = GdkPixbuf.Pixbuf.new_from_resource('/img/dust.png');
+6 -4
View File
@@ -18,7 +18,13 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
const GdkPixbuf = await utils.importInShellOnly('gi://GdkPixbuf');
const Cogl = await utils.importInShellOnly('gi://Cogl');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect tears your windows apart with a series of violent scratches! //
@@ -37,10 +43,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import these modules in this function as they are not available in the
// preferences process. This callback is only called within GNOME Shell's process.
const {Clutter, GdkPixbuf, Cogl} = imports.gi;
// Create the texture in the first call.
if (!this._clawTexture) {
const clawData = GdkPixbuf.Pixbuf.new_from_resource('/img/claws.png');
+4 -5
View File
@@ -18,7 +18,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by making it first transparent from top and bottom //
@@ -37,11 +41,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import Clutter in this function as it is not available in the preferences
// process. This creator function of the ShaderFactory is only called within GNOME
// Shell's process.
const Clutter = imports.gi.Clutter;
// Store uniform locations of newly created shaders.
shader._uColor = shader.get_uniform_location('uColor');
+4 -5
View File
@@ -18,7 +18,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect combines the Glitch and the TV Effect. Credits go to Kurt Wilson //
@@ -36,11 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import Clutter in this function as it is not available in the preferences
// process. This creator function of the ShaderFactory is only called within GNOME
// Shell's process.
const Clutter = imports.gi.Clutter;
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uColor = shader.get_uniform_location('uColor');
+4 -5
View File
@@ -18,7 +18,11 @@ const _ = imports.gettext.domain('burn-my-windows').gettext;
import * as utils from '../utils.js';
// We import some modules only in the Shell process as they are not available in the
// preferences process. They are used only in the creator function of the ShaderFactory
// which is only called within GNOME Shell's process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const Clutter = await utils.importInShellOnly('gi://Clutter');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect lets your windows be carried to the realm of dreams by some little //
@@ -36,11 +40,6 @@ export default class Effect {
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// We import Clutter in this function as it is not available in the preferences
// process. This creator function of the ShaderFactory is only called within GNOME
// Shell's process.
const Clutter = imports.gi.Clutter;
// Store uniform locations of newly created shaders.
shader._uSeed = shader.get_uniform_location('uSeed');
shader._uScale = shader.get_uniform_location('uScale');