Files
custum-hyprpanel/modules/menus/media/components/title/author/index.ts
Jas Singh 14654998ea Clean up media module logic and code. (#380)
* Organized media menu code

* More consolidation
2024-10-27 00:17:51 -07:00

37 lines
1.3 KiB
TypeScript

const media = await Service.import('mpris');
import { BoxWidget } from 'lib/types/widget';
import { getPlayerInfo } from '../../helpers';
export const songAuthor = (): BoxWidget => {
return Widget.Box({
class_name: 'media-indicator-current-song-author',
hpack: 'center',
children: [
Widget.Label({
truncate: 'end',
wrap: true,
max_width_chars: 35,
class_name: 'media-indicator-current-song-author-label',
setup: (self) => {
self.hook(media, () => {
const curPlayer = getPlayerInfo();
const makeArtistList = (trackArtists: string[]): string => {
if (trackArtists.length === 1 && !trackArtists[0].length) {
return '-----';
}
return trackArtists.join(', ');
};
return (self.label =
curPlayer !== undefined && curPlayer['track_artists'].length
? makeArtistList(curPlayer['track_artists'])
: '-----');
});
},
}),
],
});
};