From ef761f2dcf67df6ec9575936cfd1897c3c467636 Mon Sep 17 00:00:00 2001 From: Jas Singh Date: Sun, 17 Nov 2024 12:37:38 -0800 Subject: [PATCH] Added a CLI command to update layout. (#521) --- globals.d.ts | 1 + globals/utilities.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/globals.d.ts b/globals.d.ts index a1ef76c..5abad72 100644 --- a/globals.d.ts +++ b/globals.d.ts @@ -7,6 +7,7 @@ declare global { var useTheme: (filePath: string) => void; var getSystrayItems: () => string; var isWindowVisible: (windowName: string) => boolean; + var setLayout: (layout: string) => string; var clearAllNotifications: () => Promise; var setWallpaper: (filePath: string) => void; diff --git a/globals/utilities.ts b/globals/utilities.ts index 438c666..5b03e3d 100644 --- a/globals/utilities.ts +++ b/globals/utilities.ts @@ -1,3 +1,5 @@ +import options from 'options'; + globalThis.isWindowVisible = (windowName: string): boolean => { const appWindow = App.getWindow(windowName); @@ -6,3 +8,17 @@ globalThis.isWindowVisible = (windowName: string): boolean => { } return appWindow.visible; }; + +globalThis.setLayout = (layout: string): string => { + console.log(layout); + + try { + const layoutJson = JSON.parse(layout); + const { layouts } = options.bar; + + layouts.value = layoutJson; + return 'Successfully updated layout.'; + } catch (error) { + return `Failed to set layout: ${error}`; + } +};