aboutsummaryrefslogtreecommitdiff
path: root/users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/process.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/process.jsx')
-rwxr-xr-xusers/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/process.jsx102
1 files changed, 102 insertions, 0 deletions
diff --git a/users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/process.jsx b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/process.jsx
new file mode 100755
index 0000000..96a0b7c
--- /dev/null
+++ b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/yabai/process.jsx
@@ -0,0 +1,102 @@
1import * as Uebersicht from "uebersicht";
2import Window from "./window.jsx";
3import * as Utils from "../../utils";
4import { useYabaiContext } from "../yabai-context.jsx";
5import { useSimpleBarContext } from "../simple-bar-context.jsx";
6
7export { processStyles as styles } from "../../styles/components/process";
8
9const { React } = Uebersicht;
10
11/**
12 * Process component that displays the current windows and spaces information.
13 * @returns {JSX.Element|null} The rendered component or null if not visible.
14 */
15const Component = React.memo(() => {
16 // Get context values from yabai and simple-bar
17 const { spaces, windows, skhdMode } = useYabaiContext();
18 const { displayIndex, settings } = useSimpleBarContext();
19 const { process, spacesDisplay, widgets } = settings;
20 const { processWidget } = widgets;
21 const { exclusionsAsRegex } = spacesDisplay;
22 const { displayForFocusedSpace, centered, showCurrentSpaceMode, displaySkhdMode, showOnDisplay } =
23 process;
24
25 // Determine if the process widget should be visible
26 const visible =
27 processWidget &&
28 Utils.isVisibleOnDisplay(displayIndex, showOnDisplay) &&
29 windows;
30
31 if (!visible) return null;
32
33 // Parse exclusions based on settings
34 const exclusions = exclusionsAsRegex
35 ? spacesDisplay.exclusions
36 : spacesDisplay.exclusions.split(", ");
37
38 const titleExclusions = exclusionsAsRegex
39 ? spacesDisplay.titleExclusions
40 : spacesDisplay.titleExclusions.split(", ");
41
42 // Find the current space based on visibility and display index
43 const currentSpace = spaces.find((space) => {
44 const {
45 "is-visible": isVisible,
46 "has-focus" : hasFocus,
47 visible: __legacyIsVisible,
48 display,
49 } = space;
50 return (isVisible ?? __legacyIsVisible) && (displayForFocusedSpace ? hasFocus : display === displayIndex);
51 });
52
53 // Get sticky and non-sticky windows using a utility function
54 const { stickyWindows, nonStickyWindows } = Utils.stickyWindowWorkaround({
55 windows,
56 uniqueApps: false,
57 currentDisplay: displayIndex,
58 currentSpace: currentSpace?.index,
59 exclusions,
60 titleExclusions,
61 exclusionsAsRegex,
62 });
63
64 // Combine sticky and non-sticky windows
65 const apps = [...stickyWindows, ...nonStickyWindows];
66
67 // Determine CSS classes for the component
68 const classes = Utils.classNames("process", {
69 "process--centered": centered,
70 });
71
72 // Determine the current skhd mode and its color
73 const currentSkhdMode = skhdMode.mode === "default" ? null : skhdMode.mode;
74 const skhdModeColor = "var(--" + skhdMode.color + ")";
75
76 return (
77 <div className={classes}>
78 <div className="process__container">
79 {showCurrentSpaceMode && currentSpace && (
80 <div key={currentSpace.index} className="process__layout">
81 {currentSpace.type}
82 </div>
83 )}
84 {displaySkhdMode && currentSkhdMode && (
85 <div
86 className="process__skhd-mode"
87 style={{ backgroundColor: skhdModeColor }}
88 >
89 {currentSkhdMode}
90 </div>
91 )}
92 {Utils.sortWindows(apps).map((window, i) => (
93 <Window key={i} window={window} />
94 ))}
95 </div>
96 </div>
97 );
98});
99
100Component.displayName = "Process";
101
102export default Component;