Compare commits

...
6 Commits
9 changed files with 105 additions and 37 deletions
+4
View File
@@ -29,6 +29,7 @@
60C44AFD20A373A100C0EC91 /* MusicBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */; };
60F7D454208CC31400ABF5D2 /* InputSourceBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */; };
B0008E552080286C003AD4DD /* SupportHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0008E542080286C003AD4DD /* SupportHelpers.swift */; };
B002E642216C0E38002774BA /* CoreDisplay.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B002E641216C0E38002774BA /* CoreDisplay.framework */; };
B00D181D2152F4A5000806F4 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B00D181C2152F4A5000806F4 /* Sparkle.framework */; };
B00D181F2152F521000806F4 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = B00D181C2152F4A5000806F4 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
B04B7BB72087398C00C835D0 /* BatteryBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */; };
@@ -99,6 +100,7 @@
60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicBarItem.swift; sourceTree = "<group>"; };
60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputSourceBarItem.swift; sourceTree = "<group>"; };
B0008E542080286C003AD4DD /* SupportHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportHelpers.swift; sourceTree = "<group>"; };
B002E641216C0E38002774BA /* CoreDisplay.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreDisplay.framework; path = ../../../../../System/Library/Frameworks/CoreDisplay.framework; sourceTree = "<group>"; };
B00D181C2152F4A5000806F4 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatteryBarItem.swift; sourceTree = "<group>"; };
B05600D22083E9BB00EB218D /* CustomSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSlider.swift; sourceTree = "<group>"; };
@@ -143,6 +145,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B002E642216C0E38002774BA /* CoreDisplay.framework in Frameworks */,
B081732A2135F354005D4908 /* CoreBrightness.framework in Frameworks */,
B059D62D205F11E8006E6B86 /* DFRFoundation.framework in Frameworks */,
B09EB1E6207C0F8E00D5C1E0 /* MultitouchSupport.framework in Frameworks */,
@@ -163,6 +166,7 @@
B059D62B205F11E8006E6B86 /* Frameworks */ = {
isa = PBXGroup;
children = (
B002E641216C0E38002774BA /* CoreDisplay.framework */,
B00D181C2152F4A5000806F4 /* Sparkle.framework */,
B08173292135F354005D4908 /* CoreBrightness.framework */,
B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */,
+2 -2
View File
@@ -46,7 +46,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
@objc func toggleControlStrip(_ sender: Any?) {
TouchBarController.shared.controlStripState = !TouchBarController.shared.controlStripState
TouchBarController.shared.showControlStripState = !TouchBarController.shared.showControlStripState
createMenu()
TouchBarController.shared.resetControlStrip()
}
@@ -96,7 +96,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
startAtLogin.state = LaunchAtLoginController().launchAtLogin ? .on : .off
let hideControlStrip = NSMenuItem(title: "Hide Control Strip", action: #selector(toggleControlStrip(_:)), keyEquivalent: "T")
hideControlStrip.state = TouchBarController.shared.controlStripState ? .on : .off
hideControlStrip.state = TouchBarController.shared.showControlStripState ? .off : .on
let settingSeparator = NSMenuItem(title: "Settings", action: nil, keyEquivalent: "")
settingSeparator.isEnabled = false
+2 -2
View File
@@ -28,7 +28,7 @@ typedef struct {
} Status;
@interface CBBlueLightClient: NSObject
- (BOOL) setEnabled:(BOOL)enabled;
- (BOOL) setMode:(int)mode;
- (BOOL) setEnabled: (BOOL)enabled;
- (BOOL) setMode: (int)mode;
- (void) getBlueLightStatus: (Status *)status;
@end
@@ -20,4 +20,7 @@ CF_EXPORT IOReturn MTActuatorClose(CFTypeRef actuatorRef);
CF_EXPORT IOReturn MTActuatorActuate(CFTypeRef actuatorRef, SInt32 actuationID, UInt32 arg1, Float32 arg2, Float32 arg3);
CF_EXPORT bool MTActuatorIsOpen(CFTypeRef actuatorRef);
CF_EXPORT void CoreDisplay_Display_SetUserBrightness(int CGDirectDisplayID, double level);
CF_EXPORT double CoreDisplay_Display_GetUserBrightness(int CGDirectDisplayID);
NS_ASSUME_NONNULL_END
+22 -2
View File
@@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.18.2</string>
<string>0.18.5</string>
<key>CFBundleVersion</key>
<string>21</string>
<string>55</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
@@ -28,8 +28,20 @@
<true/>
<key>NSAppleEventsUsageDescription</key>
<string>AppleEvents needed for correct work AppleScript</string>
<key>NSAppleMusicUsageDescription</key>
<string>MTMR needs access to Media for work</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>MTMR needs access to Bluetooth for work</string>
<key>NSCalendarsUsageDescription</key>
<string>MTMR needs access to Calendar for work</string>
<key>NSCameraUsageDescription</key>
<string>MTMR needs access to Camera for work</string>
<key>NSHomeKitUsageDescription</key>
<string>MTMR needs access to HomeKit for work</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 Anton Palgunov. All rights reserved.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Weather widget need your location for correct work</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Weather widget need your location for correct work</string>
<key>NSLocationUsageDescription</key>
@@ -38,11 +50,19 @@
<string>Weather widget need your location for correct work</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>MTMR needs access to Photo for work</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSRemindersUsageDescription</key>
<string>MTMR needs access to Reminders for work</string>
<key>NSSystemAdministrationUsageDescription</key>
<string>MTMR needs access to Administation for work</string>
<key>SUFeedURL</key>
<string>https://mtmr.app/appcast.xml</string>
<key>SUPublicDSAKeyFile</key>
<string>dsa_pub.pem</string>
<key>kTCCServiceMediaLibrary</key>
<string>MTMR needs access to Music for work</string>
</dict>
</plist>
+14 -17
View File
@@ -74,17 +74,15 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
var scrollArea: NSCustomTouchBarItem?
var centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
var controlStripState: Bool {
var showControlStripState: Bool {
get {
return UserDefaults.standard.bool(forKey: "com.toxblh.mtmr.settings.showControlStrip")
}
set {
UserDefaults.standard.set(!controlStripState, forKey: "com.toxblh.mtmr.settings.showControlStrip")
UserDefaults.standard.set(newValue, forKey: "com.toxblh.mtmr.settings.showControlStrip")
}
}
var touchbarNeedRefresh: Bool = true
var blacklistAppIdentifiers: [String] = []
var frontmostApplicationIdentifier: String? {
get {
@@ -150,11 +148,13 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
func updateActiveApp() {
if self.blacklistAppIdentifiers.index(of: self.frontmostApplicationIdentifier!) != nil {
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, false)
self.touchbarNeedRefresh = true
dismissTouchBar()
} else {
presentTouchBar()
self.touchbarNeedRefresh = false
if self.showControlStripState {
updateControlStripPresence()
} else {
presentSystemModal(touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
}
}
}
@@ -172,7 +172,6 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
func reloadPreset(path: String) {
lastPresetPath = path
let items = path.fileData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
touchbarNeedRefresh = true
createAndUpdatePreset(newJsonItems: items)
}
@@ -207,7 +206,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
let item = NSCustomTouchBarItem(identifier: .controlStripItem)
item.view = NSButton(image: #imageLiteral(resourceName: "StatusImage"), target: self, action: #selector(presentTouchBar))
NSTouchBarItem.addSystemTrayItem(item)
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, true)
updateControlStripPresence()
}
func updateControlStripPresence() {
@@ -215,18 +214,16 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
}
@objc private func presentTouchBar() {
if touchbarNeedRefresh {
if self.controlStripState {
presentSystemModal(touchBar, systemTrayItemIdentifier: .controlStripItem)
} else {
presentSystemModal(touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
}
if self.showControlStripState {
presentSystemModal(touchBar, systemTrayItemIdentifier: .controlStripItem)
} else {
presentSystemModal(touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
}
}
@objc private func dismissTouchBar() {
self.touchbarNeedRefresh = true
minimizeSystemModal(touchBar)
updateControlStripPresence()
}
@objc func resetControlStrip() {
+19 -10
View File
@@ -18,7 +18,7 @@ class BrightnessViewController: NSCustomTouchBarItem {
sliderItem.action = #selector(BrightnessViewController.sliderValueChanged(_:))
sliderItem.minValue = 0.0
sliderItem.maxValue = 100.0
sliderItem.floatValue = getBrightness()*100
sliderItem.floatValue = getBrightness() * 100
self.view = sliderItem
@@ -47,17 +47,26 @@ class BrightnessViewController: NSCustomTouchBarItem {
}
private func getBrightness() -> Float32 {
var level: Float32 = 0.5
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"))
IODisplayGetFloatParameter(service, 0, kIODisplayBrightnessKey as CFString, &level)
return level
if #available(OSX 10.13, *) {
return Float32(CoreDisplay_Display_GetUserBrightness(0));
} else {
var level: Float32 = 0.5
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"))
IODisplayGetFloatParameter(service, 0, kIODisplayBrightnessKey as CFString, &level)
return level
}
}
private func setBrightness(level: Float) {
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"))
IODisplaySetFloatParameter(service, 0, kIODisplayBrightnessKey as CFString, level)
IOObjectRelease(service)
if #available(OSX 10.13, *) {
CoreDisplay_Display_SetUserBrightness(0, Double(level));
} else {
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"))
IODisplaySetFloatParameter(service, 1, kIODisplayBrightnessKey as CFString, level)
IOObjectRelease(service)
}
}
}
+1 -1
View File
@@ -55,7 +55,7 @@ class GroupBarItem: NSPopoverTouchBarItem, NSTouchBarDelegate {
TouchBarController.shared.touchBar.defaultItemIdentifiers = []
TouchBarController.shared.touchBar.defaultItemIdentifiers = self.leftIdentifiers + [centerScrollArea] + self.rightIdentifiers
if TouchBarController.shared.controlStripState {
if TouchBarController.shared.showControlStripState {
presentSystemModal(TouchBarController.shared.touchBar, systemTrayItemIdentifier: .controlStripItem)
} else {
presentSystemModal(TouchBarController.shared.touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
+38 -3
View File
@@ -20,7 +20,42 @@ NAME_DMG="${NAME}.app"
echo $NAME_DMG
create-dmg $NAME_DMG
VERSION=`mdls -raw -name kMDItemVersion ${NAME}.app`
DATE=`date +"%a, %d %b %Y %H:%M:%S %z"`
BUILD=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ${NAME}.app/Contents/Info.plist`
VERSION=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" ${NAME}.app/Contents/Info.plist`
MINIMUM=`/usr/libexec/PlistBuddy -c "Print LSMinimumSystemVersion" ${NAME}.app/Contents/Info.plist`
SIZE=`stat -f%z MTMR\ ${VERSION}.dmg`
SIGN=`~/Sparkle/bin/sign_update MTMR\ ${VERSION}.dmg ~/Sparkle/bin/dsa_priv.pem | awk '{printf "%s",$0} END {print ""}'`
echo $VERSION
ditto -c -k --sequesterRsrc --keepParent "${NAME}.app" "${NAME}v${VERSION}.zip"
# ditto -c -k --sequesterRsrc --keepParent "${NAME}.app" "${NAME}v${VERSION}.zip"
echo DATE $DATE
echo VERSION $VERSION
echo BUILD $BUILD
echo MINIMUM $MINIMUM
echo SIZE $SIZE
echo SIGN ${SIGN}
echo "<?xml version=\"1.0\" standalone=\"yes\"?>
<rss xmlns:sparkle=\"http://www.andymatuschak.org/xml-namespaces/sparkle\" version=\"2.0\">
<channel>
<item>
<title>${VERSION}</title>
<pubDate>${DATE}</pubDate>
<description>
${1}
</description>
<sparkle:minimumSystemVersion>${MINIMUM}</sparkle:minimumSystemVersion>
<enclosure url=\"https://mtmr.app/MTMR%20${VERSION}.dmg\"
sparkle:version=\"${BUILD}\"
sparkle:shortVersionString=\"${VERSION}\"
length=\"${SIZE}\"
type=\"application/octet-stream\"
sparkle:dsaSignature=\"${SIGN}\"
/>
</item>
</channel>
</rss>" > appcast.xml
scp MTMR\ ${VERSION}.dmg do:/var/www/mtmr
scp appcast.xml do:/var/www/mtmr