hyprpanel
This commit is contained in:
1 parent
10080a83ee
commit
5151ac24da
322 files changed
+38276
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { MprisPlayer } from 'types/service/mpris';
|
||||
const mpris = await Service.import('mpris');
|
||||
|
||||
export const getCurrentPlayer = (activePlayer: MprisPlayer = mpris.players[0]): MprisPlayer => {
|
||||
const statusOrder = {
|
||||
Playing: 1,
|
||||
Paused: 2,
|
||||
Stopped: 3,
|
||||
};
|
||||
|
||||
if (mpris.players.length === 0) {
|
||||
return mpris.players[0];
|
||||
}
|
||||
|
||||
const isPlaying = mpris.players.some((p: MprisPlayer) => p.play_back_status === 'Playing');
|
||||
|
||||
const playerStillExists = mpris.players.some((p) => activePlayer.bus_name === p.bus_name);
|
||||
|
||||
const nextPlayerUp = mpris.players.sort(
|
||||
(a: MprisPlayer, b: MprisPlayer) => statusOrder[a.play_back_status] - statusOrder[b.play_back_status],
|
||||
)[0];
|
||||
|
||||
if (isPlaying || !playerStillExists) {
|
||||
return nextPlayerUp;
|
||||
}
|
||||
|
||||
return activePlayer;
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Notification } from 'types/service/notifications';
|
||||
|
||||
export const filterNotifications = (notifications: Notification[], filter: string[]): Notification[] => {
|
||||
const notifFilter = new Set(filter.map((name: string) => name.toLowerCase().replace(/\s+/g, '_')));
|
||||
|
||||
const filteredNotifications = notifications.filter((notif: Notification) => {
|
||||
const normalizedAppName = notif.app_name.toLowerCase().replace(/\s+/g, '_');
|
||||
return !notifFilter.has(normalizedAppName);
|
||||
});
|
||||
|
||||
return filteredNotifications;
|
||||
};
|
||||
Reference in new issue
Block a user