Skip to content

Commit 9517f86

Browse files
committed
extension.js: Fix loading of versioned xlets, xlet-settings with
inactive config files. Follow-up to 406c075 and dcc091e.
1 parent dcc091e commit 9517f86

2 files changed

Lines changed: 29 additions & 7 deletions

File tree

files/usr/share/cinnamon/cinnamon-settings/xlet-settings.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,15 @@ def load_instances(self):
274274
instance_exists = False
275275
enabled = self.gsettings.get_strv(f'enabled-{self.type}s')
276276
for definition in enabled:
277-
if self.uuid in definition and instance_id in definition.split(':'):
278-
instance_exists = True
279-
break
277+
parts = definition.split(':')
278+
if self.type == "applet" and len(parts) >= 5:
279+
if parts[3] == self.uuid and parts[4] == instance_id:
280+
instance_exists = True
281+
break
282+
elif self.type == "desklet" and len(parts) >= 2:
283+
if parts[0] == self.uuid and parts[1] == instance_id:
284+
instance_exists = True
285+
break
280286

281287
if not instance_exists:
282288
continue

js/ui/extension.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,23 +297,39 @@ function installXletImporter(extension) {
297297
// extension.dir is the actual directory containing the JS files,
298298
// which might be a versioned subdirectory (e.g., .../uuid/6.0/)
299299
// or the uuid directory itself for non-versioned xlets.
300-
let parentPath = extension.dir.get_parent().get_path();
301300
let dirName = extension.dir.get_basename();
301+
let uuidDir = extension.dir.get_parent();
302+
let parentPath, importPath;
303+
304+
// Versioned subdirectories (e.g., "6.2") start with a digit and
305+
// can't be used as importer keys directly. Navigate through the
306+
// uuid directory instead.
307+
if (dirName.match(/^[0-9]/)) {
308+
parentPath = uuidDir.get_parent().get_path();
309+
importPath = [uuidDir.get_basename(), dirName];
310+
} else {
311+
parentPath = uuidDir.get_path();
312+
importPath = [dirName];
313+
}
302314

303315
let oldSearchPath = imports.searchPath.slice();
304316
imports.searchPath = [parentPath];
305317

306318
try {
307-
extension.imports = imports[dirName];
319+
let importer = imports;
320+
for (let part of importPath) {
321+
importer = importer[part];
322+
}
323+
extension.imports = importer;
308324
} catch (e) {
309325
imports.searchPath = oldSearchPath;
310-
throw new Error(`Failed to create importer for ${extension.uuid} at ${parentPath}/${dirName}: ${e.message}`);
326+
throw new Error(`Failed to create importer for ${extension.uuid} at ${parentPath}/${importPath.join('/')}: ${e.message}`);
311327
}
312328

313329
imports.searchPath = oldSearchPath;
314330

315331
if (!extension.imports) {
316-
throw new Error(`Importer is null for ${extension.uuid} at ${parentPath}/${dirName}`);
332+
throw new Error(`Importer is null for ${extension.uuid} at ${parentPath}/${importPath.join('/')}`);
317333
}
318334
}
319335

0 commit comments

Comments
 (0)