Last active
July 7, 2024 10:55
-
-
Save saiashirwad/3ee158b7598cea79a53363a572e1b149 to your computer and use it in GitHub Desktop.
phoenix-stream-mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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