fix: errors in destroy space & create space next to current
This commit is contained in:
@@ -7,16 +7,25 @@ export default async function Command() {
|
|||||||
const { stderr } = await runYabaiCommand(`-m space --create`);
|
const { stderr } = await runYabaiCommand(`-m space --create`);
|
||||||
|
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
|
console.log(stderr);
|
||||||
throw new Error(stderr);
|
throw new Error(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { stdout: spacesOutput } = await runYabaiCommand(`-m query --spaces`);
|
const { stdout: spacesOutput } = await runYabaiCommand(`-m query --spaces --space mouse`);
|
||||||
const spaces = JSON.parse(spacesOutput);
|
const space = JSON.parse(spacesOutput);
|
||||||
const lastSpaceIndex = spaces.filter((space: { [x: string]: never }) => !space["is-native-fullscreen"]).pop().index;
|
|
||||||
|
|
||||||
await runYabaiCommand(`-m space --focus ${lastSpaceIndex}`);
|
const { stderr: stderr2 } = await runYabaiCommand(`-m space last --move ${space.index+1}`);
|
||||||
|
|
||||||
showHUD(`Created space: ${lastSpaceIndex}`);
|
if (stderr2) {
|
||||||
|
console.log(stderr2);
|
||||||
|
throw new Error(stderr2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
await runYabaiCommand(`-m space --focus next`);
|
||||||
|
|
||||||
|
showHUD(`Created space`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
if (error.message.includes("Yabai executable not found")) {
|
if (error.message.includes("Yabai executable not found")) {
|
||||||
|
|||||||
@@ -4,23 +4,12 @@ import { showFailureToast } from "@raycast/utils";
|
|||||||
|
|
||||||
export default async function Command() {
|
export default async function Command() {
|
||||||
try {
|
try {
|
||||||
const { stdout: rawRecentSpace, stderr } = await runYabaiCommand(`-m query --spaces --space recent`);
|
const { stderr } = await runYabaiCommand(`-m space --destroy`);
|
||||||
|
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
throw new Error(stderr);
|
throw new Error(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const recentSpace = JSON.parse(rawRecentSpace);
|
|
||||||
const lastSpaceIndex = recentSpace.index;
|
|
||||||
|
|
||||||
await runYabaiCommand(`-m space --destroy`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
await runYabaiCommand(`-m space --focus ${lastSpaceIndex}`);
|
|
||||||
} catch (error) {
|
|
||||||
throw new Error(`Failed to focus space: ${error}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await showHUD(`Destroyed Space`);
|
await showHUD(`Destroyed Space`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user