The Window Management API provides developers with some functions to create commands with some advanced logic to move Windows around.
Gets the active .
A Promise that resolves with the active . If no window is active, the promise will be rejected.
Gets the list of s on the active .
A Promise that resolves with an array of Windows.
Gets the list of s available across all screens.
A Promise that resolves with the desktops.
Move a or make it fullscreen.
A Promise that resolves with the window was moved. If the move isn't possible (for example trying to make a window fullscreen that doesn't support it), the promise will be rejected.
A Window from an on a .
A Desktop represents a virtual desktop on a Screen.
The type of a .
id*
string
positionable*
boolean
resizable*
boolean
application
type*
options*
{ id: string } or { bounds: { position?: { x?: number; y?: number }; size?: { height?: number; width?: number } }; desktopId?: string } or { bounds: "fullscreen" }
active*
boolean
bounds*
{ position: { x: number; y: number }; size: { height: number; width: number } } or "fullscreen"
desktopId*
string
fullScreenSettable*
boolean
active*
boolean
id*
string
screenId*
string
size*
{ height: number; width: number }
User
The default Desktop type. It can contain any number of Window
FullScreen
A Desktop made of a single fullscreen window
async function getActiveWindow(): Promise<Window>;import { WindowManagement, showToast } from "@raycast/api";
export default async function Command() {
try {
const window = await WindowManagement.getActiveWindow();
if (window.positionable) {
await WindowManagement.setWindowBounds({ id: window.id, bounds: { position: { x: 100 } } });
}
} catch (error) {
showToast({ title: `Could not move window: ${error.message}`, style: Toast.Style.Failure });
}
}async function getWindowsOnActiveDesktop(): Promise<Window[]>;import { WindowManagement, showToast } from "@raycast/api";
export default async function Command() {
const windows = await WindowManagement.getWindowsOnActiveDesktop();
const chrome = windows.find((x) => x.application?.bundleId === "com.google.Chrome");
if (!chrome) {
showToast({ title: "Couldn't find chrome", style: Toast.Style.Failure });
return;
}
WindowManagement.setWindowBounds({ id: chrome.id, bounds: { position: { x: 100 } } });
}async function getDesktops(): Promise<Desktop[]>;import { WindowManagement, showToast } from "@raycast/api";
export default function Command() {
const desktops = await WindowManagement.getDesktops();
const screens = Set(desktops.map((desktop) => desktop.screenId));
showToast({ title: `Found ${desktops.length} desktops on ${screens.size} screens.` });
}async function setWindowBounds(
options: { id: string } & (
| {
bounds: {
position?: { x?: number; y?: number };
size?: { width?: number; height?: number };
};
desktopId?: string;
}
| {
bounds: "fullscreen";
}
)
): Promise<void>;import { WindowManagement, showToast } from "@raycast/api";
export default async function Command() {
try {
const window = await WindowManagement.getActiveWindow();
if (window.positionable) {
await WindowManagement.setWindowBounds({ id: window.id, bounds: { position: { x: 100 } } });
}
} catch (error) {
showToast({ title: `Could not move window: ${error.message}`, style: Toast.Style.Failure });
}
}