Skip to content

Instantly share code, notes, and snippets.

@bjesuiter
Created January 7, 2023 14:54
Show Gist options
  • Save bjesuiter/9e22e592b8bf2e6074e4630cc7ed1913 to your computer and use it in GitHub Desktop.
Save bjesuiter/9e22e592b8bf2e6074e4630cc7ed1913 to your computer and use it in GitHub Desktop.
//Name: Toggle Lenovo Monitor Streaming Mode
import "@johnlindquist/kit"
// activeScene can also be 'streaming' => simply makes everything bigger on my 4K Display
const scriptDB = await db({activeScene: 'normal'});
await scriptDB.read();
if (scriptDB.data.activeScene === 'normal') {
// activate magnified streaming mode
await $`displayplacer "id:F504C4AE-5C04-948D-85C5-28C0FBB3750B res:1920x1080 hz:60 color_depth:8 scaling:on origin:(0,0) degree:0"`;
scriptDB.data.activeScene = 'streaming';
} else {
// activate normal mode
await $`displayplacer "id:F504C4AE-5C04-948D-85C5-28C0FBB3750B res:2560x1440 hz:60 color_depth:8 scaling:on origin:(0,0) degree:0"`;
scriptDB.data.activeScene = 'normal';
}
await scriptDB.write();
// code for setting resolution to normal: displayplacer "id:F504C4AE-5C04-948D-85C5-28C0FBB3750B res:2560x1440 hz:60 color_depth:8 scaling:on origin:(0,0) degree:0"
// code for activating magnified streaming mode: displayplacer "id:F504C4AE-5C04-948D-85C5-28C0FBB3750B res:1920x1080 hz:60 color_depth:8 scaling:on origin:(0,0) degree:0"
// Note: System command to read available monitors
// Problem: No native cli to change the current resolution/mode!
// const displaysJson = await $`system_profiler SPDisplaysDataType -json`;
// const graphicsCards = JSON.parse(displaysJson).SPDisplaysDataType;
// const displays = [];
// for (const graphicsCard of graphicsCards) {
// if (graphicsCard.spdisplays_ndrvs === undefined) continue;
// for (const display of graphicsCard.spdisplays_ndrvs) {
// displays.push(display);
// }
// }
// Needs 'displayplacer' tool to be able to work!
// https://github.com/jakehilborn/displayplacer
// brew tap jakehilborn/jakehilborn && brew install displayplacer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment