top | item 34487066

macOS CLI tool to configure multi-display resolutions and arrangements

177 points| dwardu | 3 years ago |github.com

86 comments

order

alin23|3 years ago

I 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°).

deanc|3 years ago

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.

bygoneera|3 years ago

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.

MattIPv4|3 years ago

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.

zalyh|3 years ago

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.

ricardobeat|3 years ago

Isn’t this possible with the new iOS-like split view in Ventura? Sadly not supported by many apps yet (eg VSCode).

ricardobeat|3 years ago

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 :/

wpm|3 years ago

Settings in Ventura are a step back. Just…the whole thing. It’s gracious to call it an amateur effort.

donutdan4114|3 years ago

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.

seatbelts|3 years ago

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.

jakehilborn|3 years ago

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.

fruit2020|3 years ago

Latest code is from 6 months ago. You can probably build it yourself

parasti|3 years ago

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.

alin23|3 years ago

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...

deanc|3 years ago

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).

joshstrange|3 years ago

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"

artificialLimbs|3 years ago

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.

mnemnc|3 years ago

Not calling it displaycer is a missed opportunity.

jakehilborn|3 years ago

Trust me, I considered it lol.

umberthreat34g|3 years ago

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?

jakehilborn|3 years ago

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.

Analemma_|3 years ago

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.

jakehilborn|3 years ago

displayplacer lets you specify all those attributes you mentioned as shell command so you can fix everything with one "click".

xvilka|3 years ago

It reminds of seemingly abandoned "mas"[1] tool that allows using command line to install and update applications without launching AppStore.

[1] https://github.com/mas-cli/mas

Uupis|3 years ago

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.

m4tthumphrey|3 years ago

Can you elaborate? I have this problem every day.. macOS just seems incapable of remembering my display arrangement.

asmor|3 years ago

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.

[1]: https://github.com/fcanas/mirror-displays

dylan604|3 years ago

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

jakehilborn|3 years ago

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.

jamespo|3 years ago

Related to this does anyone know a way to turn off displays in MacOS? I have 2 screens connected to an M1 Mac Mini.

alin23|3 years ago

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:

    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 device
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...

jakehilborn|3 years ago

The 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.

Syzygies|3 years ago

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.

sleight42|3 years ago

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...

joshstrange|3 years ago

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.

[0] https://github.com/kasper/phoenix

[1] https://github.com/joshstrange/mousejump

matt_daemon|3 years ago

Would love if these tools also had the ability to save application window settings too.

shireboy|3 years ago

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.

alin23|3 years ago

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.

artificialLimbs|3 years ago

Closest thing I've found for getting this done is Mosaic.

haliskerbas|3 years ago

I’ve used hammerspoon for part of this functionality. Anyone else?

spudlyo|3 years ago

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.

bryanrasmussen|3 years ago

I really think this needs some screenshots.

tobr|3 years ago

Would you even see what it does in a screenshot? I think you would need a photo.

looseyesterday|3 years ago

The description could be better. Would love this tool with a GUI

jakehilborn|3 years ago

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.

squidofbits|3 years ago

Missed opportunity to call it displaycer

bobberkarl|3 years ago

Is there one for windows?