Added a CLI command to update layout. (#521)

This commit is contained in:
Jas Singh
2024-11-17 12:37:38 -08:00
committed by GitHub
parent ac794dccb0
commit ef761f2dcf
2 changed files with 17 additions and 0 deletions

1
globals.d.ts vendored
View File

@@ -7,6 +7,7 @@ declare global {
var useTheme: (filePath: string) => void; var useTheme: (filePath: string) => void;
var getSystrayItems: () => string; var getSystrayItems: () => string;
var isWindowVisible: (windowName: string) => boolean; var isWindowVisible: (windowName: string) => boolean;
var setLayout: (layout: string) => string;
var clearAllNotifications: () => Promise<void>; var clearAllNotifications: () => Promise<void>;
var setWallpaper: (filePath: string) => void; var setWallpaper: (filePath: string) => void;

View File

@@ -1,3 +1,5 @@
import options from 'options';
globalThis.isWindowVisible = (windowName: string): boolean => { globalThis.isWindowVisible = (windowName: string): boolean => {
const appWindow = App.getWindow(windowName); const appWindow = App.getWindow(windowName);
@@ -6,3 +8,17 @@ globalThis.isWindowVisible = (windowName: string): boolean => {
} }
return appWindow.visible; 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}`;
}
};