import { BarLayout, BarLayouts } from 'src/lib/types/options'; /** * Returns the bar layout configuration for a specific monitor * * @param monitor - Monitor ID number * @param layouts - Object containing layout configurations for different monitors * @returns BarLayout configuration for the specified monitor, falling back to default if not found */ export const getLayoutForMonitor = (monitor: number, layouts: BarLayouts): BarLayout => { const matchingKey = Object.keys(layouts).find((key) => key === monitor.toString()); const wildcard = Object.keys(layouts).find((key) => key === '*'); if (matchingKey) { return layouts[matchingKey]; } if (wildcard) { return layouts[wildcard]; } return { left: ['dashboard', 'workspaces', 'windowtitle'], middle: ['media'], right: ['volume', 'network', 'bluetooth', 'battery', 'systray', 'clock', 'notifications'], }; }; /** * Checks if a bar layout configuration is empty * * @param layout - Bar layout configuration to check * @returns boolean indicating if all sections of the layout are empty */ export const isLayoutEmpty = (layout: BarLayout): boolean => { const isLeftSectionEmpty = !Array.isArray(layout.left) || layout.left.length === 0; const isRightSectionEmpty = !Array.isArray(layout.right) || layout.right.length === 0; const isMiddleSectionEmpty = !Array.isArray(layout.middle) || layout.middle.length === 0; return isLeftSectionEmpty && isRightSectionEmpty && isMiddleSectionEmpty; };