diff options
Diffstat (limited to 'users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/process.jsx')
| -rwxr-xr-x | users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/process.jsx | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/process.jsx b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/process.jsx new file mode 100755 index 0000000..0c461cc --- /dev/null +++ b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/process.jsx | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | import * as Uebersicht from "uebersicht"; | ||
| 2 | import Window from "./window.jsx"; | ||
| 3 | import * as Utils from "../../utils"; | ||
| 4 | import { useAerospaceContext } from "../aerospace-context.jsx"; | ||
| 5 | import { useSimpleBarContext } from "../simple-bar-context.jsx"; | ||
| 6 | |||
| 7 | export { processStyles as styles } from "../../styles/components/process"; | ||
| 8 | |||
| 9 | const { React } = Uebersicht; | ||
| 10 | |||
| 11 | /** | ||
| 12 | * Process component to display windows in the current space. | ||
| 13 | * @returns {JSX.Element|null} The rendered component or null if not visible. | ||
| 14 | */ | ||
| 15 | const Component = React.memo(() => { | ||
| 16 | // Get spaces from aerospace context | ||
| 17 | const { spaces } = useAerospaceContext(); | ||
| 18 | // Get settings and display index from simple bar context | ||
| 19 | const { settings, displayIndex } = useSimpleBarContext(); | ||
| 20 | const { spacesDisplay, process, widgets } = settings; | ||
| 21 | const { exclusionsAsRegex } = spacesDisplay; | ||
| 22 | const { processWidget } = widgets; | ||
| 23 | const { centered, showOnDisplay } = process; | ||
| 24 | |||
| 25 | // Determine if the component should be visible | ||
| 26 | const visible = | ||
| 27 | spaces?.length && | ||
| 28 | processWidget && | ||
| 29 | Utils.isVisibleOnDisplay(displayIndex, showOnDisplay); | ||
| 30 | |||
| 31 | if (!visible) return null; | ||
| 32 | |||
| 33 | // Find the focused space on the current display | ||
| 34 | const { windows = [] } = | ||
| 35 | spaces.find((space) => space.focused && space.monitor === displayIndex) || | ||
| 36 | {}; | ||
| 37 | |||
| 38 | if (!windows.length) return null; | ||
| 39 | |||
| 40 | // Get exclusions for filtering windows | ||
| 41 | const exclusions = exclusionsAsRegex | ||
| 42 | ? spacesDisplay.exclusions | ||
| 43 | : spacesDisplay.exclusions.split(", "); | ||
| 44 | |||
| 45 | const titleExclusions = exclusionsAsRegex | ||
| 46 | ? spacesDisplay.titleExclusions | ||
| 47 | : spacesDisplay.titleExclusions.split(", "); | ||
| 48 | |||
| 49 | // Generate class names for the component | ||
| 50 | const classes = Utils.classNames("process", { | ||
| 51 | "process--centered": centered, | ||
| 52 | }); | ||
| 53 | |||
| 54 | // Filter windows based on exclusions | ||
| 55 | const filteredWindows = windows.filter((window) => | ||
| 56 | Utils.filterApps(window, exclusions, titleExclusions, exclusionsAsRegex), | ||
| 57 | ); | ||
| 58 | |||
| 59 | return ( | ||
| 60 | <div className={classes}> | ||
| 61 | <div className="process__container"> | ||
| 62 | {filteredWindows.map((window, i) => ( | ||
| 63 | <Window key={i} window={window} /> | ||
| 64 | ))} | ||
| 65 | </div> | ||
| 66 | </div> | ||
| 67 | ); | ||
| 68 | }); | ||
| 69 | |||
| 70 | Component.displayName = "Process"; | ||
| 71 | |||
| 72 | export default Component; | ||
