How to change Mac display brightness from cocoa application?
相关问题
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
- Advice for supporting both Mac and Windows Desktop
- Avoid cmake to add the flags -search_paths_first a
- NSOutlineView drag line stuck + blue border
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- ImportError: No module named twisted.persisted.sty
- How can I vertically align my status bar item text
- Converting (u)int64_t to NSNumbers
in Xcode 8 beta 6 does not compile:
Cannot convert value of type 'String' to expected argument type 'CFString!'
so let' cast it:
From Alec Jacobson's Brightness Menu source code:
Expanding on Alex's answer:
In Xcode8 beta3 with Swift3, the code is a lot more streamlined.
CGDisplayIOServicePort
is deprecated in OS 10.9 – so you have to useIOServiceGetMatchingServices
to get the service parameter forIODisplaySetFloatParameter
. Here's a basic function that looks for services named "display" and changes their brightness.And in Swift (via @Dov):
(code is open source of course)