univ-of-utah-marriott-library-apple / display_manager Goto Github PK
View Code? Open in Web Editor NEWAn open-source Python library which can modify your Mac's display settings manually or automatically.
License: MIT License
An open-source Python library which can modify your Mac's display settings manually or automatically.
License: MIT License
Hi !
I'm trying to execute display_manager on a 10.7.5 Mac Pro.
DisplayManager-1.0.2.dmg has been installed successfully, but any command I type results in:
Mac-Pro-de-crapulette:display_manager kalou$ ./display_manager.py res
Traceback (most recent call last):
File "./display_manager.py", line 1257, in
main()
File "./display_manager.py", line 1240, in main
Command(verb="help", subcommand=e.verb).run()
File "./display_manager.py", line 136, in init
getIOKit()
File "/Users/kalou/display_manager/display_manager_lib.py", line 680, in getIOKit
globals=globals()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py", line 140, in initFrameworkWrapper
_parseBridgeSupport(data, globals, frameworkName, dylib_path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py", line 42, in _parseBridgeSupport
objc.parseBridgeSupport(data, globals, frameworkName, *args, **kwds)
ValueError: cftype for 'IOBlitMemoryRef' must include gettypeid_func, tollfree or both
Any clue of what's going on ?
First off - awesome tool! I picked up on this while looking to set the 'optimise for:' option (in the Displays System Preference) via script.
More of a feature request - I currently get & set the brightness of displays with other scripts. Is display_manager going to be able to query & report the current brightness of a given display in the future?
This issue is submitted on behalf of Rob:
First, thanks for creating Display Manager!
I’ve been using v1.0.1 successfully for some time, with a trio of different displays (including a MacBook Pro 15-inch’s internal display). No errors, no problems. Today, I connected up a Dell P2415Q, which is the first Retina-type external display I’ve tried. With it attached, various Display Manager commands result in traceback errors, which I’ve never gotten before with your software.
$ display_manager.py show available
display "main":
Traceback (most recent call last):
File "/usr/local/bin/display_manager.py", line 1257, in <module>
main()
File "/usr/local/bin/display_manager.py", line 1250, in main
commands.run()
File "/usr/local/bin/display_manager.py", line 671, in run
command.run()
File "/usr/local/bin/display_manager.py", line 269, in run
self.__handleShow()
File "/usr/local/bin/display_manager.py", line 449, in __handleShow
for mode in sorted(display.allModes, reverse=True):
File "/Library/Python/2.7/site-packages/display_manager_lib.py", line 291, in allModes
uniqueModes.remove(mode)
KeyError: <display_manager_lib.DisplayMode object at 0x1116c6ed0>
Very useful open source project!
I am a privacy and security researcher and YouTuber.
I was desperate to find an open source way to configure DisplayPort output to non-high-dpi 1080P resolution (to lower CPU load when recording screen using Kap).
Any chance project can be adapted so library and command line utility can be install it using pip?
I know little about Python so question might be naive.
While Python 2.7 is still available in macOS, it is no longer being updated as of April 2020. For continued use, this tool will need to be rewritten for Python 3. (The use of Greg Neagle's Relocatable Python may be useful for final deployment.) I do not have the coding skills to write it, but would be willing to help test.
Under “Get Started“ it says:
Next, download the latest installer [here](./versions/Display Manager v1.0.0.dmg),
The Markdown stuff is showing
That's not the latest installer anymore.
I use simple script for get current brightness level.
import display_manager.display_manager_lib
import Quartz
print(display_manager.display_manager_lib.Display(displayID=Quartz.CGMainDisplayID()).brightness)
Output is:
(-536870201, 0.0)
MacOS Monterey 13.1
python 3.11
How to solve this problem?
Source: https://macmule.com/2022/01/29/macos-monterey-12-3-will-remove-python-2-7-usr-bin-python/
Given that python 2.7 will no longer be part of the system from that release onwards, the following error will appear:
/usr/local/bin/display_manager.py: bad interpreter: /usr/bin/python: no such file or directory
As a workaround, is it possible to specify the location of python 2.7 to use?
Display_Manager v.1.0.1. / macOS 10.12.6 / macbook pro 8,2
After restore the macbook from a Timemachine Backup the screen resolution 1440 x 900 only was set and available with no external monitor connected. As soon the external screen got plugged-in the main macbook LCD resolution jumped to the not-scaled 1440 x 852 – though this screen was successfully set to 1440 x 900 before the system restore.
When I now try to set resolution with plugged in external monitor Display Manager gives this result:
xxx:~ xxx$ display_manager.py res 1440 900 main
/usr/local/bin/display_manager.py:281: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
raise CommandExecutionError(e.message, command=self)
Error: Display "main" cannot be set to 1440x900
(whereas i was able to set the wanted 1440 x 900 with the tool SwitchRes (v.4.8.1)
I'm getting the following error when executing display_manager.py mirror enable main all
Traceback (most recent call last):
File "/usr/local/bin/display_manager.py", line 1257, in
main()
File "/usr/local/bin/display_manager.py", line 1250, in main
commands.run()
File "/usr/local/bin/display_manager.py", line 682, in run
currentMirror = display.mirrorSource
AttributeError: 'list' object has no attribute 'mirrorSource'
I can mirror to individual external displays.
Hi,
I am using two resolutions on my 49" (Philips 499P9) screen mainly and skip from "fullscreen" 5120x1440 to "split screen" 2560x1440 for two connected computers. Manual selection works on control panel or with other tools, but I'd like to use a script to switch even faster.
Unfortunately display_manager doesn't let me change resolution/refresh to my prefered values:
/usr/local/bin/display_manager.py res 5120 1440 30 ext0
/usr/local/bin/display_manager.py:281: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
raise CommandExecutionError(e.message, command=self)
Error: Display "ext0" cannot be set to 5120x1440
/usr/local/bin/display_manager.py res 2560 1440 60 ext0
/usr/local/bin/display_manager.py:281: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
raise CommandExecutionError(e.message, command=self)
Error: Display "ext0" cannot be set to 2560x1440
However, the following setting do change screen resolution for example without any issue.
/usr/local/bin/display_manager.py res 3840 1080 60 ext0
/usr/local/bin/display_manager.py res 3840 1080 30 ext0
/usr/local/bin/display_manager.py res 1920 1080 60 ext0
Any idea to override or force the settings for 5120x1440@30Hz and 2560x1440@60Hz and get around the exception?
Thanks in advance
Markus
When I use Display Manager to set a resolution and refresh rate, it will change the colour depth to 24 bits. When I use System Preferences to set the resolution, 30 bit is used as the UHD 630 in my machine, where the screen is connected to, can’t provide 32-bit.
In your answer to issue 6 you explain that color depth
has been deprecated as almost all modern monitors use 32-bit colour depths. As far as my monitors are concerned that is true. But the latest low-end Mac models come with a UHD 630 only providing 24-, 30- (not for HDMI), and 36-bit colour depth (see here).
Therefore, is it possible to re-implement setting of the colour depth? Or at least have Display Manager set the highest possible depth if the GPU is not capable of 32-bit?
Hello,
display_manager
looks great! I'm on macOS Catalina. I was just wondering if there is an easy way to set the "scaled" resolution for slightly larger text, as shown in the following screenshot:
I think it would be really useful if some of these "Scaled" examples could be added to the README. I'm trying to automate my Mac setup with a script, and I prefer this scaled resolution.
Thanks!
I'm not sure what's causing this. I'm running macOS Catalina. When I run the "show" command I get nothing.
% ./display_manager.py show
%
Thoughts?
I use simple script for get current brightness level.
Import display_manager.display_manager_lib
import Quartz
print(display_manager.display_manager_lib.Display(displayID=Quartz.CGMainDisplayID()).brightness)
Output is:
(-536870201, 0.0)
My environment
MacOS Monterey 13.1
python 3.11
How to solve this problem?
Running display_manager.py show
on my Mac (running 10.14 (18A365a)) gives this warning:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py:674: RuntimeWarning: Error parsing BridgeSupport data for IOKit: PyObjCRT_SkipTypeSpec: Unhandled type '0'
warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)
before it outputs the expected information:
display "main":
resolution: 1440x900
refresh rate: 0
HiDPI: True
rotation: 0
brightness: 1.00
Similarly display_manager.py help
gives this warning:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py:674: RuntimeWarning: Error parsing BridgeSupport data for IOKit: PyObjCRT_SkipTypeSpec: Unhandled type '0'
warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)
before showing the expected
usage: display_manager.py <command>
COMMANDS (required)
help Show help information about a command
show Show current/available display configurations
res Manage display resolution
brightness Manage display brightness
rotate Manage display rotation
underscan Manage display underscan
mirror Manage screen mirroring
Hello,
Im nooby with Python but I can't launch gui.py (usr/local/bin/gui.py) from command line :
Traceback (most recent call last):
File "./gui.py", line 454, in
main()
File "./gui.py", line 450, in main
view.start()
File "./gui.py", line 443, in start
self.__reloadDisplay()
File "./gui.py", line 430, in __reloadDisplay
self.__modeSelectionInit()
File "./gui.py", line 226, in __modeSelectionInit
for mode in sorted(self.display.allModes(), reverse=True):
TypeError: 'list' object is not callable
display_manager.py version
should (IMO) show 1.0.1
or whatever is in the code as # Display Manager, version XYZ
where XYZ
is the version info.
It would be fantastic if you could incorporate Tim Sutton's customdisplayprofiles command line tool into display_manager, which would make this a complete solution for controlling colour-calibrated Macs (i.e. iMacs and other displays where you can't lock down the controls). Tim is no longer working in the job that led him to write his tool, so it will also need a new home under Python 3. Your tool seems to be the perfect complement to it, so it might be useful to include its functionality when you rewrite display_manager for Python 3 (see issue #19). Again, I can help test.
Setting screen positions would be a good addition. Or did I miss it?
Thank you so much for this! It's really helped with an issue we've been having in one of our computer labs - the professor wanted mirroring disabled when a user logs in, so deploying this alongside a script run with outset seemed to do the trick.
Unfortunately, running this command at login:
/usr/local/bin/display_manager.py mirroring disable
has the side effect of making the wrong monitor the primary display - the Mac is connected to a TV, and the TV is always set as the primary display. Is there a way to override that with Display Manager? I tried a few command combinations but none of them would change this - for example, set highest
turns off mirroring, bumps up the resolution of each display, but leaves the (wrong) primary display intact.
If it's not something Display Manager supports, but you know of a different way to script this, I'd really appreciate it. Thanks!
Mike
I ran the following command to see a list of my displays
$ display_manager.py show
display "main":
resolution: 2560x1440
refresh rate: 0
HiDPI: True
rotation: 0
brightness: 0.84
underscan: 0.00
display "ext0":
resolution: 1080x1920
refresh rate: 60
HiDPI: False
rotation: 90
underscan: 1.00
Then I ran this command to underscan the external display
display_manager.py underscan 0.7 ext0
It gave me no error, so I assumed everything worked okay. After running that command, I restarted my computer and low and behold, the underscan stayed exactly the same... Am I doing something wrong???
OUTPUT of show
exactly the same
$ display_manager.py show
display "main":
resolution: 2560x1440
refresh rate: 0
HiDPI: True
rotation: 0
brightness: 0.84
underscan: 0.00
display "ext0":
resolution: 1080x1920
refresh rate: 60
HiDPI: False
rotation: 90
underscan: 1.00
When I try to open the .pkg I get this error:
“DisplayManager-1.0.2.pkg” can’t be opened because Apple cannot check it for malicious software.
This software needs to be updated. Contact the developer for more information.
Safari downloaded this file today at 5:00 PM from github-production-release-asset-2e65be.s3.amazonaws.com.
ProductName: Mac OS X
ProductVersion: 10.14.5
BuildVersion: 18F132
Hi!
I recently managed to test in an actual macOS (I was testing in a macOS VM, in which many features, including your module, was not working).
I am running this on mac mini with Catalina (10.15.7) and Python 3.8.2 (let me know if you need other details)
When executing this:
import Quartz
from ._display_manager_lib import Display # display_manager_lib.py is directly taken from your repo, and not modified at all
self.handle = Quartz.CGMainDisplayID()
self._dm = Display(self.handle)
I receive this error:
2023-10-16 21:26:19.022 Python[502:4685] *** Assertion failure in +[UINSServiceViewController initialize], /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/ViewBridge/ViewBridge-468/UINSServiceViewController.m:203
The origin of this error is within getIOKit()
function, but all its content is totally alien to me, sorry. There is no error if you just comment getIOKit()
in Display's class __init__()
method, but rationally all related functions do not work.
If, in addition, I run this:
self._dm.brightness() # returns None
self._dm.setBrightness(50) # This crashes (see below)
I get this error:
Traceback (most recent call last):
File "test.py", line 12, in <module>
mon1.setBrightness(50)
File "/Users/Angel/Library/Python/3.8/lib/python/site-packages/pymonctl/_pymonctl_macos.py", line 320, in setBrightness
self._dm.setBrightness(brightness)
File "/Users/Angel/Library/Python/3.8/lib/python/site-packages/pymonctl/_display_manager_lib.py", line 449, in setBrightness
raise DisplayError("Cannot manage brightness on display \"{}\"".format(self.tag))
pymonctl._display_manager_lib.DisplayError: Cannot manage brightness on display "main"
I know I'm using your module in a non-standard way but, if you can bring some light to this problem, I would really appreciate it!
I had some scripts that were using display_manager.py show exact
and display_manager.py set closest
and they no longer seem to work. In fact, they no longer seem to exist at all.
def setBrightness(self, brightness):
"""
:param brightness: The desired brightness, from 0 to 1.
"""
error = iokit["IODisplaySetFloatParameter"](self.__servicePort, 0, iokit["kDisplayBrightness"], brightness)
if error:
if self.isMain:
raise DisplayError("Cannot manage brightness on display \"{}\"".format(self.tag))
else:
raise DisplayError(
"Display \"{}\"\'s brightness cannot be set.\n"
"External displays may not be compatible with Display Manager. "
"Try setting manually on device hardware.".format(self.tag))
I wanted to use this code for my project as I am unable to find a way to change the macos brightness from python and this library is one caught my eye but it clearly doesnt support changing main display brightness , or I am just understanding it wrong.
Hi! Thank you so much for your work and for sharing it!
I am working on a new module aimed to get info and control monitors (specially in multi-monitor setups). You can check it here if you are curious. Struggling with macOS I found your module very useful but, since it is not available on PyPi (I already read in a reply of yours that it is not planned), I was wondering the best way to integrate it into my own module. I just need the rotation and brightness functions (no way to also deal with contrast and scale, there is?), but I felt that I had to ask before just copy-pasting the related code or the display_manager_lib.py file (of course, adding the license in all cases).
Thanks in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.