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