macOS CLI tool to configure multi-display resolutions and arrangements
github.comI recently launched some macOS Shortcuts in Lunar (https://lunar.fyi/#shortcuts) that can arrange monitors in pre-defined layouts like:
2 Screens Vertically ■̳̲
2 Screens Horizontally ⫍⃮݄⫎⃯
4 Screens in a 3-above-1 configuration ⫍⃮■̳̻⫎⃯
3 Screens in a 2-above-1 configuration ⫍‗⫎
3 Screens Horizontally ⫍⃮▬̲⫎⃯
It's not the same as DisplayPlacer but for a lot of people this could be enough. They are free and can be used without a Lunar Pro license.For those having trouble with monitors being swapped around by the OS, there's also a Swap screen positions action in Shortcuts that you can bind to a hotkey to quickly fix this. It even swaps rotations, which is especially useful for those using portrait monitors (one at 90° and one at 270°).
Lunar is awesome. Just FYI there is a link in the following text which doesn't work, so i can't actually see an examples.
> Check out the "Shortcuts" page to find some useful pre-made shortcuts that you can add with a click.
Is it possible to snapshot exact screen positioning using shortcuts? I'd like to take a snapshot of all my settings (orientation, refresh rate, hdr settings, and _exact_ screen positioning) and restore using a shortcut when ever it changes.
Thanks! That "Shortcuts" page is still WIP, I hoped to launch it the same day I released the update but life happened.
No, Lunar doesn't have that snapshot functionality because it's really hard to make it work for every possible setup. UUIDs can change between connections and the user can be left with an unusable snapshot. Or, because of how the HDMI/DP connection was negotiated, some display modes might not be available until a disconnect/reconnect cyle.
And it's impossible to detect the problem and convey it to the user when it happens, it mostly looks like an app bug no matter what I try.
But I am planning to add it in the future, at least in a rudimentary form.
Currently using displayplacer with BTT to make keyboard shortcuts. When moving to different hoteling desks, sometimes the laptop is on the left of the additional monitor and other times on the right. Now I have two keybinds that orient my layout. I've used Lunar specifically for the dim below 0 functionality, (thanks for the ongoing development), I'll have to try the new shortcuts to see if they can replace displayplacer.
The one feature I really want for window management on macOS is the ability to split fullscreen applications horizontally, for my vertical monitor. macOS lets you split a fullscreen app vertically so you can have two on the same screen, but when a monitor is oriented vertically you can still only split the screen vertically, not horizontally. Sigh.
Check out, https://rectangleapp.com/ this might be what you are looking for.
Rectangle is amazing and I highly recommend it, but it's a window manager and not a display manager.
Another window manager https://ianyh.com/amethyst/
I have tried Amythyst.
Yabai, didn't try since it wants to disable system integrity protection. Not sure if will work in locked down corporate machines.
Now back to Rectangle and arranging the windows myself in multiple desktops.
You can get value out of yabai even without disabling SIP to add the hooks into Dock.app. The things it needs that for isn't that long of a list, see the first bulleted list here https://github.com/koekeishiya/yabai/wiki/Disabling-System-I... , maybe you don't need those / can replicate them without yabai?
When I initially read this on that page,
> The following features of yabai require System Integrity Protection to be (partially) disabled:
, I thought that meant "so yabai just won't work at all if you don't disable SIP", but it's not the case at all. I use hammerspoon to deal with spaces, and don't care about window transparency/shadows/animation, and I don't know what "picture in picture for any window" means. I do miss stickiness and per-window floating (which are features I used in XMonad), but it's fine, I'm not going to disable SIP for those.
Particularly, if you just want focus-follows-mouse like in X Windows, yabai gives you that without disabling SIP.
Yet another option: https://github.com/koekeishiya/yabai
I will also +1 this as an i3wm user. I do use displayplacer and yabai together though. I have two identical external monitors that don't behave well with MacOS. Apparently the monitor's unique id's are not unique in MacOS. This causes MacOS to get them mixed up any time I disconnect from them. I have a keyboard shortcut that uses displayplacer to toggle between the two monitor valid configurations.
This person [0] also had that issue, they found that for their monitors for whatever reason, using the contextual screen IDs instead of the persistent ones always results in a consistent configuration. Might be worth a shot.
[0] https://github.com/jakehilborn/displayplacer/issues/106#issu...
I will always +1 for yabai, closest thing to i3wm I have found on macos
I think spectacle app can help. https://github.com/eczarny/spectacle
+1 been using Spectacle for years and it work perfectly.
However I just saw that the project is no longer maintained as of... two days ago ! I guess I'll have to find an alternative down the road.
Echoing what umberthreat34g said, check out Rectangle (https://github.com/rxhanson/Rectangle).
Since we're on the topic of tiling manager, I'm still using ShiftIt on my old macbook and I still think it's one of the best window manager since it allows you bind keys to particular actions and stays out of the way with minimal configuration. It's not being maintained though.
Isn’t this possible with the new iOS-like split view in Ventura? Sadly not supported by many apps yet (eg VSCode).
I really liked the display settings built-in to MacOS, very straightforward.
Unfortunately, with Ventura, they now hid the arrangement in a separate options window that takes extra clicks to reach. A step backwards :/
Settings in Ventura are a step back. Just…the whole thing. It’s gracious to call it an amateur effort.
I think the justification was that the old System Preferences window size was constraining what they could fit.
Unfortunately the new replacement allows them to not think very hard about how it's designed, just dump some everything in a list.
Terrible design. This is not a phone, Apple. It is a computer.
It was the old design that was an iOS-like grid of icons, not the new one.
now, it is like the iOS settings menu of infinite scroll.
I noticed this as well. Now if i have to rearrange i try to remember to open spotlight (CMD+Space) and type "arrange".. will take you straight to the option.
Whoa, never thought to try Spotlight for this, thanks for the hint! I was mostly using Option+BrightnessUp then clicking on Arrange.
I was stoked to see this, unfortunately, this has gone 4 years without a release (last released in 2019)
The issue log has several issues where Ventura users mention it not working at all, on M1 architectures. Can anyone on an M1 or M2 confirm this works for them? I'm still on Intel.
I placed on order for an M2 MacBook for my wife last week. I'm planning on adding native support within a few months of the laptop arriving.
Right on, thanks Jake!
The version installable with Homebrew is working for me on Ventura / M1.
I have an occasional issue where one of my external displays switches from 60 Hz to 40 Hz, and I use displayplacer to toggle the refresh rate to reset the monitor back to 60: https://github.com/jacobwgillespie/dotfiles/blob/main/bin/fi...
Ah, that's reassuring. So some bugs on Apple Silicon, but not game breaking. Thanks for the detail and filing an issue, Jacob.
Latest code is from 6 months ago. You can probably build it yourself
True - though I prefer binaries because when building from source it's easy to burn time just fiddling with dependencies
Great timing. Today I discovered that the iMac 24" screen can't be rotated. I have it on a VESA mount, so I can rotate it physically, but screen rotation settings are inaccessible (even with the Option key) via system settings. When I attempt rotation via displayplacer (tool in OP), it just complains that it "could not find res". There's a surprising lack of good search results on this. Seems to be related to the iMac overheating, but that's information coming from a random forum post that I found, not from Apple.
Edit: found Display Rotation Menu via DisplayPlacer Github issues, which is so far the only tool that worked for me.
I published a CLI for doing rotation for any display here: https://github.com/alin23/mac-utils/blob/main/bin/RotateDisp...
Source code in the same repo: https://github.com/alin23/mac-utils/blob/main/RotateDisplay....
As long as the system reports `true` for `canChangeOrientation`, then the CLI should work.
Lunar (https://lunar.fyi/) can also do that and provides some useful hotkeys if you happen to rotate displays often: https://files.alinpanaitiu.com/2106f2eac02df0c3eec379ef19965...
Do any of these methods work to rotate a Sidecar display? Right now I’m using BetterDisplay to creat a dummy and then rotate and stream that dummy to the Sidecar display, but it’s a bit unwieldy and sometimes unreliable (due to an Apple bug apparently).
Unfortunately not, the system reports false for canChangeOrientation on a Sidecar display:
mac-utils ./bin/RotateDisplay sidecar 0 ID UUID Can Change Orientation Orientation Name 1 37D8832A-2D66-02CA-B9F7-8F30A301B230 true 0° Built-in Liquid Retina XDR Display 6 BF8D0007-9573-49E5-8130-75991ECB2F15 false 0° Sidecar 4 FB46E28E-5B98-475A-A610-C15237238C8D true 0° LG Ultra HD The display does not support changing orientation: Sidecar [ID: 6]I see… Thanks for confirming!
This hasn't been updated in a while. What I really want from this kind of tool is the ability to take a snapshot of my ALL display settings, and just click something on my desktop or bind a keyboard shortcut, or run a command which will restore it - exactly how it should be. This would include, exact screen positioning, refresh rate, resolutions etc.
I don't know what triggers it, but MacOS is really bad at changing these settings if you use multiple displays through the week (e.g. different coworking spaces).
It might not have been updated but it works perfectly. Also it does everything you just asked for except invocation (you have to setup the keybind yourself, for myself I have an Alfred workflow I run to do it).
Here is an example of a displayplacer command (it will generate this for you based on your current config, you just need to save and re-run it to get back to that state):
/opt/homebrew/bin/displayplacer "id:6696B81B-DF77-45C3-9D39-AFA151E17417 res:2560x1440 hz:74 color_depth:8 scaling:off origin:(0,0) degree:0" "id:353C959C-561C-48BA-B804-84C448FAF99F res:1440x2560 hz:75 color_depth:8 scaling:off origin:(-1440,-444) degree:90" "id:3892CD52-313D-4B1B-9743-DB3165484F16 res:1920x1080 hz:60 color_depth:8 scaling:off origin:(307,-1080) degree:0" "id:EB4F0496-96F8-4DA9-B14A-6023FE90C3B1 res:1440x2560 hz:75 color_depth:8 scaling:off origin:(2560,-499) degree:270"The closest I've found to doing this is Mosaic. I paid for it because it was so useful. You can bind keyboard shortcuts and make any selected window snap to a particular screen and size. With the introduction of Ventura's Stage Manager (which is a poorly disguised Task Bar that should be at the bottom of the screen occupying all the unused real estate next to/around the dock), I can use Mosaic to snap my windows to the fullest size possible while still being able to see Stage Manager and this gives me a window management experience on Mac that is almost as good as Windows.
This is not an issue of windows. This is an issue of display settings.
There’s a tool called “Later” that does this:
This is apps and windows. I’m talking about actual display settings which don’t reliably persist across situations.
Not calling it displaycer is a missed opportunity.
Trust me, I considered it lol.
The problem that I have with my M1 is that I have 2 HP monitors with USB-C connectors and when I plug the USB/C Thunderbolt cable in to the monitor, often its not recognized and I often need to power off the machine, the monitor and or switch the ports in some combination, I really wish I could just have a manual probe I could run reliably to tell macOS,the monitor that they are connected. Any ideas?
As far as I understand, there is a low level race condition here. The order that the monitors come alive and initialize with the OS is non deterministic. This can cause the left monitor and the right monitor, for example, to swap IDs.
Does this somehow make settings more persistent than the System Pref^H^H^H^H Settings panel? Ventura has this infuriating bug where every single time it goes to sleep it forgets everything about the monitors I have plugged into my Thunderbolt dock - resolution, arrangement, refresh rate, everything. It is driving me bonkers.
displayplacer lets you specify all those attributes you mentioned as shell command so you can fix everything with one "click".
It reminds of seemingly abandoned "mas"[1] tool that allows using command line to install and update applications without launching AppStore.
There was a two-three year period where macOS would incessantly forget my display arrangement and orientation.
An Alfred action to run the displayplacer command and then after a second to activate my 'default' Moom window layout made for a great workaround.
Can you elaborate? I have this problem every day.. macOS just seems incapable of remembering my display arrangement.
It is typically because you have more than one of the same monitor with identical EDID information.
Documented and explained here: https://spin.atomicobject.com/2018/08/24/macbook-pro-externa...
Possible fix: https://gist.github.com/ejdyksen/8302862?permalink_comment_i...
I used to have two otherwise identical displays, but it still does it for me now that all of my displays are different. Notably, I think this stuff happens more when you have 3+ monitors. I don't remember having as many issues with just two displays.
I never managed to actually fix it. Maybe the links in the sibling comment can be of help there. But I feel like it became less of a nuisance after Monterey. Nowadays, it seems to move my app windows between displays after sleep, but that is resolved by applying the window layout snapshot from Moom.
My exact script seems to be gone — goes to show that I've not needed it for a while now — but the gist of my workaround was:
• I set up my display arrangement the way I wanted,
• followed the instructions in the displayplacer repo to work out a command to reproduce the desired arrangement,
• put the displayplacer command and the AppleSript call to Moom in the same shell script, with a short sleep between the two,
• and created an Alfred action to make it a tiny bit more convenient for myself.
The display arrangement would get out of sorts, but getting it back to my liking was just an Alfred action away.
You don't have to use Alfred or Moom specifically, those are just the convenience utilities I prefer.
I have used cscreen [1][2] for a while to switch resolutions beyond what macOS offers via its GUI. You can install it via `brew install cscreen`.
It seems like displayplacer is the spiritual and de facto successor to screen. [3]
[1] https://www.pyehouse.com/cscreen/#comments [2] https://apple.stackexchange.com/a/73696 [3] https://apple.stackexchange.com/a/173875
I have a setup where I share a screen between two computers (a macOS productivity machine and a Windows gaming laptop / x86 VM lab). I did look at a lot of tools to be able to disable one of the screens in macOS so I wouldn't need to fiddle with cables, and I remember that this one didn't work.
I use mirror-displays[1] (alongside Bunch, which also turns on VBAN Talkie for audio) now. Mirroring a screen is the only way to approximate disabled screens.
if you have multiple cables attached to the monitor, isn't it easier to use the monitor's input selection buttons to do this? with the monitors i have, when i manually switch inputs, it signals to the other computer the monitor is no longer available and my mac auto switches like was not plugged in. when i switch back to the mac's input for the monitor, the mac auto recognizes it is available and reconfigures the layout. all as i was expecting it to do
I still use the macOS machine (either directly or via Synergy), so I need the have it only put the desktop on one of the screens.
The latest code on the master branch of displayplacer supports this. Run `displayplacer "id:34686E82-0CED-DF86-AFC7-AA1A8EB5CFC0 enabled:false"` with your screen ID and it will set the screen to all black plus remove the screen from the view of the OS. I'll cut the next release version after I add native Apple silicon support.
Related to this does anyone know a way to turn off displays in MacOS? I have 2 screens connected to an M1 Mac Mini.
Lunar's BlackOut feature can do that: https://lunar.fyi/pro#blackout
The feature is especially useful if you want to turn them off in software and keep them still connected to the Mac so that you can turn them on at a later time using a hotkey for example.
If you simply want to turn them off completely, just like you would press the physical power button of the monitor, then Lunar can do that by sending a DDC toggle power command, but there are some caveats to be aware of:
I recently wrote a deep dive into how I tried to find a better way to turn off these screens using private macOS APIs: https://alinpanaitiu.com/blog/turn-off-macbook-display-clams...works only if the monitor can be controlled through DDC (most monitors work) can't be used to power on the monitor when a monitor is turned off or in standby, it does not accept any commands from a connected deviceThe latest code on the master branch of displayplacer supports this. Clone the repo and run `make` to build it. Run `displayplacer "id:34686E82-0CED-DF86-AFC7-AA1A8EB5CFC0 res:1440x2560 enabled:false"` with your screen ID and it will set the screen to all black plus remove the screen from the view of the OS.
I had a rather expensive monitor that would sometimes refuse to wake up. I ended up scripting an Alfred keystroke to use AppleScript and System Preferences to toggle the resolution, which would wake up the screen. This would be easier, as I could simply SSH in from another machine.
I don't suppose it exposes commands to switch a Universal Controlled device from extended screen mode to remote keyboard-mouse control?
I have to reset this setting in Settings -> Display every few hours when the connection gets disrupted between my two macs for unknown reasons...
displayplacer is an awesome tool that I've mentioned on HN a number of times before. I have my displayplacer command setup to be run by Alfred so that when I connect my monitors I can just invoke Alfred, type "disp", and hit enter.
The next step would be to have it auto-run when monitors were attached but this works well enough for me. displayplacer for monitor alignment, phoenix for window management, and my own hacked together mousejump for jumping over the monitor gaps make for an awesome experience.
Would love if these tools also had the ability to save application window settings too.
This is what I’m looking for too. I have three places I plug in displays: home office, work office, no displays (coffee shop). I have specific windows I want in specific places when plugged into external displays at home or work. Browser, Remote Desktop tool, chat client, etc. Every time I come back from the coffee shop, I have to manually re-arrange my windows. First world problem I know but every time I think “it should be smart enough to land these windows in this spot”
Similar with code editors: it should be smart enough to re-arrange my docks based on screen size. When I have big screen, expand side and bottom sub-windows. When I’m just on laptop screen, auto hide them.
Ivan Sapozhnik (https://twitter.com/iSapozhnik) is working on adding this to his Lasso app (https://thelasso.app/). It's not an easy problem to solve as there's no API that can just save and restore windows, a lot of inventive solutions have been tried and failed.
But I see Ivan very determined to solve this.
Do you know of any specific writeups? I couldn't find any obvious results, but I'm curious where the difficulties lay. Tbh, I'd be happy with just "windows with this parent process go here" list - I wonder how far off that is.
I don't have any link on hand right now for a writeup, but I've followed yabai's (https://github.com/koekeishiya/yabai) development closely ever since it was called kwm and saw the limitations of macOS's public API to managing windows.
The windows with this parent process go here thing can be solved easily, and can even be done as a one-liner with yabai. Example of moving all the windows of Sublime Text to display 2:
It can even be automated by adding a rule in ~/.yabairc (although that might be undesirable as it will always be enforced even if you want to move the window manually):yabai -m query --windows | jq '.[] | select(.app == "Sublime Text") | .id' | xargs -I '{}' -- yabai -m window '{}' --display 2
Yabai can also resize the window to whatever size you want, or move it to a specific space, and it can even do that based on the window title.yabai -m rule --add app="Sublime Text" label="sublime-display-2" display=2It has this much power because it uses macOS's private APIs from SkyLight.framework (the macOS window and display manager): https://github.com/koekeishiya/yabai/blob/master/src/misc/ex...
Closest thing I've found for getting this done is Mosaic.
I use Display Maid, and it is pretty OK for my simple needs: https://funk-isoft.com/display-maid.html
is not this for window locations? It seems it's not for monitor config backup and restore.
I’ve used hammerspoon for part of this functionality. Anyone else?
I use Hammerspoon for managing my windows, but never for managing my displays. It shouldn't surprise me that it can do it, I'll check it out.
I really think this needs some screenshots.
Would you even see what it does in a screenshot? I think you would need a photo.
well when saying screenshot I of course figured that the idea of multiple screenshots, perhaps also with some explanatory text, would be implied, but yeah sure some photos would also be good.
The description could be better. Would love this tool with a GUI
I've seen a few comments mention the description now. Thank you for the feedback. I wrote displayplacer because all the other tools were GUIs and I needed something scriptable. Consider using SwitchResX for a multi-display profile GUI tool.
KDE has it.
Missed opportunity to call it displaycer
Is there one for windows?