univ-of-utah-marriott-library-apple / display_manager

An open-source Python library which can modify your Mac's display settings manually or automatically.
MIT License
237 stars 18 forks source link

Set screen position #28

Open soundflix opened 1 year ago

soundflix commented 1 year ago

Setting screen positions would be a good addition. Or did I miss it?

Alexandro1112 commented 1 year ago

What did you mean?

soundflix commented 1 year ago

Set position and offset of multiple screens

Alexandro1112 commented 1 year ago

Try this script:

import AppKit

# Получаем список всех экранов
screens = AppKit.NSScreen.screens()

screen = screens[0]
frame = screen.frame()

new_frame = AppKit.NSMakeRect(frame.origin.x + 100, frame.origin.y - 50, frame.size.width, frame.size.height)

screen.setFrame(new_frame)
soundflix commented 1 year ago

Thanks for the script. I do mostly stuff in Swift. NSScreen does not have a .setScreen(..) method?! I think setting screen origins only works with Quartz services methods. I tried some things, but all settings vanish after user session ends (log-out or restart)

Alexandro1112 commented 1 year ago

If you can change the screen position in the system preferences, I think it's also possible to set the position automatically.

Alexandro1112 commented 1 year ago

I'm thinking about the IOKit framework. I even set the screen resolution using this framework. I think we need to figure out how to change the screen position using Iokit.