Skip to content

Commit bfc91fd

Browse files
committed
🎉 Smaller increment
- You can now change brightness and volume in smaller increments just like native holding `alt + shift`
1 parent 9657e4b commit bfc91fd

File tree

8 files changed

+38
-30
lines changed

8 files changed

+38
-30
lines changed

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github "the0neyouseek/MediaKeyTap" "master"
1+
github "the0neyouseek/MediaKeyTap"
22
github "reitermarkus/DDC.swift" "master"
33
github "rnine/AMCoreAudio"
44
github "shpakovski/MASPreferences"

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
github "reitermarkus/DDC.swift" "5c03666e17a1a850892c08a5db6f4a208f762f26"
22
github "rnine/AMCoreAudio" "3.3"
33
github "shpakovski/MASPreferences" "1.3"
4-
github "the0neyouseek/MediaKeyTap" "abfe09f53ccabb1aa14a0f4ab99cfb8812f41919"
4+
github "the0neyouseek/MediaKeyTap" "3.1.0"

MonitorControl.xcodeproj/project.pbxproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
isa = PBXProject;
313313
attributes = {
314314
LastSwiftUpdateCheck = 0920;
315-
LastUpgradeCheck = 1020;
315+
LastUpgradeCheck = 1100;
316316
ORGANIZATIONNAME = "Guillaume Broder";
317317
TargetAttributes = {
318318
56754EAA1D9A4016007BCDC5 = {
@@ -634,7 +634,9 @@
634634
CODE_SIGN_IDENTITY = "Mac Developer";
635635
CODE_SIGN_STYLE = Automatic;
636636
COMBINE_HIDPI_IMAGES = YES;
637+
CURRENT_PROJECT_VERSION = 560;
637638
DEVELOPMENT_TEAM = KGY56RWR9A;
639+
ENABLE_HARDENED_RUNTIME = YES;
638640
FRAMEWORK_SEARCH_PATHS = (
639641
"$(inherited)",
640642
"$(PROJECT_DIR)/Carthage/Build/Mac",
@@ -643,6 +645,7 @@
643645
);
644646
INFOPLIST_FILE = MonitorControl/Info.plist;
645647
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
648+
MARKETING_VERSION = 1.6.0;
646649
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControl;
647650
PRODUCT_NAME = "$(TARGET_NAME)";
648651
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -658,7 +661,9 @@
658661
CODE_SIGN_IDENTITY = "Mac Developer";
659662
CODE_SIGN_STYLE = Automatic;
660663
COMBINE_HIDPI_IMAGES = YES;
664+
CURRENT_PROJECT_VERSION = 560;
661665
DEVELOPMENT_TEAM = KGY56RWR9A;
666+
ENABLE_HARDENED_RUNTIME = YES;
662667
FRAMEWORK_SEARCH_PATHS = (
663668
"$(inherited)",
664669
"$(PROJECT_DIR)/Carthage/Build/Mac",
@@ -667,6 +672,7 @@
667672
);
668673
INFOPLIST_FILE = MonitorControl/Info.plist;
669674
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
675+
MARKETING_VERSION = 1.6.0;
670676
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControl;
671677
PRODUCT_NAME = "$(TARGET_NAME)";
672678
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -686,10 +692,13 @@
686692
CODE_SIGN_IDENTITY = "Mac Developer";
687693
CODE_SIGN_STYLE = Automatic;
688694
COMBINE_HIDPI_IMAGES = YES;
695+
CURRENT_PROJECT_VERSION = 560;
689696
DEVELOPMENT_TEAM = KGY56RWR9A;
697+
ENABLE_HARDENED_RUNTIME = YES;
690698
GCC_C_LANGUAGE_STANDARD = gnu11;
691699
INFOPLIST_FILE = MonitorControlHelper/Info.plist;
692700
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
701+
MARKETING_VERSION = 1.6.0;
693702
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControlHelper;
694703
PRODUCT_NAME = "$(TARGET_NAME)";
695704
SKIP_INSTALL = YES;
@@ -708,10 +717,13 @@
708717
CODE_SIGN_IDENTITY = "Mac Developer";
709718
CODE_SIGN_STYLE = Automatic;
710719
COMBINE_HIDPI_IMAGES = YES;
720+
CURRENT_PROJECT_VERSION = 560;
711721
DEVELOPMENT_TEAM = KGY56RWR9A;
722+
ENABLE_HARDENED_RUNTIME = YES;
712723
GCC_C_LANGUAGE_STANDARD = gnu11;
713724
INFOPLIST_FILE = MonitorControlHelper/Info.plist;
714725
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
726+
MARKETING_VERSION = 1.6.0;
715727
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControlHelper;
716728
PRODUCT_NAME = "$(TARGET_NAME)";
717729
SKIP_INSTALL = YES;

MonitorControl.xcodeproj/xcshareddata/xcschemes/MonitorControl.xcscheme

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1020"
3+
LastUpgradeVersion = "1100"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -27,8 +27,6 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<Testables>
31-
</Testables>
3230
<MacroExpansion>
3331
<BuildableReference
3432
BuildableIdentifier = "primary"
@@ -38,8 +36,8 @@
3836
ReferencedContainer = "container:MonitorControl.xcodeproj">
3937
</BuildableReference>
4038
</MacroExpansion>
41-
<AdditionalOptions>
42-
</AdditionalOptions>
39+
<Testables>
40+
</Testables>
4341
</TestAction>
4442
<LaunchAction
4543
buildConfiguration = "Debug"
@@ -61,8 +59,6 @@
6159
ReferencedContainer = "container:MonitorControl.xcodeproj">
6260
</BuildableReference>
6361
</BuildableProductRunnable>
64-
<AdditionalOptions>
65-
</AdditionalOptions>
6662
</LaunchAction>
6763
<ProfileAction
6864
buildConfiguration = "Release"

MonitorControl/AppDelegate.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,29 +197,29 @@ class AppDelegate: NSObject, NSApplicationDelegate {
197197
// MARK: - Media Key Tap delegate
198198

199199
extension AppDelegate: MediaKeyTapDelegate {
200-
func handle(mediaKey: MediaKey, event _: KeyEvent?) {
200+
func handle(mediaKey: MediaKey, event _: KeyEvent?, modifiers: NSEvent.ModifierFlags?) {
201201
guard let currentDisplay = Utils.getCurrentDisplay(from: displays) else { return }
202202

203203
let allDisplays = prefs.bool(forKey: Utils.PrefKeys.allScreens.rawValue) ? self.displays : [currentDisplay]
204+
let isSmallIncrement = modifiers?.isSuperset(of: NSEvent.ModifierFlags([.shift, .option])) ?? false
204205

205206
for display in allDisplays {
206207
if (prefs.object(forKey: "\(display.identifier)-state") as? Bool) ?? true {
207208
switch mediaKey {
208209
case .brightnessUp:
209-
let value = display.calcNewValue(for: .brightness, withRel: +self.step)
210-
display.setBrightness(to: value)
210+
let value = display.calcNewValue(for: .brightness, withRel: +(isSmallIncrement ? self.step / 4 : self.step))
211+
display.setBrightness(to: value, isSmallIncrement: isSmallIncrement)
211212
case .brightnessDown:
212-
let value = currentDisplay.calcNewValue(for: .brightness, withRel: -self.step)
213-
display.setBrightness(to: value)
213+
let value = currentDisplay.calcNewValue(for: .brightness, withRel: -(isSmallIncrement ? self.step / 4 : self.step))
214+
display.setBrightness(to: value, isSmallIncrement: isSmallIncrement)
214215
case .mute:
215216
display.mute()
216217
case .volumeUp:
217-
let value = display.calcNewValue(for: .audioSpeakerVolume, withRel: +self.step)
218-
display.setVolume(to: value)
218+
let value = display.calcNewValue(for: .audioSpeakerVolume, withRel: +(isSmallIncrement ? self.step / 4 : self.step))
219+
display.setVolume(to: value, isSmallIncrement: isSmallIncrement)
219220
case .volumeDown:
220-
let value = display.calcNewValue(for: .audioSpeakerVolume, withRel: -self.step)
221-
display.setVolume(to: value)
222-
221+
let value = display.calcNewValue(for: .audioSpeakerVolume, withRel: -(isSmallIncrement ? self.step / 4 : self.step))
222+
display.setVolume(to: value, isSmallIncrement: isSmallIncrement)
223223
default:
224224
return
225225
}

MonitorControl/Display.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Display {
7171
}
7272
}
7373

74-
func setVolume(to value: Int) {
74+
func setVolume(to value: Int, isSmallIncrement: Bool = false) {
7575
if value > 0, self.isMuted {
7676
self.mute(forceVolume: value)
7777
} else if value == 0 {
@@ -85,7 +85,7 @@ class Display {
8585
}
8686

8787
self.hideDisplayOsd()
88-
self.showOsd(command: .audioSpeakerVolume, value: value)
88+
self.showOsd(command: .audioSpeakerVolume, value: value, isSmallIncrement: isSmallIncrement)
8989
self.playVolumeChangedSound()
9090
}
9191

@@ -96,7 +96,7 @@ class Display {
9696
self.saveValue(value, for: .audioSpeakerVolume)
9797
}
9898

99-
func setBrightness(to value: Int) {
99+
func setBrightness(to value: Int, isSmallIncrement: Bool = false) {
100100
if self.prefs.bool(forKey: Utils.PrefKeys.lowerContrast.rawValue) {
101101
if value == 0 {
102102
DispatchQueue.global(qos: .userInitiated).async {
@@ -120,7 +120,7 @@ class Display {
120120
return
121121
}
122122

123-
self.showOsd(command: .brightness, value: value)
123+
self.showOsd(command: .brightness, value: value, isSmallIncrement: isSmallIncrement)
124124
}
125125

126126
if let slider = brightnessSliderHandler?.slider {
@@ -161,7 +161,7 @@ class Display {
161161
return self.prefs.string(forKey: "friendlyName-\(self.identifier)") ?? self.name
162162
}
163163

164-
private func showOsd(command: DDC.Command, value: Int) {
164+
private func showOsd(command: DDC.Command, value: Int, isSmallIncrement: Bool = false) {
165165
guard let manager = OSDManager.sharedManager() as? OSDManager else {
166166
return
167167
}
@@ -176,7 +176,7 @@ class Display {
176176
}
177177
}
178178

179-
let step = maxValue / 16
179+
let step = isSmallIncrement ? maxValue / maxValue : maxValue / 16
180180

181181
manager.showImage(osdImage,
182182
onDisplayID: self.identifier,

MonitorControl/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.5.2</string>
20+
<string>$(MARKETING_VERSION)</string>
2121
<key>CFBundleVersion</key>
22-
<string>560</string>
22+
<string>$(CURRENT_PROJECT_VERSION)</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.utilities</string>
2525
<key>LSMinimumSystemVersion</key>

MonitorControlHelper/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.5.2</string>
20+
<string>$(MARKETING_VERSION)</string>
2121
<key>CFBundleVersion</key>
22-
<string>533</string>
22+
<string>$(CURRENT_PROJECT_VERSION)</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.utilities</string>
2525
<key>LSBackgroundOnly</key>

0 commit comments

Comments
 (0)