* fix: display media total length on bar * fix: add option to display custom nomedia text * feat: add dedicated label too * fix: media add more window names for playables * fix: add option to control display time * Consolidate code and make tooltip timestamp for media bar opt-in. --------- Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
59 lines
2.2 KiB
TypeScript
59 lines
2.2 KiB
TypeScript
const media = await Service.import('mpris');
|
|
import { MediaInfo } from './title/index.js';
|
|
import { Controls } from './controls/index.js';
|
|
import { Bar } from './timebar/index.js';
|
|
import options from 'options.js';
|
|
import { BoxWidget } from 'lib/types/widget.js';
|
|
import { generateAlbumArt, getPlayerInfo, initializeActivePlayerHook } from './helpers.js';
|
|
import { Time } from './timelabel/index.js';
|
|
|
|
const { tint, color } = options.theme.bar.menus.menu.media.card;
|
|
const { displayTime } = options.menus.media;
|
|
|
|
initializeActivePlayerHook();
|
|
|
|
const Media = (): BoxWidget => {
|
|
return Widget.Box({
|
|
class_name: 'menu-section-container',
|
|
children: [
|
|
Widget.Box({
|
|
class_name: 'menu-items-section',
|
|
vertical: false,
|
|
child: Widget.Box({
|
|
class_name: 'menu-content',
|
|
child: Widget.Box({
|
|
class_name: 'media-content',
|
|
child: Widget.Box({
|
|
class_name: 'media-indicator-right-section',
|
|
hpack: 'fill',
|
|
hexpand: true,
|
|
vertical: true,
|
|
children: displayTime.bind('value').as((showTime) => {
|
|
return [MediaInfo(), Controls(), Bar(), ...(showTime ? [Time()] : [])];
|
|
}),
|
|
}),
|
|
}),
|
|
setup: (self) => {
|
|
self.hook(media, () => {
|
|
const curPlayer = getPlayerInfo();
|
|
|
|
if (curPlayer !== undefined) {
|
|
self.css = generateAlbumArt(curPlayer.track_cover_url);
|
|
}
|
|
});
|
|
|
|
Utils.merge([color.bind('value'), tint.bind('value')], () => {
|
|
const curPlayer = getPlayerInfo();
|
|
if (curPlayer !== undefined) {
|
|
self.css = generateAlbumArt(curPlayer.track_cover_url);
|
|
}
|
|
});
|
|
},
|
|
}),
|
|
}),
|
|
],
|
|
});
|
|
};
|
|
|
|
export { Media };
|