diff --git a/lib/types/options.d.ts b/lib/types/options.d.ts index e9dd76d..beb31f3 100644 --- a/lib/types/options.d.ts +++ b/lib/types/options.d.ts @@ -215,6 +215,3 @@ export type ColorMapKey = keyof typeof defaultColorMap; export type ColorMapValue = (typeof defaultColorMap)[ColorMapKey]; export type ScalingPriority = 'gdk' | 'hyprland' | 'both'; - -export type IgnoredWorkspace = number | string; -export type IgnoredWorkspaces = IgnoredWorkspace[]; diff --git a/modules/bar/workspaces/helpers.ts b/modules/bar/workspaces/helpers.ts index 9e3642e..0e0229d 100644 --- a/modules/bar/workspaces/helpers.ts +++ b/modules/bar/workspaces/helpers.ts @@ -1,6 +1,5 @@ const hyprland = await Service.import('hyprland'); -import { IgnoredWorkspace, IgnoredWorkspaces } from 'lib/types/options'; import { MonitorMap, WorkspaceMap, WorkspaceRule } from 'lib/types/workspace'; import options from 'options'; import { Variable } from 'types/variable'; @@ -72,28 +71,19 @@ type ThrottledScrollHandlers = { throttledScrollDown: () => void; }; -export const isWorkspaceIgnored = ( - ignoredWorkspaces: Variable, - workspaceNumber: number, -): boolean => { - const ignoredValues = ignoredWorkspaces.value; +export const isWorkspaceIgnored = (ignoredWorkspaces: Variable, workspaceNumber: number): boolean => { + if (ignoredWorkspaces.value === '') return false; - return ignoredValues.some((ignore: IgnoredWorkspace) => { - if (typeof ignore === 'number') { - return ignore === workspaceNumber; - } - if (typeof ignore === 'string') { - return new RegExp(ignore).test(workspaceNumber.toString()); - } - return true; - }); + const ignoredWsRegex = new RegExp(ignoredWorkspaces.value); + + return ignoredWsRegex.test(workspaceNumber.toString()); }; const navigateWorkspace = ( direction: 'next' | 'prev', currentMonitorWorkspaces: Variable, activeWorkspaces: boolean, - ignoredWorkspaces: Variable, + ignoredWorkspaces: Variable, ): void => { const workspacesList = activeWorkspaces ? hyprland.workspaces.filter((ws) => hyprland.active.monitor.id === ws.monitorID).map((ws) => ws.id) @@ -120,7 +110,7 @@ const navigateWorkspace = ( export const goToNextWS = ( currentMonitorWorkspaces: Variable, activeWorkspaces: boolean, - ignoredWorkspaces: Variable, + ignoredWorkspaces: Variable, ): void => { navigateWorkspace('next', currentMonitorWorkspaces, activeWorkspaces, ignoredWorkspaces); }; @@ -128,7 +118,7 @@ export const goToNextWS = ( export const goToPrevWS = ( currentMonitorWorkspaces: Variable, activeWorkspaces: boolean, - ignoredWorkspaces: Variable, + ignoredWorkspaces: Variable, ): void => { navigateWorkspace('prev', currentMonitorWorkspaces, activeWorkspaces, ignoredWorkspaces); }; diff --git a/options.ts b/options.ts index 2b84bd3..c2a2f60 100644 --- a/options.ts +++ b/options.ts @@ -13,7 +13,6 @@ import { ActiveWsIndicator, BarButtonStyles, BarLocation, - IgnoredWorkspaces, NotificationAnchor, OSDAnchor, OSDOrientation, @@ -862,7 +861,7 @@ const options = mkOptions(OPTIONS, { }, workspaces: { show_icons: opt(false), - ignored: opt([]), + ignored: opt(''), show_numbered: opt(false), showWsIcons: opt(false), numbered_active_indicator: opt('underline'), diff --git a/widget/settings/pages/config/bar/index.ts b/widget/settings/pages/config/bar/index.ts index e5eb5dc..7dd3a80 100644 --- a/widget/settings/pages/config/bar/index.ts +++ b/widget/settings/pages/config/bar/index.ts @@ -300,10 +300,8 @@ export const BarSettings = (): Scrollable => { Option({ opt: options.bar.workspaces.ignored, title: 'Ignored Workspaces', - subtitle: - 'An array of workspace numbers to ignore.\n' + - 'A regular expression can be passed in the array to ignore workspaces that match the regex.', - type: 'object', + subtitle: 'A regex that defines workspaces to ignore', + type: 'string', }), /*