Skip to content

Instantly share code, notes, and snippets.

@bobmagicii
Created May 17, 2024 04:59
Show Gist options
  • Save bobmagicii/00d34b989a43110a9f48958bad48ea12 to your computer and use it in GitHub Desktop.
Save bobmagicii/00d34b989a43110a9f48958bad48ea12 to your computer and use it in GitHub Desktop.
quick wrapper for displayplacer on mac os
#!env php
<?php
// placed in ~/Local/bin, chmoded, with that added to PATH.
// requires: https://github.com/jakehilborn/displayplacer
// use `displayplacer list` to find your screen id and supported modes. then
// update the screen id and sizes to have what you want.
// $ dp <size>
$ScreenID = '37D8832A-2D66-02CA-B9F7-8F30A301B230';
$Sizes = [
// 1600x1000 (fills built-in screen)
// a compromise between space and reading comfort on the macbook.
'normal' => sprintf('displayplacer "id:%s mode:12"', $ScreenID),
// 1920x1200 (fills built-in screen)
// on the tiny macbook screen it is too small to be comfortable from more
// than a foot away from the screen.
'native' => sprintf('displayplacer "id:%s mode:15"', $ScreenID),
// 1920x1080 (black bars on built-in)
// so i can fill my remote desktop window properly on real computers with
// good screens.
'wide' => sprintf('displayplacer "id:%s mode:14"', $ScreenID)
];
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
$Args = $_SERVER['argv'];
$Size = array_pop($Args);
if(!array_key_exists($Size, $Sizes)) {
echo 'invalid size: ', $Size, PHP_EOL, PHP_EOL;
echo 'sizes: ', join(', ', array_keys($Sizes)), PHP_EOL, PHP_EOL;
exit(1);
}
system($Sizes[$Size]);
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment