Added a CLI command to update layout. (#521)
This commit is contained in:
1
globals.d.ts
vendored
1
globals.d.ts
vendored
@@ -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<void>;
|
||||
var setWallpaper: (filePath: string) => void;
|
||||
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user