Skip to content

Instantly share code, notes, and snippets.

@saiashirwad
Last active July 7, 2024 10:55
Show Gist options
  • Save saiashirwad/3ee158b7598cea79a53363a572e1b149 to your computer and use it in GitHub Desktop.
Save saiashirwad/3ee158b7598cea79a53363a572e1b149 to your computer and use it in GitHub Desktop.
phoenix-stream-mode
const frame = Screen.main().visibleFrame();
const toggleStreaming = Key.on("s", ["control", "option"], () => {
const isStreaming = Storage.get("isStreaming") ?? false;
Storage.set("isStreaming", !isStreaming);
if (isStreaming) {
getAndMoveApp(
"Chatterino",
{ x: 0, y: 0 },
{ width: 250, height: frame.height },
);
getAndMoveApp(
"kitty",
{ x: 250, y: 0 },
{ width: frame.width - 250, height: frame.height },
);
getAndMoveApp(
"Firefox",
{ x: 250, y: 0 },
{ width: frame.width - 250, height: frame.height },
);
} else {
App.get("Chatterino").hide();
getAndMaximizeApp("kitty");
getAndMaximizeApp("Firefox");
}
});
function getAndMaximizeApp(appName) {
const app = App.get(appName);
if (!app) {
App.launch(appName, { focus: true });
}
if (app) {
app.show();
const appWindow = app.windows()[0];
if (appWindow) {
appWindow.maximize();
const size = appWindow.size();
}
}
}
function getAndMoveApp(appName, position, size) {
const app = App.get(appName);
if (!app) {
App.launch(appName, { focus: true });
}
if (app) {
app.show();
const appWindow = app.windows()[0];
if (appWindow) {
appWindow.setTopLeft(position);
appWindow.setSize(size);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment