Skip to content

Commit

Permalink
v6.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alin23 committed Mar 18, 2023
1 parent e5c87d2 commit d9483f5
Show file tree
Hide file tree
Showing 16 changed files with 357 additions and 67 deletions.
12 changes: 8 additions & 4 deletions Lunar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
C731E85E27E1E5090016B36D /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = C731E85D27E1E5090016B36D /* Sentry */; };
C73716A526DE1F22008EEE53 /* CBTrueToneClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C737169E26DE1F22008EEE53 /* CBTrueToneClient.h */; };
C73716A726DE1F22008EEE53 /* CBAdaptationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C73716A426DE1F22008EEE53 /* CBAdaptationClient.h */; };
C73A4E6229C5EAFC006A22F3 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = C73A4E6129C5EAFC006A22F3 /* Localizable.stringsdict */; };
C73AAC4B22241B690063AD2A /* Hotkeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = C73AAC4A22241B690063AD2A /* Hotkeys.swift */; };
C73B41EC263BE02E006F6783 /* LetsMove.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C73B41EA263BE01F006F6783 /* LetsMove.framework */; };
C73B41ED263BE02E006F6783 /* LetsMove.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C73B41EA263BE01F006F6783 /* LetsMove.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -231,6 +232,7 @@
C735DD791FD5C04D00FBD16F /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
C737169E26DE1F22008EEE53 /* CBTrueToneClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBTrueToneClient.h; sourceTree = "<group>"; };
C73716A426DE1F22008EEE53 /* CBAdaptationClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBAdaptationClient.h; sourceTree = "<group>"; };
C73A4E6129C5EAFC006A22F3 /* Localizable.stringsdict */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; path = Localizable.stringsdict; sourceTree = "<group>"; };
C73AAC4A22241B690063AD2A /* Hotkeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hotkeys.swift; sourceTree = "<group>"; };
C73B41EA263BE01F006F6783 /* LetsMove.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = LetsMove.framework; sourceTree = "<group>"; };
C73B41F5263E1301006F6783 /* ddcctl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ddcctl; path = bin/ddcctl; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -650,6 +652,7 @@
C78BD03D259B2FA300FC823F /* Modes */,
C790D4BC259B9DC100868689 /* Utils */,
C77CC75A1FEDB367009AA718 /* Views */,
C73A4E6129C5EAFC006A22F3 /* Localizable.stringsdict */,
);
path = Lunar;
sourceTree = "<group>";
Expand Down Expand Up @@ -899,6 +902,7 @@
C772802629AE09D900401C78 /* edid-decode in Resources */,
C7AEC7FD1FD0B4350039B562 /* Assets.xcassets in Resources */,
C7AEC8001FD0B4350039B562 /* Main.storyboard in Resources */,
C73A4E6229C5EAFC006A22F3 /* Localizable.stringsdict in Resources */,
C780CF98269F241A007FFB58 /* tsl2591.h in Resources */,
C73B41F6263E1301006F6783 /* ddcctl in Resources */,
C7A2574220EA249B003B3A84 /* dsa_pub.pem in Resources */,
Expand Down Expand Up @@ -1200,7 +1204,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 6.0.0;
CURRENT_PROJECT_VERSION = 6.0.1;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "";
Expand Down Expand Up @@ -1232,7 +1236,7 @@
"$(PROJECT_DIR)/Lunar/CSSH",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.0.1;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CODE_SIGN_FLAGS = "";
OTHER_LDFLAGS = "";
Expand Down Expand Up @@ -1269,7 +1273,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 6.0.0;
CURRENT_PROJECT_VERSION = 6.0.1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
Expand Down Expand Up @@ -1301,7 +1305,7 @@
);
LLVM_LTO = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.0.1;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = fyi.lunar.Lunar;
Expand Down
5 changes: 5 additions & 0 deletions Lunar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, CLLocationManagerDeleg

static var hdrWorkaround: Bool = Defaults[.hdrWorkaround]

static var colorScheme: ColorScheme = {
colorSchemePublisher.sink { AppDelegate.colorScheme = $0.newValue }.store(in: &observers)
return Defaults[.colorScheme]
}()

@Atomic var paddleDismissed = true

var locationManager: CLLocationManager?
Expand Down
5 changes: 5 additions & 0 deletions Lunar/Controllers/DisplayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,11 @@ final class DisplayViewController: NSViewController {
let brightnessChartEntry = brightnessContrastChart.brightnessGraph.entries
let contrastChartEntry = brightnessContrastChart.contrastGraph.entries

guard !brightnessChartEntry.isEmpty else {
self.initGraphSubject.send(DC.adaptiveModeKey)
return
}

let brColor = darkMode ? white.withAlphaComponent(0.5) : violet
var gradient: CGGradient?

Expand Down
50 changes: 49 additions & 1 deletion Lunar/Controllers/QuickActionsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,8 @@ struct QuickActionsLayoutView: View {
@Default(.hideMenuBarIcon) var hideMenuBarIcon
@Default(.showDockIcon) var showDockIcon
@Default(.moreGraphData) var moreGraphData
@Default(.infoMenuShown) var infoMenuShown
@Default(.adaptiveBrightnessMode) var adaptiveBrightnessMode

var body: some View {
ZStack {
Expand Down Expand Up @@ -1428,6 +1430,9 @@ struct QuickActionsLayoutView: View {
}
Divider()
Group {
if adaptiveBrightnessMode.hasUsefulInfo {
SettingsToggle(text: "Show useful adaptive info near mode selector", setting: $infoMenuShown.animation(.fastSpring))
}
if dc.activeDisplayList.contains(where: \.hasDDC) {
SettingsToggle(text: "Show last raw values sent to the display", setting: $showRawValues.animation(.fastSpring))
}
Expand Down Expand Up @@ -1727,11 +1732,13 @@ struct QuickActionsMenuView: View {
@Namespace var namespace

@Default(.overrideAdaptiveMode) var overrideAdaptiveMode
@Default(.adaptiveBrightnessMode) var adaptiveBrightnessMode
@Default(.showStandardPresets) var showStandardPresets
@Default(.showCustomPresets) var showCustomPresets
@Default(.showHeaderOnHover) var showHeaderOnHover
@Default(.showFooterOnHover) var showFooterOnHover
@Default(.showOptionsMenu) var showOptionsMenu
@Default(.infoMenuShown) var infoMenuShown
@Default(.menuBarClosed) var menuBarClosed
@Default(.menuDensity) var menuDensity

Expand Down Expand Up @@ -1760,8 +1767,8 @@ struct QuickActionsMenuView: View {
@ObservedObject var menuBarIcon: StatusItemButtonController

@ObservedObject var km = KM

@ObservedObject var wm = WM
@ObservedObject var ami = AMI

var modeSelector: some View {
let titleBinding = Binding<String>(
Expand Down Expand Up @@ -1999,11 +2006,52 @@ struct QuickActionsMenuView: View {
}
}

var usefulInfoText: (String, String)? {
guard infoMenuShown else { return nil }

switch adaptiveBrightnessMode {
case .sync:
#if arch(arm64)
guard SyncMode.syncNits, let nits = ami.nits else {
return nil
}
return (nits.intround.s, "nits")
#else
return nil
#endif
case .sensor:
guard let lux = ami.lux else {
return nil
}
return (lux > 10 ? lux.intround.s : lux.str(decimals: 1), "lux")
case .location:
guard let elevation = ami.sunElevation else {
return nil
}
return ("\((elevation >= 10 || elevation <= -10) ? elevation.intround.s : elevation.str(decimals: 1))°", "sun")
default:
return nil
}
}

@ViewBuilder var usefulInfo: some View {
if let (t1, t2) = usefulInfoText {
VStack(spacing: -2) {
Text(t1)
.font(.system(size: 10, weight: .bold, design: .monospaced).leading(.tight))
Text(t2)
.font(.system(size: 9, weight: .semibold, design: .rounded).leading(.tight))
}
.foregroundColor(.secondary)
}
}

var header: some View {
let op = (showHeaderOnHover && !showOptionsMenu) ? headerOpacity : 1.0
return ZStack {
HStack {
modeSelector.fixedSize()
usefulInfo.fixedSize()
Spacer()
topRightButtons.fixedSize()
}
Expand Down
14 changes: 11 additions & 3 deletions Lunar/Data/Display.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3557,7 +3557,14 @@ let AUDIO_IDENTIFIER_UUID_PATTERN = "([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{4})-[0
self.readapt(newValue: false, oldValue: true)
}

@Published var nits: Double? = nil
@Published var nits: Double? = nil {
didSet {
guard isActiveSyncSource else { return }
Task.init {
await MainActor.run { AMI.nits = nits }
}
}
}
lazy var nitsToPercentageMapping: [AutoLearnMapping] = Self.LUX_TO_NITS.sorted(by: { $0.key < $1.key }).map { k, v in
AutoLearnMapping(source: k, target: nitsToPercentage(v, minNits: minNits, maxNits: userMaxNits ?? maxNits) * 100)
}
Expand Down Expand Up @@ -3847,10 +3854,11 @@ let AUDIO_IDENTIFIER_UUID_PATTERN = "([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{4})-[0

func getPowerOffTooltip(hasDDC: Bool? = nil) -> String {
#if arch(arm64)
let disconnect: Bool
if #available(macOS 13, *) {
let disconnect = CachedDefaults[.newBlackOutDisconnect]
disconnect = CachedDefaults[.newBlackOutDisconnect]
} else {
let disconnect = false
disconnect = false
}
#else
let disconnect = false
Expand Down
2 changes: 1 addition & 1 deletion Lunar/Data/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let logoColor = lunarYellow
let settingsDividerColor = white.withAlphaComponent(0.3)

var darkMode: Bool {
switch CachedDefaults[.colorScheme] {
switch AppDelegate.colorScheme {
case .system:
return (UserDefaults.standard.string(forKey: "AppleInterfaceStyle") ?? "Light") == "Dark"
case .light:
Expand Down
2 changes: 1 addition & 1 deletion Lunar/Data/Util.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ class ExpiringOptional<T>: ExpressibleByNilLiteral, CustomStringConvertible, Obs
return
}

if value == nil {
if self.value == nil {
set(value, expireAfter: 1)
} else {
refresh(expireAfter: 1)
Expand Down
40 changes: 40 additions & 0 deletions Lunar/Localizable.stringsdict
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist
PUBLIC '-//Apple//DTD PLIST 1.0//EN'
'http://www.apple.com/DTDs/PropertyList-1.0.dtd'>
<plist version="1.0">
<dict>
<key>Screen</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@VARIABLE@</string>
<key>VARIABLE</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>one</key>
<string>Screen</string>
<key>other</key>
<string>Screens</string>
</dict>
</dict>
<key>%lld screens</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@count@</string>
<key>count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>%lld screens</string>
<key>one</key>
<string>%lld screen</string>
<key>other</key>
<string>%lld screens</string>
</dict>
</dict>
</dict>
</plist>
12 changes: 12 additions & 0 deletions Lunar/Modes/AdaptiveMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,15 @@ final class AdaptiveModeMenuValidator: NSObject, NSMenuItemValidation {
}

let adaptiveModeMenuValidator = AdaptiveModeMenuValidator()

@MainActor
final class AdaptiveModeInfo: ObservableObject {
init() {}

@Published var lux: Double?
@Published var nits: Double?
@Published var sunElevation: Double?
}

@MainActor
let AMI = AdaptiveModeInfo()
34 changes: 23 additions & 11 deletions Lunar/Utils/DisplayController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,14 @@ final class DisplayController: ObservableObject {

static var serials: [CGDirectDisplayID: String] = [:]

static var observers: Set<AnyCancellable> = []
static var ddcSleepFactor: DDCSleepFactor = {
ddcSleepFactorPublisher.sink { change in
DisplayController.ddcSleepFactor = change.newValue
}.store(in: &observers)
return Defaults[.ddcSleepFactor]
}()

@Published var calibrating = false

var screencaptureIsRunning: CurrentValueSubject<Bool, Never> = .init(processIsRunning("/usr/sbin/screencapture", nil))
Expand Down Expand Up @@ -2128,16 +2136,18 @@ final class DisplayController: ObservableObject {
display.fallbackPromptTime = Date()
let semaphore = DispatchSemaphore(value: 0, name: "Non-responsive Control Watcher Prompt")
let completionHandler = { (fallbackToGamma: NSApplication.ModalResponse) in
if fallbackToGamma == .alertFirstButtonReturn {
if let control = display.control?.displayControl {
display.enabledControls[control] = false
mainAsync {
if fallbackToGamma == .alertFirstButtonReturn {
if let control = display.control?.displayControl {
display.enabledControls[control] = false
}
display.gammaEnabled = true
display.control = GammaControl(display: display)
display.setGamma()
}
if fallbackToGamma == .alertThirdButtonReturn {
display.neverFallbackControl = true
}
display.gammaEnabled = true
display.control = GammaControl(display: display)
display.setGamma()
}
if fallbackToGamma == .alertThirdButtonReturn {
display.neverFallbackControl = true
}
semaphore.signal()
}
Expand Down Expand Up @@ -2165,8 +2175,10 @@ final class DisplayController: ObservableObject {
window: window,
suppressionText: "Always fallback to software controls for this display when needed",
onSuppression: { fallback in
display.alwaysFallbackControl = fallback
display.save()
mainAsync {
display.alwaysFallbackControl = fallback
display.save()
}
},
onCompletion: completionHandler,
unique: true,
Expand Down
Loading

0 comments on commit d9483f5

Please sign in to comment.