summaryrefslogtreecommitdiff
path: root/utils/mpris.ts
blob: 8f6923a4390bad31024f3d7dbb78beecf7e0176d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import AstalMpris from "gi://AstalMpris";
import { inPath } from "./system";

const hasPlasmaIntegration = inPath("plasma-browser-integration-host");

export const isRealPlayer = (player?: AstalMpris.Player) =>
    player !== undefined &&
    // Player closed
    player.identity !== null &&
    // Remove unecessary native buses from browsers if there's plasma integration
    !(hasPlasmaIntegration && player.busName.startsWith("org.mpris.MediaPlayer2.firefox")) &&
    !(hasPlasmaIntegration && player.busName.startsWith("org.mpris.MediaPlayer2.chromium")) &&
    // playerctld just copies other buses and we don't need duplicates
    !player.busName.startsWith("org.mpris.MediaPlayer2.playerctld") &&
    // Non-instance mpd bus
    !(player.busName.endsWith(".mpd") && !player.busName.endsWith("MediaPlayer2.mpd"));