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

const hasPlasmaIntegration = GLib.find_program_in_path("plasma-browser-integration-host") !== null;

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"));