jakehilborn / displayplacer

macOS command line utility to configure multi-display resolutions and arrangements. Essentially XRandR for macOS.
MIT License
3.72k stars 135 forks source link

Save monitor enabled / disabled state #25

Open telias-tp opened 4 years ago

telias-tp commented 4 years ago

i have a 3 monitor setup at work. when i remote desktop in, i like to switch it to a 1 monitor setup with different resolution / orientation.

i use SwitchResX to disable the 2 other monitors.

i would like the command line utility to remember whether a monitor is enabled / disabled. (perhaps with an enabled:0 / enabled:1 string in the monitor config)

telias-tp commented 4 years ago

proposed solution via pull request #26

copied quartz call from https://github.com/janten/disable-monitor/blob/master/DisableMonitorAppDelegate.m

jakehilborn commented 4 years ago

I've played around with this before in an attempt to "turn off" the other screens. Best I could come up with is making the screen show all black and, if I remember correctly, using the CGSConfigureDisplayEnabled call. Never considered the remote login use case as I assumed people mirrored all their screens if they wanted one effective workspace.

I'll try to find some time later this week to test out your PR. Thanks!

hanj0415 commented 4 years ago

+1 This will be very useful when I remote access to my macmini with 2 screens from MBA, because it is really difficult to use both screens with high resolution from MBA display.

spcurtis81 commented 2 years ago

I think I have exactly the same use case here. I want to be able to disable 2 of my three displays and change the resolution of the main display using a script.

Is this possible?

I'd been trying to achieve this by porting xrandr to Mac but having no luck. I found this on xrandr... https://adamosk.com/turn-off-monitor-using-command-line/

telias-tp commented 2 years ago

i have a fork that currently supports this

https://github.com/telias-tp/displayplacer

i have started a pull request

spcurtis81 commented 2 years ago

Hi @telias-tp,

This is great and I'm on my way to getting it to work. As I plan to toggle between two states, I have created one command for each. The first sticks everything in mirrored mode with a resolution suitable for Remote Desktop from my iPad and the other is intended on returning to extended mode and re-orientated the screens as required.

The first script works as intended... displayplacer "id:BC128B79-2887-62AF-0857-D6964E3302DB+DD496242-0253-50BA-3D19-FC1626C9B248+DD496242-0253-50BA-C90B-A2661D91F570 res:1600x900 hz:30 color_depth:7 scaling:on origin:(0,0) degree:0"

However the second is not returning me to extended mode. Once I go in and manually switch the displays to extended in the Mac OS settings, the placement is fine, so this bit is working. Am I missing something to return these to extended (I.e. reverse the mirrored set up I created above? displayplacer "id:BC128B79-2887-62AF-0857-D6964E3302DB res:3840x2160 hz:60 color_depth:7 scaling:off origin:(0,0) degree:0" "id:DD496242-0253-50BA-3D19-FC1626C9B248 res:1920x1080 hz:60 color_depth:8 scaling:off origin:(0,2160) degree:0" "id:DD496242-0253-50BA-C90B-A2661D91F570 res:1920x1080 hz:60 color_depth:4 scaling:off origin:(1920,2160) degree:0"

jakehilborn commented 1 year ago

@telias-tp @hanj0415 @spcurtis81 The disabling screens features has been added to release v.1.3.0. Could you try it out and let me know if it works for you?

Just a heads up, on my Intel macbook I can disable & re-eenable the screen. On my M2 macbook, I can disable the screen but I have to unplug/replug it to re-enable it. Be careful if you're executing this command on a remote workstation. Another option to "get rid of" extra screens is to have them all mirror each other.

telias-tp commented 5 months ago

just switched over to a m2 mac studio, and currently it looks like CGSConfigureDisplayEnabled is no longer found. (macOS 13.6). is just using mirroring the solution now?