Files
custum-hyprpanel/modules/menus/media/components/title/name/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

29 lines
981 B
TypeScript

import { BoxWidget } from 'lib/types/widget';
import { getPlayerInfo } from '../../helpers';
const media = await Service.import('mpris');
export const songName = (): BoxWidget => {
return Widget.Box({
class_name: 'media-indicator-current-song-name',
hpack: 'center',
children: [
Widget.Label({
truncate: 'end',
max_width_chars: 31,
wrap: true,
class_name: 'media-indicator-current-song-name-label',
setup: (self) => {
self.hook(media, () => {
const curPlayer = getPlayerInfo();
return (self.label =
curPlayer !== undefined && curPlayer['track_title'].length
? curPlayer['track_title']
: 'No Media Currently Playing');
});
},
}),
],
});
};