♻️ refactor(bar/media): move icon-getting method to a function in utils.ts

This commit is contained in:
retrozinndev
2025-07-25 19:09:56 -03:00
parent 3b59243cdc
commit 627ed101e0
2 changed files with 13 additions and 7 deletions
+10
View File
@@ -2,6 +2,7 @@ import { createPoll } from "ags/time";
import { exec, execAsync } from "ags/process";
import { Accessor, For, With } from "ags";
import { Astal, Gtk } from "ags/gtk4";
import { getSymbolicIcon } from "./apps";
import GLib from "gi://GLib?version=2.0";
import Gio from "gi://Gio?version=2.0";
@@ -24,6 +25,15 @@ export function getHyprlandVersion(): string {
return exec(`${GLib.getenv("HYPRLAND_CMD") ?? "Hyprland"} --version | head -n1`).split(" ")[1];
}
export function getPlayerIconFromBusName(busName: string): string {
const splitName = busName.split('.').filter(str => str !== "" &&
!str.toLowerCase().includes('instance'));
return getSymbolicIcon(splitName[splitName.length - 1]) ?
getSymbolicIcon(splitName[splitName.length - 1])!
: "folder-music-symbolic";
}
export function escapeUnintendedMarkup(input: string): string {
return input.replace(/(?<!<[^>]*)[<>&"]/g, (s) => {
switch(s) {