Skip to content

Commit

Permalink
handle app-less mpris players
Browse files Browse the repository at this point in the history
  • Loading branch information
sakithb committed Jan 8, 2024
1 parent 5a6b0c8 commit 01f63c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/helpers/shell/PanelButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ class PanelButton extends PanelMenu.Button {
const app = getAppByIdAndEntry(player.identity, player.desktopEntry);
const isSamePlayer = this.isSamePlayer(player);

const appName = app?.get_name() ?? (player.identity || "Unknown player");
const appIcon = app?.get_icon() ?? Gio.Icon.new_for_string("audio-x-generic-symbolic");

if (isSamePlayer) {
this.menuPlayersTextBoxLabel.text = app.get_name();
this.menuPlayersTextBoxLabel.text = appName;

if (players.length > 1) {
this.menuPlayersTextBoxIcon.gicon = null;
Expand All @@ -268,7 +271,7 @@ class PanelButton extends PanelMenu.Button {

this.menuPlayersTextBox.insert_child_at_index(this.menuPlayersTextBoxPin, 1);
} else {
this.menuPlayersTextBoxIcon.gicon = app.get_icon();
this.menuPlayersTextBoxIcon.gicon = appIcon;
this.menuPlayersTextBox.insert_child_at_index(this.menuPlayersTextBoxIcon, 0);

this.menuPlayersTextBoxLabel.xAlign = Clutter.ActorAlign.START;
Expand All @@ -283,7 +286,7 @@ class PanelButton extends PanelMenu.Button {
if (players.length > 1) {
const icon = new St.Icon({
styleClass: "popup-menu-icon popup-menu-player-icons-icon",
gicon: app.get_icon(),
gicon: appIcon,
reactive: isPinned === false,
trackHover: isPinned === false,
xAlign: Clutter.ActorAlign.FILL,
Expand Down
1 change: 0 additions & 1 deletion src/utils/shell_only.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const getAppByIdAndEntry = (id: string, entry: string): Shell.App => {

if (idResults?.length > 0) {
const app = runningApps.find((app) => idResults[0].includes(app.get_id()));

if (app != null) {
return app;
}
Expand Down

0 comments on commit 01f63c3

Please sign in to comment.