Skip to content

Commit 36a877d

Browse files
committed
fix: Improve blacklist detection for sandboxed applications
1 parent 8cdf74f commit 36a877d

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

src/extension.js

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Extension } from "resource:///org/gnome/shell/extensions/extension.js";
1313
import PanelButton from "./helpers/shell/PanelButton.js";
1414
import PlayerProxy from "./helpers/shell/PlayerProxy.js";
1515
import { debugLog, enumValueByIndex, errorLog } from "./utils/common.js";
16-
import { getAppInfoByIdAndEntry, createDbusProxy } from "./utils/shell_only.js";
16+
import { getAppInfoByIdAndEntry, getAppByIdAndEntry, createDbusProxy } from "./utils/shell_only.js";
1717
import {
1818
PlaybackStatus,
1919
WidgetFlags,
@@ -648,18 +648,45 @@ export default class MediaControls extends Extension {
648648
}
649649

650650
/**
651+
* Checks if a player is in the user's blacklist.
652+
* Uses multiple lookup strategies to handle inconsistencies between MPRIS identities
653+
* and system desktop entries, especially for sandboxed apps (Snap/Flatpak).
654+
*
651655
* @private
652-
* @param {string} id
653-
* @param {string} entry
654-
* @returns {boolean}
656+
* @param {string} id - The MPRIS Identity (e.g., "Spotify")
657+
* @param {string} entry - The Desktop Entry name (e.g., "spotify")
658+
* @returns {boolean} - True if the player is blacklisted
655659
*/
656660
isPlayerBlacklisted(id, entry) {
657-
const app = getAppInfoByIdAndEntry(id, entry);
661+
// Standard AppInfo lookup (fastest)
662+
let app = getAppInfoByIdAndEntry(id, entry);
663+
664+
// Shell AppSystem lookup
665+
// Necessary for finding running apps that standard AppInfo misses (e.g., Snaps)
658666
if (app == null) {
659-
return false;
667+
app = getAppByIdAndEntry(id, entry);
668+
}
669+
670+
// Check if the resolved App ID matches the blacklist
671+
if (app != null) {
672+
const appId = app.get_id();
673+
if (this.blacklistedPlayers.includes(appId)) {
674+
return true;
675+
}
660676
}
661-
const appId = app.get_id();
662-
return this.blacklistedPlayers.includes(appId);
677+
678+
// Raw string fallback
679+
const checkRaw = (name) => {
680+
return (
681+
name && (this.blacklistedPlayers.includes(name) || this.blacklistedPlayers.includes(`${name}.desktop`))
682+
);
683+
};
684+
685+
if (checkRaw(entry) || checkRaw(id)) {
686+
return true;
687+
}
688+
689+
return false;
663690
}
664691

665692
/**

0 commit comments

Comments
 (0)