♻️ Use utility method to import module in Shell process only

This commit is contained in:
Simon Schneegans
2023-09-09 06:05:15 +02:00
parent 006cc593a3
commit 767035e313
23 changed files with 76 additions and 45 deletions
+3 -3
View File
@@ -165,11 +165,11 @@ void main() {
"use strict";
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain("burn-my-windows").gettext;
import { ShaderFactory } from "../ShaderFactory.js";
import * as utils from "../utils.js";
const ShaderFactory = await utils.importInShellOnly("./ShaderFactory.js");
//////////////////////////////////////////////////////////////////////////////////////////
// This effect ... //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by violently sucking it into the void of magic. //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect shatters the window into pieces. For an explanation how this works, look //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect melts your windows. Inspired by the legendary screen transitions of the //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TOS. //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect looks a bit like the transporter effect from TNG. //
+3 -2
View File
@@ -18,8 +18,9 @@ import Gio from 'gi://Gio';
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect is a homage to the good old Compiz days. However, it is implemented //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect fades the window to transparency with subtle 3D effects. //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect applies some intentional graphics issues to your windows. //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect overlays a glowing hexagonal grid over the window. The grid cells then //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect burns windows to ashes. The fire starts at a random position at the //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// The Matrix shader multiplies a grid of random letters with some gradients which are //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect paints your windows with a thick paint brush. //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This simple effect pixelates the window texture and hides the pixels in a wheel-like //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect pixelates the window texture and hides the pixels radially, starting //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This very simple effect pixelates the window texture and randomly hides pixels until //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This ridiculous effect teleports your windows from and to alternative dimensions. //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effects dissolves your windows into a cloud of dust. For this, it uses an //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect tears your windows apart with a series of violent scratches! //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect hides the actor by making it first transparent from top and bottom //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect combines the Glitch and the TV Effect. Credits go to Kurt Wilson //
+3 -2
View File
@@ -16,8 +16,9 @@
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ShaderFactory =
typeof global !== 'undefined' ? (await import('../ShaderFactory.js'))?.default : null;
import * as utils from '../utils.js';
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
//////////////////////////////////////////////////////////////////////////////////////////
// This effect lets your windows be carried to the realm of dreams by some little //
+10
View File
@@ -35,6 +35,16 @@ export function debug(message) {
console.log('[' + stack[0].slice(extensionRoot) + '] ' + message);
}
// This method can be used to import a module in the GNOME Shell process only. This
// is useful if you want to use a module in extension.js, but not in the preferences
// process. This method returns null if it is called in the preferences process.
export async function importInShellOnly(module) {
if (typeof global !== 'undefined') {
return (await import(module)).default;
}
return null;
}
// Reads the contents of a file contained in the global resources archive. The data
// is returned as a string.
export function getStringResource(path) {