config/modules/home/apps/helpers/ags/cfg/modules/bar/media.js
2024-05-23 20:26:30 +00:00

21 lines
765 B
JavaScript

import { Widget, Utils, Mpris } from "../../imports.js";
const { execAsync } = Utils;
export const Media = () => Widget.Button({
class_name: 'media',
on_primary_click: () => Mpris.getPlayer('').playPause(),
onSecondaryClickRelease: () => {
execAsync(['bash', '-c', 'anyrun', '&']);
},
on_scroll_up: () => Mpris.getPlayer('').next(),
on_scroll_down: () => Mpris.getPlayer('').previous(),
child: Widget.Label('-').hook(Mpris, self => {
if (Mpris.players[0]) {
const { track_title } = Mpris.players[0];
self.label = track_title.length > 60 ? `${track_title.substring(0, 60)}...` : track_title;
} else {
self.label = 'Nothing is playing';
}
}, 'player-changed'),
});