Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0b10074f8 | ||
|
|
2023ab29f3 | ||
|
|
9a265887cf | ||
|
|
62e87c53f5 | ||
|
|
dbab502d14 | ||
|
|
ae79e8b90e | ||
|
|
d7eddb8484 | ||
|
|
457fa9481e | ||
|
|
69e8e6eefd | ||
|
|
ffc101b455 | ||
|
|
bbe9a1f10e | ||
|
|
71051d7ad0 | ||
|
|
e5136d5991 | ||
|
|
09d9f9618f | ||
|
|
534dbc2284 | ||
|
|
9e0f103ba6 | ||
|
|
c6b6f7bbd5 | ||
|
|
eee4082a1a | ||
|
|
10d94d65e2 | ||
|
|
7de87ad029 | ||
|
|
ad27d26c86 | ||
|
|
ecbd2beb48 | ||
|
|
0aed9a8680 | ||
|
|
1f764d539a | ||
|
|
e95c707009 | ||
|
|
1914dbb08f | ||
|
|
34074a1b9b | ||
|
|
e07ee1e263 | ||
|
|
9228eaffc8 | ||
|
|
f89871d294 | ||
|
|
8e35d38b59 | ||
|
|
17e023d2d2 | ||
|
|
dc94857ac4 | ||
|
|
ec228fddde | ||
|
|
958f93f440 | ||
|
|
d03b16eb89 | ||
|
|
ea573882a0 | ||
|
|
7fb936bd1d | ||
|
|
f97a3be6d3 | ||
|
|
3bc26eae82 | ||
|
|
f84463dbb2 | ||
|
|
46c86a71de | ||
|
|
ad70c034da | ||
|
|
221565f604 | ||
|
|
6ca7f11a2b | ||
|
|
63795b3d41 | ||
|
|
8a7de99bce | ||
|
|
7f13422805 | ||
|
|
56d64155ae | ||
|
|
088f141da3 | ||
|
|
091208e536 | ||
|
|
c6f6fbc5cd | ||
|
|
3cdf44903b | ||
|
|
e13e8598a7 | ||
|
|
d82c837902 | ||
|
|
d5483cdd03 | ||
|
|
9f2dd277fb | ||
|
|
e7c949209d | ||
|
|
42d3d29e0d | ||
|
|
6674b5aef7 | ||
|
|
f83f331a99 | ||
|
|
cd16c09dbd | ||
|
|
4ba9d11494 |
@@ -1,6 +1,6 @@
|
||||
language: swift
|
||||
xcode_project: MTMR.xcodeproj
|
||||
xcode_scheme: UnitTests
|
||||
osx_image: xcode9.3
|
||||
osx_image: xcode10
|
||||
install: gem install xcpretty
|
||||
script: "xcodebuild test -project MTMR.xcodeproj -scheme 'UnitTests' | xcpretty -c && exit ${PIPESTATUS[0]}"
|
||||
|
||||
@@ -18,20 +18,28 @@
|
||||
36C2ECDD207C723B003CDA33 /* ParseConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36C2ECDC207C723B003CDA33 /* ParseConfigTests.swift */; };
|
||||
36C2ECDE207C82DE003CDA33 /* ItemsParsing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36C2ECDA207C3FE7003CDA33 /* ItemsParsing.swift */; };
|
||||
36C2ECE0207CB1B0003CDA33 /* defaultPreset.json in Resources */ = {isa = PBXBuildFile; fileRef = 36C2ECDF207CB1B0003CDA33 /* defaultPreset.json */; };
|
||||
60173D3E20C0031B002C305F /* LaunchAtLoginController.m in Sources */ = {isa = PBXBuildFile; fileRef = 60173D3D20C0031B002C305F /* LaunchAtLoginController.m */; };
|
||||
6027D1B92080E52A004FFDC7 /* BrightnessViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */; };
|
||||
6027D1BA2080E52A004FFDC7 /* VolumeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */; };
|
||||
6042B6A72083E03A00C525C8 /* AppScrubberTouchBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6042B6A62083E03A00C525C8 /* AppScrubberTouchBarItem.swift */; };
|
||||
6042B6AA2083E27000C525C8 /* DeprecatedCarbonAPI.c in Sources */ = {isa = PBXBuildFile; fileRef = 6042B6A92083E27000C525C8 /* DeprecatedCarbonAPI.c */; };
|
||||
60669B4320AD8FA80074E817 /* GroupBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60669B4220AD8FA80074E817 /* GroupBarItem.swift */; };
|
||||
607EEA4B2087835F009DA5F0 /* WeatherBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607EEA4A2087835F009DA5F0 /* WeatherBarItem.swift */; };
|
||||
607EEA4D2087A8DA009DA5F0 /* CurrencyBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607EEA4C2087A8DA009DA5F0 /* CurrencyBarItem.swift */; };
|
||||
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 */; };
|
||||
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 */; };
|
||||
B05600D32083E9BB00EB218D /* CustomSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B05600D22083E9BB00EB218D /* CustomSlider.swift */; };
|
||||
B059D622205E03F5006E6B86 /* TouchBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B059D621205E03F5006E6B86 /* TouchBarController.swift */; };
|
||||
B059D624205E04F3006E6B86 /* CustomButtonTouchBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B059D623205E04F3006E6B86 /* CustomButtonTouchBarItem.swift */; };
|
||||
B059D62D205F11E8006E6B86 /* DFRFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B059D62C205F11E8006E6B86 /* DFRFoundation.framework */; };
|
||||
B0679BC1215AE73F000FC6B4 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = B0679BC0215AE73F000FC6B4 /* dsa_pub.pem */; };
|
||||
B08173272135F02B005D4908 /* NightShiftBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B08173262135F02B005D4908 /* NightShiftBarItem.swift */; };
|
||||
B081732A2135F354005D4908 /* CoreBrightness.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B08173292135F354005D4908 /* CoreBrightness.framework */; };
|
||||
B081732C213739FE005D4908 /* DnDBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B081732B213739FE005D4908 /* DnDBarItem.swift */; };
|
||||
B082B253205C7D8000BC04DC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B082B252205C7D8000BC04DC /* AppDelegate.swift */; };
|
||||
B082B257205C7D8000BC04DC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B082B256205C7D8000BC04DC /* Assets.xcassets */; };
|
||||
B082B25A205C7D8000BC04DC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B082B258205C7D8000BC04DC /* Main.storyboard */; };
|
||||
@@ -48,9 +56,23 @@
|
||||
B0B17438207D6B590004B740 /* Vox.next.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B0B1742E207D6B590004B740 /* Vox.next.scpt */; };
|
||||
B0B17439207D6B590004B740 /* Vox.nowPlaying.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B0B1742F207D6B590004B740 /* Vox.nowPlaying.scpt */; };
|
||||
B0B1743A207D6B590004B740 /* iTunes.nowPlaying.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B0B17430207D6B590004B740 /* iTunes.nowPlaying.scpt */; };
|
||||
B0F3112520C9E35F0076BB88 /* SupportNSTouchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F3112420C9E35F0076BB88 /* SupportNSTouchBar.swift */; };
|
||||
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
B00D181E2152F507000806F4 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 12;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
B00D181F2152F521000806F4 /* Sparkle.framework in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
36300E85209FD16700B31C71 /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .travis.yml; sourceTree = SOURCE_ROOT; };
|
||||
36300E8E20A2CF3400B31C71 /* AppleScriptDefinitionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleScriptDefinitionTests.swift; sourceTree = "<group>"; };
|
||||
@@ -64,16 +86,20 @@
|
||||
36C2ECDA207C3FE7003CDA33 /* ItemsParsing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemsParsing.swift; sourceTree = "<group>"; };
|
||||
36C2ECDC207C723B003CDA33 /* ParseConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParseConfigTests.swift; sourceTree = "<group>"; };
|
||||
36C2ECDF207CB1B0003CDA33 /* defaultPreset.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = defaultPreset.json; sourceTree = "<group>"; };
|
||||
60173D3C20C0031B002C305F /* LaunchAtLoginController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LaunchAtLoginController.h; sourceTree = "<group>"; };
|
||||
60173D3D20C0031B002C305F /* LaunchAtLoginController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LaunchAtLoginController.m; sourceTree = "<group>"; };
|
||||
6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BrightnessViewController.swift; sourceTree = "<group>"; };
|
||||
6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VolumeViewController.swift; sourceTree = "<group>"; };
|
||||
6042B6A62083E03A00C525C8 /* AppScrubberTouchBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppScrubberTouchBarItem.swift; sourceTree = "<group>"; };
|
||||
6042B6A82083E1F500C525C8 /* DeprecatedCarbonAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeprecatedCarbonAPI.h; sourceTree = "<group>"; };
|
||||
6042B6A92083E27000C525C8 /* DeprecatedCarbonAPI.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = DeprecatedCarbonAPI.c; sourceTree = "<group>"; };
|
||||
60669B4220AD8FA80074E817 /* GroupBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupBarItem.swift; sourceTree = "<group>"; };
|
||||
607EEA4A2087835F009DA5F0 /* WeatherBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherBarItem.swift; sourceTree = "<group>"; };
|
||||
607EEA4C2087A8DA009DA5F0 /* CurrencyBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyBarItem.swift; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
B059D621205E03F5006E6B86 /* TouchBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchBarController.swift; sourceTree = "<group>"; };
|
||||
@@ -81,6 +107,11 @@
|
||||
B059D629205E13E5006E6B86 /* TouchBarPrivateApi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarPrivateApi.h; sourceTree = "<group>"; };
|
||||
B059D62A205F0E7D006E6B86 /* TouchBarPrivateApi-Bridging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TouchBarPrivateApi-Bridging.h"; sourceTree = "<group>"; };
|
||||
B059D62C205F11E8006E6B86 /* DFRFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DFRFoundation.framework; path = ../../../../../System/Library/PrivateFrameworks/DFRFoundation.framework; sourceTree = "<group>"; };
|
||||
B0679BC0215AE73F000FC6B4 /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = "<group>"; };
|
||||
B08173262135F02B005D4908 /* NightShiftBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NightShiftBarItem.swift; sourceTree = "<group>"; };
|
||||
B08173282135F128005D4908 /* CBBlueLightClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBBlueLightClient.h; sourceTree = "<group>"; };
|
||||
B08173292135F354005D4908 /* CoreBrightness.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreBrightness.framework; path = ../../../../../System/Library/PrivateFrameworks/CoreBrightness.framework; sourceTree = "<group>"; };
|
||||
B081732B213739FE005D4908 /* DnDBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DnDBarItem.swift; sourceTree = "<group>"; };
|
||||
B082B24F205C7D8000BC04DC /* MTMR.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MTMR.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B082B252205C7D8000BC04DC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
B082B256205C7D8000BC04DC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
@@ -102,6 +133,7 @@
|
||||
B0B1742E207D6B590004B740 /* Vox.next.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Vox.next.scpt; sourceTree = "<group>"; };
|
||||
B0B1742F207D6B590004B740 /* Vox.nowPlaying.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Vox.nowPlaying.scpt; sourceTree = "<group>"; };
|
||||
B0B17430207D6B590004B740 /* iTunes.nowPlaying.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = iTunes.nowPlaying.scpt; sourceTree = "<group>"; };
|
||||
B0F3112420C9E35F0076BB88 /* SupportNSTouchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportNSTouchBar.swift; sourceTree = "<group>"; };
|
||||
B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TouchBarSupport.m; sourceTree = "<group>"; };
|
||||
B0F8771B207AC92700D6E430 /* TouchBarSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarSupport.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@@ -111,8 +143,10 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B081732A2135F354005D4908 /* CoreBrightness.framework in Frameworks */,
|
||||
B059D62D205F11E8006E6B86 /* DFRFoundation.framework in Frameworks */,
|
||||
B09EB1E6207C0F8E00D5C1E0 /* MultitouchSupport.framework in Frameworks */,
|
||||
B00D181D2152F4A5000806F4 /* Sparkle.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -129,6 +163,8 @@
|
||||
B059D62B205F11E8006E6B86 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B00D181C2152F4A5000806F4 /* Sparkle.framework */,
|
||||
B08173292135F354005D4908 /* CoreBrightness.framework */,
|
||||
B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */,
|
||||
B059D62C205F11E8006E6B86 /* DFRFoundation.framework */,
|
||||
);
|
||||
@@ -165,6 +201,7 @@
|
||||
B082B256205C7D8000BC04DC /* Assets.xcassets */,
|
||||
B082B258205C7D8000BC04DC /* Main.storyboard */,
|
||||
B082B25B205C7D8000BC04DC /* Info.plist */,
|
||||
B0679BC0215AE73F000FC6B4 /* dsa_pub.pem */,
|
||||
B082B25C205C7D8000BC04DC /* MTMR.entitlements */,
|
||||
36C2ECDF207CB1B0003CDA33 /* defaultPreset.json */,
|
||||
B082B252205C7D8000BC04DC /* AppDelegate.swift */,
|
||||
@@ -178,6 +215,7 @@
|
||||
368EDDE620812A1D00E10953 /* ScrollViewItem.swift */,
|
||||
B05600D22083E9BB00EB218D /* CustomSlider.swift */,
|
||||
36A778BD20A6C27100B38714 /* GeneralExtensions.swift */,
|
||||
B0F3112420C9E35F0076BB88 /* SupportNSTouchBar.swift */,
|
||||
);
|
||||
path = MTMR;
|
||||
sourceTree = "<group>";
|
||||
@@ -220,6 +258,9 @@
|
||||
B0F8771B207AC92700D6E430 /* TouchBarSupport.h */,
|
||||
6042B6A82083E1F500C525C8 /* DeprecatedCarbonAPI.h */,
|
||||
6042B6A92083E27000C525C8 /* DeprecatedCarbonAPI.c */,
|
||||
60173D3C20C0031B002C305F /* LaunchAtLoginController.h */,
|
||||
60173D3D20C0031B002C305F /* LaunchAtLoginController.m */,
|
||||
B08173282135F128005D4908 /* CBBlueLightClient.h */,
|
||||
);
|
||||
path = CBridge;
|
||||
sourceTree = "<group>";
|
||||
@@ -236,6 +277,9 @@
|
||||
6042B6A62083E03A00C525C8 /* AppScrubberTouchBarItem.swift */,
|
||||
60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */,
|
||||
60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */,
|
||||
60669B4220AD8FA80074E817 /* GroupBarItem.swift */,
|
||||
B08173262135F02B005D4908 /* NightShiftBarItem.swift */,
|
||||
B081732B213739FE005D4908 /* DnDBarItem.swift */,
|
||||
);
|
||||
path = Widgets;
|
||||
sourceTree = "<group>";
|
||||
@@ -250,6 +294,8 @@
|
||||
B082B24B205C7D8000BC04DC /* Sources */,
|
||||
B082B24C205C7D8000BC04DC /* Frameworks */,
|
||||
B082B24D205C7D8000BC04DC /* Resources */,
|
||||
B00D181E2152F507000806F4 /* CopyFiles */,
|
||||
B0679BBF215AE085000FC6B4 /* ShellScript */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -284,11 +330,12 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0920;
|
||||
LastUpgradeCheck = 0930;
|
||||
LastUpgradeCheck = 1000;
|
||||
ORGANIZATIONNAME = "Anton Palgunov";
|
||||
TargetAttributes = {
|
||||
B082B24E205C7D8000BC04DC = {
|
||||
CreatedOnToolsVersion = 9.2;
|
||||
LastSwiftMigration = 1000;
|
||||
ProvisioningStyle = Manual;
|
||||
SystemCapabilities = {
|
||||
com.apple.Sandbox = {
|
||||
@@ -298,6 +345,7 @@
|
||||
};
|
||||
B082B260205C7D8000BC04DC = {
|
||||
CreatedOnToolsVersion = 9.2;
|
||||
LastSwiftMigration = 1000;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -332,6 +380,7 @@
|
||||
B0B17436207D6B590004B740 /* iTunes.next.scpt in Resources */,
|
||||
B082B25A205C7D8000BC04DC /* Main.storyboard in Resources */,
|
||||
B0B17435207D6B590004B740 /* Spotify.next.scpt in Resources */,
|
||||
B0679BC1215AE73F000FC6B4 /* dsa_pub.pem in Resources */,
|
||||
B0B17433207D6B590004B740 /* Finder.scpt in Resources */,
|
||||
B0B17439207D6B590004B740 /* Vox.nowPlaying.scpt in Resources */,
|
||||
B0B17438207D6B590004B740 /* Vox.next.scpt in Resources */,
|
||||
@@ -350,6 +399,26 @@
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
B0679BBF215AE085000FC6B4 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nbuildNumber=$(/usr/libexec/PlistBuddy -c \"Print CFBundleVersion\" \"${PROJECT_DIR}/${INFOPLIST_FILE}\")\nbuildNumber=$(($buildNumber + 1))\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $buildNumber\" \"${PROJECT_DIR}/${INFOPLIST_FILE}\"\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
B082B24B205C7D8000BC04DC /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
@@ -362,14 +431,19 @@
|
||||
B0008E552080286C003AD4DD /* SupportHelpers.swift in Sources */,
|
||||
6042B6A72083E03A00C525C8 /* AppScrubberTouchBarItem.swift in Sources */,
|
||||
B082B253205C7D8000BC04DC /* AppDelegate.swift in Sources */,
|
||||
B081732C213739FE005D4908 /* DnDBarItem.swift in Sources */,
|
||||
60C44AFD20A373A100C0EC91 /* MusicBarItem.swift in Sources */,
|
||||
B059D624205E04F3006E6B86 /* CustomButtonTouchBarItem.swift in Sources */,
|
||||
60173D3E20C0031B002C305F /* LaunchAtLoginController.m in Sources */,
|
||||
6027D1BA2080E52A004FFDC7 /* VolumeViewController.swift in Sources */,
|
||||
607EEA4B2087835F009DA5F0 /* WeatherBarItem.swift in Sources */,
|
||||
B0F3112520C9E35F0076BB88 /* SupportNSTouchBar.swift in Sources */,
|
||||
6042B6AA2083E27000C525C8 /* DeprecatedCarbonAPI.c in Sources */,
|
||||
B09EB1E4207C082000D5C1E0 /* HapticFeedback.swift in Sources */,
|
||||
B08173272135F02B005D4908 /* NightShiftBarItem.swift in Sources */,
|
||||
60F7D454208CC31400ABF5D2 /* InputSourceBarItem.swift in Sources */,
|
||||
36A778BE20A6C27100B38714 /* GeneralExtensions.swift in Sources */,
|
||||
60669B4320AD8FA80074E817 /* GroupBarItem.swift in Sources */,
|
||||
36C2ECDB207C3FE7003CDA33 /* ItemsParsing.swift in Sources */,
|
||||
B0A7E9AA205D6AA400EEF070 /* KeyPress.swift in Sources */,
|
||||
36C2ECD7207B6DAE003CDA33 /* TimeTouchBarItem.swift in Sources */,
|
||||
@@ -524,14 +598,15 @@
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
INFOPLIST_FILE = MTMR/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMR;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h";
|
||||
SWIFT_VERSION = 4.0;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -539,20 +614,22 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEVELOPMENT_TEAM = D6D8BR2QNB;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
INFOPLIST_FILE = MTMR/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMR;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h";
|
||||
SWIFT_VERSION = 4.0;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -565,7 +642,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 4.0;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -580,7 +657,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 4.0;
|
||||
SWIFT_VERSION = 4.2;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0920"
|
||||
LastUpgradeVersion = "1000"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -26,7 +26,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
@@ -56,7 +55,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0920"
|
||||
LastUpgradeVersion = "1000"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -10,9 +10,8 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
codeCoverageEnabled = "YES">
|
||||
codeCoverageEnabled = "YES"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -32,7 +31,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import Sparkle
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
@@ -14,6 +15,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
private var fileSystemSource: DispatchSourceFileSystemObject?
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
// Configure Sparkle
|
||||
SUUpdater.shared().automaticallyDownloadsUpdates = false
|
||||
SUUpdater.shared().automaticallyChecksForUpdates = true
|
||||
SUUpdater.shared().checkForUpdatesInBackground()
|
||||
|
||||
let _ = AXIsProcessTrustedWithOptions([kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true] as NSDictionary)
|
||||
|
||||
TouchBarController.shared.setupControlStripPresence()
|
||||
|
||||
if let button = statusItem.button {
|
||||
@@ -28,7 +36,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
}
|
||||
|
||||
@objc func openPrefereces(_ sender: Any?) {
|
||||
@objc func openPreferences(_ sender: Any?) {
|
||||
let task = Process()
|
||||
let appSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR")
|
||||
let presetPath = appSupportDirectory.appending("/items.json")
|
||||
@@ -37,10 +45,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
task.launch()
|
||||
}
|
||||
|
||||
@objc func updatePreset(_ sender: Any?) {
|
||||
TouchBarController.shared.createAndUpdatePreset()
|
||||
}
|
||||
|
||||
@objc func toggleControlStrip(_ sender: Any?) {
|
||||
TouchBarController.shared.controlStripState = !TouchBarController.shared.controlStripState
|
||||
createMenu()
|
||||
@@ -75,33 +79,44 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
dialog.allowedFileTypes = ["json"]
|
||||
dialog.directoryURL = NSURL.fileURL(withPath: NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR"), isDirectory: true)
|
||||
|
||||
if (dialog.runModal() == NSApplication.ModalResponse.OK) {
|
||||
let result = dialog.url
|
||||
|
||||
if (result != nil) {
|
||||
let path = result!.path
|
||||
let jsonData = path.fileData
|
||||
let jsonItems = jsonData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
||||
|
||||
TouchBarController.shared.createAndUpdatePreset(jsonItems: jsonItems)
|
||||
}
|
||||
if dialog.runModal() == .OK, let path = dialog.url?.path {
|
||||
TouchBarController.shared.reloadPreset(path: path)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func toggleStartAtLogin(_ sender: Any?) {
|
||||
LaunchAtLoginController().setLaunchAtLogin(!LaunchAtLoginController().launchAtLogin, for: NSURL.fileURL(withPath: Bundle.main.bundlePath))
|
||||
createMenu()
|
||||
}
|
||||
|
||||
func createMenu() {
|
||||
let menu = NSMenu()
|
||||
menu.addItem(withTitle: "Preferences", action: #selector(openPrefereces(_:)), keyEquivalent: ",")
|
||||
menu.addItem(withTitle: "Reload Preset", action: #selector(updatePreset(_:)), keyEquivalent: "r")
|
||||
menu.addItem(withTitle: "Open Preset", action: #selector(openPreset(_:)), keyEquivalent: "O")
|
||||
menu.addItem(withTitle: TouchBarController.shared.controlStripState ? "Hide Control Strip" : "Show Control Strip" , action: #selector(toggleControlStrip(_:)), keyEquivalent: "T")
|
||||
menu.addItem(withTitle: "Toggle blackList current app" , action: #selector(toggleBlackListedApp(_:)), keyEquivalent: "B")
|
||||
|
||||
let startAtLogin = NSMenuItem(title: "Start at login", action: #selector(toggleStartAtLogin(_:)), keyEquivalent: "L")
|
||||
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
|
||||
|
||||
let settingSeparator = NSMenuItem(title: "Settings", action: nil, keyEquivalent: "")
|
||||
settingSeparator.isEnabled = false
|
||||
|
||||
menu.addItem(withTitle: "Preferences", action: #selector(openPreferences(_:)), keyEquivalent: ",")
|
||||
menu.addItem(withTitle: "Open preset", action: #selector(openPreset(_:)), keyEquivalent: "O")
|
||||
menu.addItem(withTitle: "Check for Updates...", action: #selector(SUUpdater.checkForUpdates(_:)), keyEquivalent: "").target = SUUpdater.shared()
|
||||
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
menu.addItem(settingSeparator)
|
||||
menu.addItem(hideControlStrip)
|
||||
menu.addItem(withTitle: "Toggle current app in blacklist" , action: #selector(toggleBlackListedApp(_:)), keyEquivalent: "B")
|
||||
menu.addItem(startAtLogin)
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
menu.addItem(withTitle: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
||||
statusItem.menu = menu
|
||||
}
|
||||
|
||||
func reloadOnDefaultConfigChanged() {
|
||||
let file = NSURL.fileURL(withPath: NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR/items.json"))
|
||||
let file = NSURL.fileURL(withPath: standardConfigPath)
|
||||
|
||||
let fd = open(file.path, O_EVTONLY)
|
||||
|
||||
@@ -110,7 +125,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
self.fileSystemSource?.setEventHandler(handler: {
|
||||
print("Config changed, reloading...")
|
||||
DispatchQueue.main.async {
|
||||
TouchBarController.shared.createAndUpdatePreset()
|
||||
TouchBarController.shared.reloadPreset(path: file.path)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -63,13 +63,6 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
|
||||
|
||||
}
|
||||
|
||||
extension SourceProtocol {
|
||||
var appleScript: NSAppleScript? {
|
||||
guard let source = self.string else { return nil }
|
||||
return NSAppleScript(source: source)
|
||||
}
|
||||
}
|
||||
|
||||
extension DispatchQueue {
|
||||
static let appleScriptQueue = DispatchQueue(label: "mtmr.applescript")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "dnd-off.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "dnd-on.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 7.8 KiB |
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "KeyboardBrightDown.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "KeyboardBrightUp.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "NightShift.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "NightShiftEnabled.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Application-->
|
||||
@@ -676,6 +676,7 @@
|
||||
</application>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="MTMR" customModuleProvider="target"/>
|
||||
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
|
||||
<customObject id="VW7-73-dHf" customClass="SUUpdater"/>
|
||||
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="75" y="0.0"/>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// CBBlueLightClient.h
|
||||
// MTMR
|
||||
//
|
||||
// Created by Anton Palgunov on 28/08/2018.
|
||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
typedef struct {
|
||||
int hour;
|
||||
int minute;
|
||||
} Time;
|
||||
|
||||
typedef struct {
|
||||
Time fromTime;
|
||||
Time toTime;
|
||||
} Schedule;
|
||||
|
||||
typedef struct {
|
||||
BOOL active;
|
||||
BOOL enabled;
|
||||
BOOL sunSchedulePermitted;
|
||||
int mode;
|
||||
Schedule schedule;
|
||||
unsigned long long disableFlags;
|
||||
} Status;
|
||||
|
||||
@interface CBBlueLightClient: NSObject
|
||||
- (BOOL) setEnabled:(BOOL)enabled;
|
||||
- (BOOL) setMode:(int)mode;
|
||||
- (void) getBlueLightStatus: (Status *)status;
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// LaunchAtLoginController.h
|
||||
//
|
||||
// Copyright 2011 Tomáš Znamenáček
|
||||
// Copyright 2010 Ben Clark-Robinson
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the ‘Software’),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@import Foundation;
|
||||
@import CoreServices;
|
||||
|
||||
@interface LaunchAtLoginController : NSObject {}
|
||||
|
||||
@property(assign) BOOL launchAtLogin;
|
||||
|
||||
- (BOOL) willLaunchAtLogin: (NSURL*) itemURL;
|
||||
- (void) setLaunchAtLogin: (BOOL) enabled forURL: (NSURL*) itemURL;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// LaunchAtLoginController.m
|
||||
//
|
||||
// Copyright 2011 Tomáš Znamenáček
|
||||
// Copyright 2010 Ben Clark-Robinson
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the ‘Software’),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#import "LaunchAtLoginController.h"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
static NSString *const StartAtLoginKey = @"launchAtLogin";
|
||||
|
||||
@interface LaunchAtLoginController ()
|
||||
@property(assign) LSSharedFileListRef loginItems;
|
||||
@end
|
||||
|
||||
@implementation LaunchAtLoginController
|
||||
@synthesize loginItems;
|
||||
|
||||
#pragma mark Change Observing
|
||||
|
||||
void sharedFileListDidChange(LSSharedFileListRef inList, void *context)
|
||||
{
|
||||
LaunchAtLoginController *self = (__bridge id) context;
|
||||
[self willChangeValueForKey:StartAtLoginKey];
|
||||
[self didChangeValueForKey:StartAtLoginKey];
|
||||
}
|
||||
|
||||
#pragma mark Initialization
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
|
||||
LSSharedFileListAddObserver(loginItems, CFRunLoopGetMain(),
|
||||
(CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, (voidPtr)CFBridgingRetain(self));
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
LSSharedFileListRemoveObserver(loginItems, CFRunLoopGetMain(),
|
||||
(CFStringRef)NSDefaultRunLoopMode, sharedFileListDidChange, (__bridge void *)(self));
|
||||
CFRelease(loginItems);
|
||||
}
|
||||
|
||||
#pragma mark Launch List Control
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
LSSharedFileListItemRef copyItemWithURLinFileList(NSURL* wantedURL, LSSharedFileListRef fileList) {
|
||||
if (wantedURL == NULL || fileList == NULL)
|
||||
return NULL;
|
||||
|
||||
NSArray *listSnapshot = (__bridge_transfer NSArray *)LSSharedFileListCopySnapshot(fileList, NULL);
|
||||
for(NSUInteger i = 0; i< [listSnapshot count]; i++) {
|
||||
LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef)[listSnapshot objectAtIndex:i];
|
||||
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
|
||||
CFURLRef currentItemURL = NULL;
|
||||
LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, NULL);
|
||||
if (currentItemURL && [(__bridge_transfer NSURL*)currentItemURL isEqual:wantedURL]) {
|
||||
CFRetain(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
- (BOOL) willLaunchAtLogin: (NSURL*) itemURL
|
||||
{
|
||||
return !!copyItemWithURLinFileList(itemURL, loginItems);
|
||||
}
|
||||
|
||||
- (void) setLaunchAtLogin: (BOOL) enabled forURL: (NSURL*) itemURL
|
||||
{
|
||||
LSSharedFileListItemRef appItem = copyItemWithURLinFileList(itemURL, loginItems);
|
||||
if (enabled && !appItem) {
|
||||
LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst,
|
||||
NULL, NULL, (__bridge CFURLRef)itemURL, NULL, NULL);
|
||||
} else if (!enabled && appItem) {
|
||||
LSSharedFileListItemRemove(loginItems, appItem);
|
||||
}
|
||||
if (appItem) {
|
||||
CFRelease(appItem);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Basic Interface
|
||||
|
||||
- (NSURL*) appURL
|
||||
{
|
||||
return [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
|
||||
}
|
||||
|
||||
- (void) setLaunchAtLogin: (BOOL) enabled
|
||||
{
|
||||
[self willChangeValueForKey:StartAtLoginKey];
|
||||
[self setLaunchAtLogin:enabled forURL:[self appURL]];
|
||||
[self didChangeValueForKey:StartAtLoginKey];
|
||||
}
|
||||
|
||||
- (BOOL) launchAtLogin
|
||||
{
|
||||
return [self willLaunchAtLogin:[self appURL]];
|
||||
}
|
||||
|
||||
@end
|
||||
#pragma clang diagnostic pop
|
||||
@@ -9,6 +9,8 @@
|
||||
#import "TouchBarPrivateApi.h"
|
||||
#import "TouchBarSupport.h"
|
||||
#import "DeprecatedCarbonAPI.h"
|
||||
#import "CBBlueLightClient.h"
|
||||
#import "LaunchAtLoginController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@@ -17,13 +17,16 @@ extern void DFRSystemModalShowsCloseBoxWhenFrontMost(BOOL);
|
||||
|
||||
@interface NSTouchBar (PrivateMethods)
|
||||
|
||||
// presentSystemModalFunctionBar:placement:systemTrayItemIdentifier:
|
||||
// macOS 10.14
|
||||
+ (void)presentSystemModalTouchBar:(NSTouchBar *)touchBar placement:(long long)placement systemTrayItemIdentifier:(NSTouchBarItemIdentifier)identifier;
|
||||
+ (void)presentSystemModalTouchBar:(NSTouchBar *)touchBar systemTrayItemIdentifier:(NSTouchBarItemIdentifier)identifier;
|
||||
+ (void)dismissSystemModalTouchBar:(NSTouchBar *)touchBar;
|
||||
+ (void)minimizeSystemModalTouchBar:(NSTouchBar *)touchBar;
|
||||
|
||||
// macOS 10.13
|
||||
+ (void)presentSystemModalFunctionBar:(NSTouchBar *)touchBar placement:(long long)placement systemTrayItemIdentifier:(NSTouchBarItemIdentifier)identifier;
|
||||
|
||||
+ (void)presentSystemModalFunctionBar:(NSTouchBar *)touchBar systemTrayItemIdentifier:(NSTouchBarItemIdentifier)identifier;
|
||||
|
||||
+ (void)dismissSystemModalFunctionBar:(NSTouchBar *)touchBar;
|
||||
|
||||
+ (void)minimizeSystemModalFunctionBar:(NSTouchBar *)touchBar;
|
||||
|
||||
@end
|
||||
|
||||
@@ -17,15 +17,31 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.15</string>
|
||||
<string>0.18.3</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<string>26</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>LSUIElement</key>
|
||||
<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>
|
||||
@@ -34,7 +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>
|
||||
|
||||
@@ -3,7 +3,7 @@ import AppKit
|
||||
|
||||
extension Data {
|
||||
func barItemDefinitions() -> [BarItemDefinition]? {
|
||||
return try? JSONDecoder().decode([BarItemDefinition].self, from: self.utf8string!.stripComments().data(using: .utf8)!)
|
||||
return try? JSONDecoder().decode([BarItemDefinition].self, from: self.utf8string!.stripComments().data(using: .utf8)!)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,23 +12,24 @@ struct BarItemDefinition: Decodable {
|
||||
let action: ActionType
|
||||
let longAction: LongActionType
|
||||
let additionalParameters: [GeneralParameters.CodingKeys: GeneralParameter]
|
||||
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
}
|
||||
|
||||
|
||||
init(type: ItemType, action: ActionType, longAction: LongActionType, additionalParameters: [GeneralParameters.CodingKeys:GeneralParameter]) {
|
||||
self.type = type
|
||||
self.action = action
|
||||
self.longAction = longAction
|
||||
self.additionalParameters = additionalParameters
|
||||
}
|
||||
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let type = try container.decode(String.self, forKey: .type)
|
||||
let parametersDecoder = SupportedTypesHolder.sharedInstance.lookup(by: type)
|
||||
var additionalParameters = try GeneralParameters(from: decoder).parameters
|
||||
|
||||
if let result = try? parametersDecoder(decoder),
|
||||
case let (itemType, action, longAction, parameters) = result {
|
||||
parameters.forEach { additionalParameters[$0] = $1 }
|
||||
@@ -37,46 +38,66 @@ struct BarItemDefinition: Decodable {
|
||||
self.init(type: .staticButton(title: "unknown"), action: .none, longAction: .none, additionalParameters: additionalParameters)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class SupportedTypesHolder {
|
||||
typealias ParametersDecoder = (Decoder) throws ->(item: ItemType, action: ActionType, longAction: LongActionType, parameters: [GeneralParameters.CodingKeys: GeneralParameter])
|
||||
private var supportedTypes: [String: ParametersDecoder] = [
|
||||
"escape": { _ in return (item: .staticButton(title: "esc"), action: .keyPress(keycode: 53), longAction: .none, parameters: [.align: .align(.left)]) },
|
||||
|
||||
"delete": { _ in return (item: .staticButton(title: "del"), action: .keyPress(keycode: 117), longAction: .none, parameters: [:])},
|
||||
|
||||
"brightnessUp": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: #imageLiteral(resourceName: "brightnessUp"))
|
||||
return (item: .staticButton(title: ""), action: .keyPress(keycode: 144), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"brightnessDown": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: #imageLiteral(resourceName: "brightnessDown"))
|
||||
return (item: .staticButton(title: ""), action: .keyPress(keycode: 145), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"illuminationUp": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: #imageLiteral(resourceName: "ill_up"))
|
||||
return (item: .staticButton(title: ""), action: .hidKey(keycode: NX_KEYTYPE_ILLUMINATION_UP), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"illuminationDown": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: #imageLiteral(resourceName: "ill_down"))
|
||||
return (item: .staticButton(title: ""), action: .hidKey(keycode: NX_KEYTYPE_ILLUMINATION_DOWN), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"volumeDown": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: .touchBarVolumeDownTemplate)!)
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: NSImage.touchBarVolumeDownTemplateName)!)
|
||||
return (item: .staticButton(title: ""), action: .hidKey(keycode: NX_KEYTYPE_SOUND_DOWN), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"volumeUp": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: .touchBarVolumeUpTemplate)!)
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: NSImage.touchBarVolumeUpTemplateName)!)
|
||||
return (item: .staticButton(title: ""), action: .hidKey(keycode: NX_KEYTYPE_SOUND_UP), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"mute": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: .touchBarAudioOutputMuteTemplate)!)
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: NSImage.touchBarAudioOutputMuteTemplateName)!)
|
||||
return (item: .staticButton(title: ""), action: .hidKey(keycode: NX_KEYTYPE_MUTE), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"previous": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: .touchBarRewindTemplate)!)
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: NSImage.touchBarRewindTemplateName)!)
|
||||
return (item: .staticButton(title: ""), action: .hidKey(keycode: NX_KEYTYPE_PREVIOUS), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"play": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: .touchBarPlayPauseTemplate)!)
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: NSImage.touchBarPlayPauseTemplateName)!)
|
||||
return (item: .staticButton(title: ""), action: .hidKey(keycode: NX_KEYTYPE_PLAY), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"next": { _ in
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: .touchBarFastForwardTemplate)!)
|
||||
let imageParameter = GeneralParameter.image(source: NSImage(named: NSImage.touchBarFastForwardTemplateName)!)
|
||||
return (item: .staticButton(title: ""), action: .hidKey(keycode: NX_KEYTYPE_NEXT), longAction: .none, parameters: [.image: imageParameter])
|
||||
},
|
||||
|
||||
"weather": { decoder in
|
||||
enum CodingKeys: String, CodingKey { case refreshInterval; case units; case api_key ; case icon_type }
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -88,6 +109,7 @@ class SupportedTypesHolder {
|
||||
let longAction = try LongActionType(from: decoder)
|
||||
return (item: .weather(interval: interval ?? 1800.00, units: units ?? "metric", api_key: api_key ?? "32c4256d09a4c52b38aecddba7a078f6", icon_type: icon_type ?? "text"), action: action, longAction: longAction, parameters: [:])
|
||||
},
|
||||
|
||||
"currency": { decoder in
|
||||
enum CodingKeys: String, CodingKey { case refreshInterval; case from; case to }
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -98,12 +120,15 @@ class SupportedTypesHolder {
|
||||
let longAction = try LongActionType(from: decoder)
|
||||
return (item: .currency(interval: interval ?? 600.00, from: from ?? "RUB", to: to ?? "USD"), action: action, longAction: longAction, parameters: [:])
|
||||
},
|
||||
|
||||
"dock": { decoder in
|
||||
return (item: .dock(), action: .none, longAction: .none, parameters: [:])
|
||||
},
|
||||
|
||||
"inputsource": { decoder in
|
||||
return (item: .inputsource(), action: .none, longAction: .none, parameters: [:])
|
||||
},
|
||||
|
||||
"volume": { decoder in
|
||||
enum CodingKeys: String, CodingKey { case image }
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -113,6 +138,7 @@ class SupportedTypesHolder {
|
||||
return (item: .volume(), action: .none, longAction: .none, parameters: [:])
|
||||
}
|
||||
},
|
||||
|
||||
"brightness": { decoder in
|
||||
enum CodingKeys: String, CodingKey { case refreshInterval; case image }
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -123,8 +149,11 @@ class SupportedTypesHolder {
|
||||
return (item: .brightness(refreshInterval: interval ?? 0.5), action: .none, longAction: .none, parameters: [:])
|
||||
}
|
||||
},
|
||||
|
||||
"sleep": { _ in return (item: .staticButton(title: "☕️"), action: .shellScript(executable: "/usr/bin/pmset", parameters: ["sleepnow"]), longAction: .none, parameters: [:]) },
|
||||
|
||||
"displaySleep": { _ in return (item: .staticButton(title: "☕️"), action: .shellScript(executable: "/usr/bin/pmset", parameters: ["displaysleepnow"]), longAction: .none, parameters: [:])},
|
||||
|
||||
"music": { decoder in
|
||||
enum CodingKeys: String, CodingKey { case refreshInterval }
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -136,20 +165,51 @@ class SupportedTypesHolder {
|
||||
parameters: [:]
|
||||
)
|
||||
},
|
||||
|
||||
"group": { decoder in
|
||||
enum CodingKeys: CodingKey { case items }
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let items = try container.decode([BarItemDefinition].self, forKey: .items)
|
||||
return (
|
||||
item: .groupBar(items: items),
|
||||
action: .none,
|
||||
longAction: .none,
|
||||
parameters: [:]
|
||||
)
|
||||
},
|
||||
|
||||
"nightShift": {_ in
|
||||
return (
|
||||
item: .nightShift(),
|
||||
action: .none,
|
||||
longAction: .none,
|
||||
parameters: [:]
|
||||
)
|
||||
},
|
||||
|
||||
"dnd": { _ in
|
||||
return (
|
||||
item: .dnd(),
|
||||
action: .none,
|
||||
longAction: .none,
|
||||
parameters: [:]
|
||||
)
|
||||
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
static let sharedInstance = SupportedTypesHolder()
|
||||
|
||||
|
||||
func lookup(by type: String) -> ParametersDecoder {
|
||||
return supportedTypes[type] ?? { decoder in
|
||||
return (item: try ItemType(from: decoder), action: try ActionType(from: decoder), longAction: try LongActionType(from: decoder), parameters: [:])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func register(typename: String, decoder: @escaping ParametersDecoder) {
|
||||
supportedTypes[typename] = decoder
|
||||
}
|
||||
|
||||
|
||||
func register(typename: String, item: ItemType, action: ActionType, longAction: LongActionType) {
|
||||
register(typename: typename) { _ in
|
||||
return (item: item, action: action, longAction: longAction, parameters: [:])
|
||||
@@ -169,7 +229,10 @@ enum ItemType: Decodable {
|
||||
case currency(interval: Double, from: String, to: String)
|
||||
case inputsource()
|
||||
case music(interval: Double)
|
||||
|
||||
case groupBar(items: [BarItemDefinition])
|
||||
case nightShift()
|
||||
case dnd()
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
case title
|
||||
@@ -184,8 +247,9 @@ enum ItemType: Decodable {
|
||||
case image
|
||||
case url
|
||||
case longUrl
|
||||
case items
|
||||
}
|
||||
|
||||
|
||||
enum ItemTypeRaw: String, Decodable {
|
||||
case staticButton
|
||||
case appleScriptTitledButton
|
||||
@@ -198,47 +262,71 @@ enum ItemType: Decodable {
|
||||
case currency
|
||||
case inputsource
|
||||
case music
|
||||
case groupBar
|
||||
case nightShift
|
||||
case dnd
|
||||
}
|
||||
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let type = try container.decode(ItemTypeRaw.self, forKey: .type)
|
||||
switch type {
|
||||
|
||||
case .appleScriptTitledButton:
|
||||
let source = try container.decode(Source.self, forKey: .source)
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||
self = .appleScriptTitledButton(source: source, refreshInterval: interval)
|
||||
|
||||
case .staticButton:
|
||||
let title = try container.decode(String.self, forKey: .title)
|
||||
self = .staticButton(title: title)
|
||||
|
||||
case .timeButton:
|
||||
let template = try container.decodeIfPresent(String.self, forKey: .formatTemplate) ?? "HH:mm"
|
||||
self = .timeButton(formatTemplate: template)
|
||||
|
||||
case .battery:
|
||||
self = .battery()
|
||||
|
||||
case .dock:
|
||||
self = .dock()
|
||||
|
||||
case .volume:
|
||||
self = .volume()
|
||||
|
||||
case .brightness:
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 0.5
|
||||
self = .brightness(refreshInterval: interval)
|
||||
|
||||
case .weather:
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||
let units = try container.decodeIfPresent(String.self, forKey: .units) ?? "metric"
|
||||
let api_key = try container.decodeIfPresent(String.self, forKey: .api_key) ?? "32c4256d09a4c52b38aecddba7a078f6"
|
||||
let icon_type = try container.decodeIfPresent(String.self, forKey: .icon_type) ?? "text"
|
||||
self = .weather(interval: interval, units: units, api_key: api_key, icon_type: icon_type)
|
||||
|
||||
case .currency:
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 600.0
|
||||
let from = try container.decodeIfPresent(String.self, forKey: .from) ?? "RUB"
|
||||
let to = try container.decodeIfPresent(String.self, forKey: .to) ?? "USD"
|
||||
self = .currency(interval: interval, from: from, to: to)
|
||||
|
||||
case .inputsource:
|
||||
self = .inputsource()
|
||||
|
||||
case .music:
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||
self = .music(interval: interval)
|
||||
|
||||
case .groupBar:
|
||||
let items = try container.decode([BarItemDefinition].self, forKey: .items)
|
||||
self = .groupBar(items: items)
|
||||
|
||||
case .nightShift:
|
||||
self = .nightShift()
|
||||
|
||||
case .dnd:
|
||||
self = .dnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,11 +335,11 @@ enum ActionType: Decodable {
|
||||
case none
|
||||
case hidKey(keycode: Int32)
|
||||
case keyPress(keycode: Int)
|
||||
case appleSctipt(source: SourceProtocol)
|
||||
case appleScript(source: SourceProtocol)
|
||||
case shellScript(executable: String, parameters: [String])
|
||||
case custom(closure: ()->())
|
||||
case openUrl(url: String)
|
||||
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case action
|
||||
case keycode
|
||||
@@ -260,7 +348,7 @@ enum ActionType: Decodable {
|
||||
case shellArguments
|
||||
case url
|
||||
}
|
||||
|
||||
|
||||
private enum ActionTypeRaw: String, Decodable {
|
||||
case hidKey
|
||||
case keyPress
|
||||
@@ -268,29 +356,35 @@ enum ActionType: Decodable {
|
||||
case shellScript
|
||||
case openUrl
|
||||
}
|
||||
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let type = try container.decodeIfPresent(ActionTypeRaw.self, forKey: .action)
|
||||
|
||||
switch type {
|
||||
case .some(.hidKey):
|
||||
let keycode = try container.decode(Int32.self, forKey: .keycode)
|
||||
self = .hidKey(keycode: keycode)
|
||||
case .some(.keyPress):
|
||||
let keycode = try container.decode(Int.self, forKey: .keycode)
|
||||
self = .keyPress(keycode: keycode)
|
||||
case .some(.appleScript):
|
||||
let source = try container.decode(Source.self, forKey: .actionAppleScript)
|
||||
self = .appleSctipt(source: source)
|
||||
case .some(.shellScript):
|
||||
let executable = try container.decode(String.self, forKey: .executablePath)
|
||||
let parameters = try container.decodeIfPresent([String].self, forKey: .shellArguments) ?? []
|
||||
self = .shellScript(executable: executable, parameters: parameters)
|
||||
case .some(.openUrl):
|
||||
let url = try container.decode(String.self, forKey: .url)
|
||||
self = .openUrl(url: url)
|
||||
case .none:
|
||||
self = .none
|
||||
case .some(.hidKey):
|
||||
let keycode = try container.decode(Int32.self, forKey: .keycode)
|
||||
self = .hidKey(keycode: keycode)
|
||||
|
||||
case .some(.keyPress):
|
||||
let keycode = try container.decode(Int.self, forKey: .keycode)
|
||||
self = .keyPress(keycode: keycode)
|
||||
|
||||
case .some(.appleScript):
|
||||
let source = try container.decode(Source.self, forKey: .actionAppleScript)
|
||||
self = .appleScript(source: source)
|
||||
|
||||
case .some(.shellScript):
|
||||
let executable = try container.decode(String.self, forKey: .executablePath)
|
||||
let parameters = try container.decodeIfPresent([String].self, forKey: .shellArguments) ?? []
|
||||
self = .shellScript(executable: executable, parameters: parameters)
|
||||
|
||||
case .some(.openUrl):
|
||||
let url = try container.decode(String.self, forKey: .url)
|
||||
self = .openUrl(url: url)
|
||||
|
||||
case .none:
|
||||
self = .none
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,17 +394,17 @@ enum LongActionType: Decodable {
|
||||
case none
|
||||
case hidKey(keycode: Int32)
|
||||
case keyPress(keycode: Int)
|
||||
case appleSctipt(source: SourceProtocol)
|
||||
case appleScript(source: SourceProtocol)
|
||||
case shellScript(executable: String, parameters: [String])
|
||||
case custom(closure: ()->())
|
||||
case openUrl(url: String)
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case longAction
|
||||
case keycode
|
||||
case actionAppleScript
|
||||
case executablePath
|
||||
case shellArguments
|
||||
case longKeycode
|
||||
case longActionAppleScript
|
||||
case longExecutablePath
|
||||
case longShellArguments
|
||||
case longUrl
|
||||
}
|
||||
|
||||
@@ -325,25 +419,31 @@ enum LongActionType: Decodable {
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let longType = try container.decodeIfPresent(LongActionTypeRaw.self, forKey: .longAction)
|
||||
|
||||
switch longType {
|
||||
case .some(.hidKey):
|
||||
let keycode = try container.decode(Int32.self, forKey: .keycode)
|
||||
self = .hidKey(keycode: keycode)
|
||||
case .some(.keyPress):
|
||||
let keycode = try container.decode(Int.self, forKey: .keycode)
|
||||
self = .keyPress(keycode: keycode)
|
||||
case .some(.appleScript):
|
||||
let source = try container.decode(Source.self, forKey: .actionAppleScript)
|
||||
self = .appleSctipt(source: source)
|
||||
case .some(.shellScript):
|
||||
let executable = try container.decode(String.self, forKey: .executablePath)
|
||||
let parameters = try container.decodeIfPresent([String].self, forKey: .shellArguments) ?? []
|
||||
self = .shellScript(executable: executable, parameters: parameters)
|
||||
case .some(.openUrl):
|
||||
let longUrl = try container.decode(String.self, forKey: .longUrl)
|
||||
self = .openUrl(url: longUrl)
|
||||
case .none:
|
||||
self = .none
|
||||
case .some(.hidKey):
|
||||
let keycode = try container.decode(Int32.self, forKey: .longKeycode)
|
||||
self = .hidKey(keycode: keycode)
|
||||
|
||||
case .some(.keyPress):
|
||||
let keycode = try container.decode(Int.self, forKey: .longKeycode)
|
||||
self = .keyPress(keycode: keycode)
|
||||
|
||||
case .some(.appleScript):
|
||||
let source = try container.decode(Source.self, forKey: .longActionAppleScript)
|
||||
self = .appleScript(source: source)
|
||||
|
||||
case .some(.shellScript):
|
||||
let executable = try container.decode(String.self, forKey: .longExecutablePath)
|
||||
let parameters = try container.decodeIfPresent([String].self, forKey: .longShellArguments) ?? []
|
||||
self = .shellScript(executable: executable, parameters: parameters)
|
||||
|
||||
case .some(.openUrl):
|
||||
let longUrl = try container.decode(String.self, forKey: .longUrl)
|
||||
self = .openUrl(url: longUrl)
|
||||
|
||||
case .none:
|
||||
self = .none
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,43 +455,59 @@ enum GeneralParameter {
|
||||
case align(_: Align)
|
||||
case bordered(_: Bool)
|
||||
case background(_:NSColor)
|
||||
case title(_:String)
|
||||
}
|
||||
|
||||
struct GeneralParameters: Decodable {
|
||||
let parameters: [GeneralParameters.CodingKeys: GeneralParameter]
|
||||
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case width
|
||||
case image
|
||||
case align
|
||||
case bordered
|
||||
case background
|
||||
case title
|
||||
}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
var result: [GeneralParameters.CodingKeys: GeneralParameter] = [:]
|
||||
|
||||
if let value = try container.decodeIfPresent(CGFloat.self, forKey: .width) {
|
||||
result[.width] = .width(value)
|
||||
}
|
||||
|
||||
if let imageSource = try container.decodeIfPresent(Source.self, forKey: .image) {
|
||||
result[.image] = .image(source: imageSource)
|
||||
}
|
||||
|
||||
let align = try container.decodeIfPresent(Align.self, forKey: .align) ?? .center
|
||||
result[.align] = .align(align)
|
||||
|
||||
if let borderedFlag = try container.decodeIfPresent(Bool.self, forKey: .bordered) {
|
||||
result[.bordered] = .bordered(borderedFlag)
|
||||
}
|
||||
|
||||
if let backgroundColor = try container.decodeIfPresent(String.self, forKey: .background)?.hexColor {
|
||||
result[.background] = .background(backgroundColor)
|
||||
}
|
||||
|
||||
if let title = try container.decodeIfPresent(String.self, forKey: .title) {
|
||||
result[.title] = .title(title)
|
||||
}
|
||||
|
||||
parameters = result
|
||||
}
|
||||
}
|
||||
|
||||
protocol SourceProtocol {
|
||||
var data: Data? { get }
|
||||
var string: String? { get }
|
||||
var image: NSImage? { get }
|
||||
var appleScript: NSAppleScript? { get }
|
||||
}
|
||||
|
||||
struct Source: Decodable, SourceProtocol {
|
||||
let filePath: String?
|
||||
let base64: String?
|
||||
@@ -406,46 +522,69 @@ struct Source: Decodable, SourceProtocol {
|
||||
var data: Data? {
|
||||
return base64?.base64Data ?? inline?.data(using: .utf8) ?? filePath?.fileData
|
||||
}
|
||||
|
||||
var string: String? {
|
||||
return inline ?? self.data?.utf8string
|
||||
return inline ?? filePath?.fileString
|
||||
}
|
||||
|
||||
var image: NSImage? {
|
||||
return data?.image
|
||||
}
|
||||
|
||||
|
||||
var appleScript: NSAppleScript? {
|
||||
return filePath?.fileURL.appleScript ?? self.string?.appleScript
|
||||
}
|
||||
|
||||
private init(filePath: String?, base64: String?, inline: String?) {
|
||||
self.filePath = filePath
|
||||
self.base64 = base64
|
||||
self.inline = inline
|
||||
}
|
||||
|
||||
init(filePath: String) {
|
||||
self.init(filePath: filePath, base64: nil, inline: nil)
|
||||
}
|
||||
}
|
||||
|
||||
extension NSImage: SourceProtocol {
|
||||
var data: Data? {
|
||||
return nil
|
||||
}
|
||||
|
||||
var string: String? {
|
||||
return nil
|
||||
}
|
||||
|
||||
var image: NSImage? {
|
||||
return self
|
||||
}
|
||||
|
||||
var appleScript: NSAppleScript? {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
var base64Data: Data? {
|
||||
return Data(base64Encoded: self)
|
||||
}
|
||||
|
||||
var fileData: Data? {
|
||||
return try? Data(contentsOf: URL(fileURLWithPath: self))
|
||||
}
|
||||
|
||||
var fileString: String? {
|
||||
var encoding: String.Encoding = .utf8
|
||||
return try? String(contentsOfFile: self, usedEncoding: &encoding)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Data {
|
||||
var utf8string: String? {
|
||||
return String(data: self, encoding: .utf8)
|
||||
}
|
||||
|
||||
var image: NSImage? {
|
||||
return NSImage(data: self)?.resize(maxSize: NSSize(width: 24, height: 24))
|
||||
}
|
||||
@@ -456,3 +595,20 @@ enum Align: String, Decodable {
|
||||
case center
|
||||
case right
|
||||
}
|
||||
|
||||
extension String {
|
||||
var fileURL: URL {
|
||||
return URL(fileURLWithPath: self)
|
||||
}
|
||||
|
||||
var appleScript: NSAppleScript? {
|
||||
return NSAppleScript(source: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension URL {
|
||||
var appleScript: NSAppleScript? {
|
||||
guard FileManager.default.fileExists(atPath: self.path) else { return nil }
|
||||
return NSAppleScript(contentsOf: self, error: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import Foundation
|
||||
|
||||
class ScrollViewItem: NSCustomTouchBarItem {
|
||||
class ScrollViewItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
||||
var twofingersPrev: CGFloat = 0.0
|
||||
var threefingersPrev: CGFloat = 0.0
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, items: [NSTouchBarItem]) {
|
||||
super.init(identifier: identifier)
|
||||
@@ -11,10 +13,63 @@ class ScrollViewItem: NSCustomTouchBarItem {
|
||||
let scrollView = NSScrollView(frame: CGRect(origin: .zero, size: stackView.fittingSize))
|
||||
scrollView.documentView = stackView
|
||||
self.view = scrollView
|
||||
|
||||
let twofingers = NSPanGestureRecognizer(target: self, action: #selector(twofingersHandler(_:)))
|
||||
twofingers.allowedTouchTypes = .direct
|
||||
twofingers.numberOfTouchesRequired = 2
|
||||
self.view.addGestureRecognizer(twofingers)
|
||||
|
||||
let threefingers = NSPanGestureRecognizer(target: self, action: #selector(threefingersHandler(_:)))
|
||||
threefingers.allowedTouchTypes = .direct
|
||||
threefingers.numberOfTouchesRequired = 3
|
||||
self.view.addGestureRecognizer(threefingers)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@objc func twofingersHandler(_ sender: NSGestureRecognizer?) { // Volume
|
||||
let position = (sender?.location(in: sender?.view).x)!
|
||||
|
||||
switch sender!.state {
|
||||
case .began:
|
||||
twofingersPrev = position
|
||||
case .changed:
|
||||
if (((position-twofingersPrev) > 10) || ((twofingersPrev-position) > 10)) {
|
||||
if position > twofingersPrev {
|
||||
HIDPostAuxKey(NX_KEYTYPE_SOUND_UP)
|
||||
} else if position < twofingersPrev {
|
||||
HIDPostAuxKey(NX_KEYTYPE_SOUND_DOWN)
|
||||
}
|
||||
twofingersPrev = position
|
||||
}
|
||||
case .ended:
|
||||
twofingersPrev = 0.0
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@objc func threefingersHandler(_ sender: NSGestureRecognizer?) { // Brightness
|
||||
let position = (sender?.location(in: sender?.view).x)!
|
||||
|
||||
switch sender!.state {
|
||||
case .began:
|
||||
threefingersPrev = position
|
||||
case .changed:
|
||||
if (((position-threefingersPrev) > 15) || ((threefingersPrev-position) > 15)) {
|
||||
if position > threefingersPrev {
|
||||
GenericKeyPress(keyCode: CGKeyCode(144)).send()
|
||||
} else if position < threefingersPrev {
|
||||
GenericKeyPress(keyCode: CGKeyCode(145)).send()
|
||||
}
|
||||
threefingersPrev = position
|
||||
}
|
||||
case .ended:
|
||||
threefingersPrev = 0.0
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// ExtendNSTouchBar.swift
|
||||
// MTMR
|
||||
//
|
||||
// Created by Anton Palgunov on 07/06/2018.
|
||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
|
||||
func presentSystemModal(_ touchBar: NSTouchBar!, systemTrayItemIdentifier identifier: NSTouchBarItem.Identifier!) -> Void {
|
||||
if #available(OSX 10.14, *) {
|
||||
NSTouchBar.presentSystemModalTouchBar(touchBar, systemTrayItemIdentifier: identifier)
|
||||
} else {
|
||||
NSTouchBar.presentSystemModalFunctionBar(touchBar, systemTrayItemIdentifier: identifier)
|
||||
}
|
||||
}
|
||||
|
||||
func presentSystemModal(_ touchBar: NSTouchBar!, placement: Int64, systemTrayItemIdentifier identifier: NSTouchBarItem.Identifier!) -> Void {
|
||||
if #available(OSX 10.14, *) {
|
||||
NSTouchBar.presentSystemModalTouchBar(touchBar, placement: placement, systemTrayItemIdentifier: identifier)
|
||||
} else {
|
||||
NSTouchBar.presentSystemModalFunctionBar(touchBar, placement: placement, systemTrayItemIdentifier: identifier)
|
||||
}
|
||||
}
|
||||
|
||||
func minimizeSystemModal(_ touchBar: NSTouchBar!) -> Void {
|
||||
if #available(OSX 10.14, *) {
|
||||
NSTouchBar.minimizeSystemModalTouchBar(touchBar)
|
||||
} else {
|
||||
NSTouchBar.minimizeSystemModalFunctionBar(touchBar)
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ struct ExactItem {
|
||||
let presetItem: BarItemDefinition
|
||||
}
|
||||
|
||||
let appSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR")
|
||||
let standardConfigPath = appSupportDirectory.appending("/items.json")
|
||||
|
||||
extension ItemType {
|
||||
|
||||
var identifierBase: String {
|
||||
@@ -39,6 +42,12 @@ extension ItemType {
|
||||
return "com.toxblh.mtmr.inputsource."
|
||||
case .music(interval: _):
|
||||
return "com.toxblh.mtmr.music."
|
||||
case .groupBar(items: _):
|
||||
return "com.toxblh.mtmr.groupBar."
|
||||
case .nightShift(items: _):
|
||||
return "com.toxblh.mtmr.nightShift."
|
||||
case .dnd(items: _):
|
||||
return "com.toxblh.mtmr.dnd."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +63,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
|
||||
var touchBar: NSTouchBar!
|
||||
|
||||
fileprivate var lastPresetPath = ""
|
||||
var jsonItems: [BarItemDefinition] = []
|
||||
var itemDefinitions: [NSTouchBarItem.Identifier: BarItemDefinition] = [:]
|
||||
var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:]
|
||||
var leftIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||
@@ -72,6 +83,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
var touchbarNeedRefresh: Bool = true
|
||||
|
||||
var blacklistAppIdentifiers: [String] = []
|
||||
var frontmostApplicationIdentifier: String? {
|
||||
get {
|
||||
@@ -83,6 +96,13 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
private override init() {
|
||||
super.init()
|
||||
SupportedTypesHolder.sharedInstance.register(typename: "exitTouchbar", item: .staticButton(title: "exit"), action: .custom(closure: { [weak self] in self?.dismissTouchBar()}), longAction: .none)
|
||||
|
||||
SupportedTypesHolder.sharedInstance.register(typename: "close") { _ in
|
||||
return (item: .staticButton(title: ""), action: .custom(closure: { [weak self] in
|
||||
guard let `self` = self else { return }
|
||||
self.reloadPreset(path: self.lastPresetPath)
|
||||
}), longAction: .none, parameters: [.width: .width(30), .image: .image(source: (NSImage(named: NSImage.stopProgressFreestandingTemplateName))!)])
|
||||
}
|
||||
|
||||
if let blackListed = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.blackListedApps") {
|
||||
self.blacklistAppIdentifiers = blackListed
|
||||
@@ -92,25 +112,22 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didTerminateApplicationNotification, object: nil)
|
||||
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didActivateApplicationNotification, object: nil)
|
||||
|
||||
createAndUpdatePreset()
|
||||
reloadStandardConfig()
|
||||
}
|
||||
|
||||
func createAndUpdatePreset(jsonItems: [BarItemDefinition]? = nil) {
|
||||
func createAndUpdatePreset(newJsonItems: [BarItemDefinition]) {
|
||||
if let oldBar = self.touchBar {
|
||||
NSTouchBar.minimizeSystemModalFunctionBar(oldBar)
|
||||
minimizeSystemModal(oldBar)
|
||||
}
|
||||
self.touchBar = NSTouchBar()
|
||||
var jsonItems = jsonItems
|
||||
self.jsonItems = newJsonItems
|
||||
self.itemDefinitions = [:]
|
||||
self.items = [:]
|
||||
self.leftIdentifiers = []
|
||||
self.centerItems = []
|
||||
self.rightIdentifiers = []
|
||||
|
||||
if (jsonItems == nil) {
|
||||
jsonItems = readConfig()
|
||||
}
|
||||
loadItemDefinitions(jsonItems: jsonItems!)
|
||||
loadItemDefinitions(jsonItems: self.jsonItems)
|
||||
createItems()
|
||||
|
||||
centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
||||
@@ -134,23 +151,29 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
func updateActiveApp() {
|
||||
if self.blacklistAppIdentifiers.index(of: self.frontmostApplicationIdentifier!) != nil {
|
||||
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, false)
|
||||
self.touchbarNeedRefresh = true
|
||||
} else {
|
||||
presentTouchBar()
|
||||
self.touchbarNeedRefresh = false
|
||||
}
|
||||
}
|
||||
|
||||
func readConfig() -> [BarItemDefinition]? {
|
||||
let appSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR")
|
||||
let presetPath = appSupportDirectory.appending("/items.json")
|
||||
func reloadStandardConfig() {
|
||||
let presetPath = standardConfigPath
|
||||
if !FileManager.default.fileExists(atPath: presetPath),
|
||||
let defaultPreset = Bundle.main.path(forResource: "defaultPreset", ofType: "json") {
|
||||
try? FileManager.default.createDirectory(atPath: appSupportDirectory, withIntermediateDirectories: true, attributes: nil)
|
||||
try? FileManager.default.copyItem(atPath: defaultPreset, toPath: presetPath)
|
||||
}
|
||||
|
||||
let jsonData = presetPath.fileData
|
||||
|
||||
return jsonData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
||||
reloadPreset(path: presetPath)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func loadItemDefinitions(jsonItems: [BarItemDefinition]) {
|
||||
@@ -192,20 +215,23 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
}
|
||||
|
||||
@objc private func presentTouchBar() {
|
||||
if self.controlStripState {
|
||||
NSTouchBar.presentSystemModalFunctionBar(touchBar, systemTrayItemIdentifier: .controlStripItem)
|
||||
} else {
|
||||
NSTouchBar.presentSystemModalFunctionBar(touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
|
||||
if touchbarNeedRefresh {
|
||||
if self.controlStripState {
|
||||
presentSystemModal(touchBar, systemTrayItemIdentifier: .controlStripItem)
|
||||
} else {
|
||||
presentSystemModal(touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func resetControlStrip() {
|
||||
NSTouchBar.minimizeSystemModalFunctionBar(self.touchBar)
|
||||
presentTouchBar()
|
||||
}
|
||||
|
||||
@objc private func dismissTouchBar() {
|
||||
NSTouchBar.minimizeSystemModalFunctionBar(touchBar)
|
||||
self.touchbarNeedRefresh = true
|
||||
minimizeSystemModal(touchBar)
|
||||
}
|
||||
|
||||
@objc func resetControlStrip() {
|
||||
dismissTouchBar()
|
||||
presentTouchBar()
|
||||
}
|
||||
|
||||
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
||||
@@ -255,6 +281,12 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
barItem = InputSourceBarItem(identifier: identifier)
|
||||
case .music(interval: let interval):
|
||||
barItem = MusicBarItem(identifier: identifier, interval: interval)
|
||||
case .groupBar(items: let items):
|
||||
barItem = GroupBarItem(identifier: identifier, items: items)
|
||||
case .nightShift():
|
||||
barItem = NightShiftBarItem(identifier: identifier)
|
||||
case .dnd():
|
||||
barItem = DnDBarItem(identifier: identifier)
|
||||
}
|
||||
|
||||
if let action = self.action(forItem: item), let item = barItem as? CustomButtonTouchBarItem {
|
||||
@@ -275,6 +307,13 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
if case .image(let source)? = item.additionalParameters[.image], let item = barItem as? CustomButtonTouchBarItem {
|
||||
item.image = source.image
|
||||
}
|
||||
if case .title(let value)? = item.additionalParameters[.title] {
|
||||
if let item = barItem as? GroupBarItem {
|
||||
item.collapsedRepresentationLabel = value
|
||||
} else if let item = barItem as? CustomButtonTouchBarItem {
|
||||
item.title = value
|
||||
}
|
||||
}
|
||||
return barItem
|
||||
}
|
||||
|
||||
@@ -284,7 +323,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
return { HIDPostAuxKey(keycode) }
|
||||
case .keyPress(keycode: let keycode):
|
||||
return { GenericKeyPress(keyCode: CGKeyCode(keycode)).send() }
|
||||
case .appleSctipt(source: let source):
|
||||
case .appleScript(source: let source):
|
||||
guard let appleScript = source.appleScript else {
|
||||
print("cannot create apple script for item \(item)")
|
||||
return {}
|
||||
@@ -329,7 +368,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
return { HIDPostAuxKey(keycode) }
|
||||
case .keyPress(keycode: let keycode):
|
||||
return { GenericKeyPress(keyCode: CGKeyCode(keycode)).send() }
|
||||
case .appleSctipt(source: let source):
|
||||
case .appleScript(source: let source):
|
||||
guard let appleScript = source.appleScript else {
|
||||
print("cannot create apple script for item \(item)")
|
||||
return {}
|
||||
|
||||
@@ -138,7 +138,7 @@ class BatteryInfo: NSObject {
|
||||
}
|
||||
|
||||
let newTitle = NSMutableAttributedString(string: title as String, attributes: [.foregroundColor: color, .font: NSFont.systemFont(ofSize: 15), .baselineOffset: 1])
|
||||
let newTitleSecond = NSMutableAttributedString(string: timeRemaining as String, attributes: [NSAttributedStringKey.foregroundColor: color, NSAttributedStringKey.font: NSFont.systemFont(ofSize: 8, weight: .regular), NSAttributedStringKey.baselineOffset: 7])
|
||||
let newTitleSecond = NSMutableAttributedString(string: timeRemaining as String, attributes: [NSAttributedString.Key.foregroundColor: color, NSAttributedString.Key.font: NSFont.systemFont(ofSize: 8, weight: .regular), NSAttributedString.Key.baselineOffset: 7])
|
||||
newTitle.append(newTitleSecond)
|
||||
newTitle.setAlignment(.center, range: NSRange(location: 0, length: title.count))
|
||||
return newTitle
|
||||
|
||||
@@ -23,7 +23,7 @@ class BrightnessViewController: NSCustomTouchBarItem {
|
||||
self.view = sliderItem
|
||||
|
||||
let timer = Timer.scheduledTimer(timeInterval: refreshInterval, target: self, selector: #selector(BrightnessViewController.updateBrightnessSlider), userInfo: nil, repeats: true)
|
||||
RunLoop.current.add(timer, forMode: RunLoopMode.commonModes)
|
||||
RunLoop.current.add(timer, forMode: RunLoop.Mode.common)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// DnDBarItem.swift
|
||||
// MTMR
|
||||
//
|
||||
// Created by Anton Palgunov on 29/08/2018.
|
||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class DnDBarItem : CustomButtonTouchBarItem {
|
||||
private var timer: Timer!
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier) {
|
||||
super.init(identifier: identifier, title: "")
|
||||
self.isBordered = false
|
||||
self.setWidth(value: 32)
|
||||
|
||||
self.tapClosure = { [weak self] in self?.DnDToggle() }
|
||||
|
||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(refresh), userInfo: nil, repeats: true)
|
||||
|
||||
self.refresh()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func DnDToggle() {
|
||||
DoNotDisturb.isEnabled = !DoNotDisturb.isEnabled
|
||||
refresh()
|
||||
}
|
||||
|
||||
@objc func refresh() {
|
||||
self.image = DoNotDisturb.isEnabled ? #imageLiteral(resourceName: "dnd-on") : #imageLiteral(resourceName: "dnd-off")
|
||||
}
|
||||
}
|
||||
|
||||
public struct DoNotDisturb {
|
||||
private static let appId = "com.apple.notificationcenterui" as CFString
|
||||
private static let dndPref = "com.apple.notificationcenterui.dndprefs_changed"
|
||||
|
||||
private static func set(_ key: String, value: CFPropertyList?) {
|
||||
CFPreferencesSetValue(key as CFString, value, appId, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost)
|
||||
}
|
||||
|
||||
private static func commitChanges() {
|
||||
CFPreferencesSynchronize(appId, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost)
|
||||
DistributedNotificationCenter.default().postNotificationName(NSNotification.Name(dndPref), object: nil, userInfo: nil, deliverImmediately: true)
|
||||
NSRunningApplication.runningApplications(withBundleIdentifier: appId as String).first?.terminate()
|
||||
}
|
||||
|
||||
private static func enable() {
|
||||
set("dndStart", value: nil)
|
||||
set("dndEnd", value: nil)
|
||||
set("doNotDisturb", value: true as CFPropertyList)
|
||||
set("doNotDisturbDate", value: Date() as CFPropertyList)
|
||||
commitChanges()
|
||||
}
|
||||
|
||||
private static func disable() {
|
||||
set("dndStart", value: nil)
|
||||
set("dndEnd", value: nil)
|
||||
set("doNotDisturb", value: false as CFPropertyList)
|
||||
set("doNotDisturbDate", value: nil)
|
||||
commitChanges()
|
||||
}
|
||||
|
||||
static var isEnabled:Bool {
|
||||
get {
|
||||
return CFPreferencesGetAppBooleanValue("doNotDisturb" as CFString, appId, nil)
|
||||
}
|
||||
set {
|
||||
newValue ? enable() : disable()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// GroupBarItem.swift
|
||||
// MTMR
|
||||
//
|
||||
// Created by Daniel Apatin on 11.05.2018.
|
||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
import Cocoa
|
||||
|
||||
class GroupBarItem: NSPopoverTouchBarItem, NSTouchBarDelegate {
|
||||
|
||||
var jsonItems: [BarItemDefinition]
|
||||
|
||||
var itemDefinitions: [NSTouchBarItem.Identifier: BarItemDefinition] = [:]
|
||||
var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:]
|
||||
var leftIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||
var centerIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||
var centerItems: [NSTouchBarItem] = []
|
||||
var rightIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||
var scrollArea: NSCustomTouchBarItem?
|
||||
var centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, items: [BarItemDefinition]) {
|
||||
jsonItems = items
|
||||
super.init(identifier: identifier)
|
||||
self.popoverTouchBar.delegate = self
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
||||
}
|
||||
|
||||
@objc override func showPopover(_ sender: Any?) {
|
||||
self.itemDefinitions = [:]
|
||||
self.items = [:]
|
||||
self.leftIdentifiers = []
|
||||
self.centerItems = []
|
||||
self.rightIdentifiers = []
|
||||
|
||||
self.loadItemDefinitions(jsonItems: jsonItems)
|
||||
self.createItems()
|
||||
|
||||
centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
||||
return items[identifier]
|
||||
})
|
||||
|
||||
self.centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||
self.scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)
|
||||
|
||||
TouchBarController.shared.touchBar.delegate = self
|
||||
TouchBarController.shared.touchBar.defaultItemIdentifiers = []
|
||||
TouchBarController.shared.touchBar.defaultItemIdentifiers = self.leftIdentifiers + [centerScrollArea] + self.rightIdentifiers
|
||||
|
||||
if TouchBarController.shared.controlStripState {
|
||||
presentSystemModal(TouchBarController.shared.touchBar, systemTrayItemIdentifier: .controlStripItem)
|
||||
} else {
|
||||
presentSystemModal(TouchBarController.shared.touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
|
||||
}
|
||||
}
|
||||
|
||||
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
||||
if identifier == centerScrollArea {
|
||||
return self.scrollArea
|
||||
}
|
||||
|
||||
guard let item = self.items[identifier],
|
||||
let definition = self.itemDefinitions[identifier],
|
||||
definition.align != .center else {
|
||||
return nil
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
func loadItemDefinitions(jsonItems: [BarItemDefinition]) {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "HH-mm-ss"
|
||||
let time = dateFormatter.string(from: Date())
|
||||
for item in jsonItems {
|
||||
let identifierString = item.type.identifierBase.appending(time + "--" + UUID().uuidString)
|
||||
let identifier = NSTouchBarItem.Identifier(identifierString)
|
||||
itemDefinitions[identifier] = item
|
||||
if item.align == .left {
|
||||
leftIdentifiers.append(identifier)
|
||||
}
|
||||
if item.align == .right {
|
||||
rightIdentifiers.append(identifier)
|
||||
}
|
||||
if item.align == .center {
|
||||
centerIdentifiers.append(identifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func createItems() {
|
||||
for (identifier, definition) in self.itemDefinitions {
|
||||
self.items[identifier] = TouchBarController.shared.createItem(forIdentifier: identifier, definition: definition)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,7 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
self.tapClosure = { [weak self] in self?.playPause() }
|
||||
self.longTapClosure = { [weak self] in self?.nextTrack() }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.updatePlayer()
|
||||
}
|
||||
self.refreshAndSchedule()
|
||||
}
|
||||
|
||||
@objc func marquee(){
|
||||
@@ -118,14 +116,17 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
if (musicPlayer.className == "SpotifyApplication") {
|
||||
let mp = (musicPlayer as SpotifyApplication)
|
||||
mp.nextTrack!()
|
||||
updatePlayer()
|
||||
return
|
||||
} else if (musicPlayer.className == "ITunesApplication") {
|
||||
let mp = (musicPlayer as iTunesApplication)
|
||||
mp.nextTrack!()
|
||||
updatePlayer()
|
||||
return
|
||||
} else if (musicPlayer.className == "VOXApplication") {
|
||||
let mp = (musicPlayer as VoxApplication)
|
||||
mp.next!()
|
||||
updatePlayer()
|
||||
return
|
||||
} else if (musicPlayer.className == "SafariApplication") {
|
||||
// You must enable the 'Allow JavaScript from Apple Events' option in Safari's Develop menu to use 'do JavaScript'.
|
||||
@@ -136,12 +137,15 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
let tab = tab as! SafariTab
|
||||
if (tab.URL?.starts(with: "https://music.yandex.ru"))! {
|
||||
_ = safariApplication.doJavaScript!("document.getElementsByClassName('player-controls__btn_next')[0].click()", in: tab)
|
||||
updatePlayer()
|
||||
return
|
||||
} else if ((tab.URL?.starts(with: "https://vk.com/audios"))! || (tab.URL?.starts(with: "https://vk.com/music"))!) {
|
||||
_ = safariApplication.doJavaScript!("document.getElementsByClassName('audio_page_player_next')[0].click()", in: tab)
|
||||
updatePlayer()
|
||||
return
|
||||
} else if (tab.URL?.starts(with: "https://www.youtube.com/watch"))! {
|
||||
_ = safariApplication.doJavaScript!("document.getElementsByClassName('ytp-next-button')[0].click()", in: tab)
|
||||
updatePlayer()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -152,6 +156,15 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
}
|
||||
}
|
||||
|
||||
func refreshAndSchedule() {
|
||||
DispatchQueue.main.async {
|
||||
self.updatePlayer()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + self.interval) { [weak self] in
|
||||
self?.refreshAndSchedule()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updatePlayer() {
|
||||
var iconUpdated = false
|
||||
var titleUpdated = false
|
||||
@@ -215,9 +228,6 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
}
|
||||
|
||||
if (tempTitle == self.songTitle) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + self.interval) { [weak self] in
|
||||
self?.updatePlayer()
|
||||
}
|
||||
return
|
||||
} else {
|
||||
self.songTitle = tempTitle
|
||||
@@ -251,9 +261,6 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
self.title = ""
|
||||
}
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + self.interval) { [weak self] in
|
||||
self?.updatePlayer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// NightShiftBarItem.swift
|
||||
// MTMR
|
||||
//
|
||||
// Created by Anton Palgunov on 28/08/2018.
|
||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class NightShiftBarItem: CustomButtonTouchBarItem {
|
||||
private let nsclient = CBBlueLightClient()
|
||||
private var timer: Timer!
|
||||
|
||||
private var blueLightStatus: Status {
|
||||
var status: Status = Status()
|
||||
nsclient.getBlueLightStatus(&status)
|
||||
return status
|
||||
}
|
||||
|
||||
private var isNightShiftEnabled: Bool {
|
||||
return self.blueLightStatus.enabled.boolValue
|
||||
}
|
||||
|
||||
private func setNightShift(state: Bool) {
|
||||
self.nsclient.setEnabled(state)
|
||||
}
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier) {
|
||||
super.init(identifier: identifier, title: "")
|
||||
self.isBordered = false
|
||||
self.setWidth(value: 28)
|
||||
|
||||
self.tapClosure = { [weak self] in self?.nightShiftAction() }
|
||||
|
||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(refresh), userInfo: nil, repeats: true)
|
||||
|
||||
self.refresh()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func nightShiftAction() {
|
||||
self.setNightShift(state: !self.isNightShiftEnabled)
|
||||
self.refresh()
|
||||
}
|
||||
|
||||
@objc func refresh() {
|
||||
self.image = isNightShiftEnabled ? #imageLiteral(resourceName: "nightShiftOn") : #imageLiteral(resourceName: "nightShiftOff")
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
}
|
||||
},
|
||||
{ "type": "brightnessUp", "width": 44, "align": "left" },
|
||||
// --- iTunes ---
|
||||
{
|
||||
"type": "appleScriptTitledButton",
|
||||
"source": {
|
||||
@@ -29,40 +30,42 @@
|
||||
"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"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "appleScriptTitledButton",
|
||||
"source": {
|
||||
"inline":
|
||||
"if application \"Spotify\" is running then\rtell application \"Spotify\"\rif player state is playing then\rreturn (get artist of current track) & \" – \" & (get name of current track)\relse\rreturn \"\"\rend if\rend tell\rend if\rreturn \"\"\r"
|
||||
},
|
||||
"action": "appleScript",
|
||||
"actionAppleScript": {
|
||||
"inline":
|
||||
"if application \"Spotify\" is running then\rtell application \"Spotify\"\rif player state is playing then\rnext track\rend if\rend tell\rend if\r"
|
||||
},
|
||||
"refreshInterval": 1,
|
||||
"image": {
|
||||
"base64":
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAYUExURUdwTB3WXx3UXh3VXx7XYBkXFRpVLRyURmIaeAQAAAAEdFJOUwDDO3fSqUUkAAABbklEQVRIx61VbW6DMAztoAeYNA7ApB6gkzhAWS24wIAL0HABaK6/pHFNEhy8TXu/kPzkPD/8cTj8K7KPAqB+K5NhQPCUrABCXe7HOUYYZxgVRLiG8RfY4DUgFFtC7cffAfZTFBwBdhWEKfgEq4ocEjgj4ZQifO6/QG9kkETp1dDeVWfRKx3XYSW0LoqY5kCElXDrQkyeCCuh6WL0M4nIWQIyzqixdfKU1koFDKvyCA8NJMzU4xiD+b4kfHRpsIyKc6hBwjVptFHVY51EMAINNDFGJITKDNQcdpX74Hz0CQ3rY5qwMp4EIxrlafzrsYZ2Veb0DkRgfNCUok4Y1fqEijfyi2b8RE9beWqa48Y/uvCNMcH9btfUi+/CGLR1vhL6Zz9N/vBlaCU+7lwY/cmJ67Ryen/2tj23PLqJBodZH8vgj544vOL4pxfI5acrSFxi8hrkU9TSKr78ZpnL50A8KPJJEo+afBblwyqf5j/iGys5j6ScrST2AAAAAElFTkSuQmCC"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "appleScriptTitledButton",
|
||||
"source": {
|
||||
"inline":
|
||||
"if application \"VOX\" is running then\rtell application \"VOX\"\rif player state is 1 then\rreturn (get artist) & \" – \" & (get track)\relse\rreturn \"\"\rend if\rend tell\rend if\rreturn \"\"\r"
|
||||
},
|
||||
"action": "appleScript",
|
||||
"actionAppleScript": {
|
||||
"inline":
|
||||
"if application \"VOX\" is running then\rtell application \"VOX\"\rif player state is 1 then\rnext\rend if\rend tell\rend if\r"
|
||||
},
|
||||
"refreshInterval": 1,
|
||||
"image": {
|
||||
"base64":
|
||||
"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"
|
||||
}
|
||||
},
|
||||
// --- Spotify ---
|
||||
// {
|
||||
// "type": "appleScriptTitledButton",
|
||||
// "source": {
|
||||
// "inline":
|
||||
// "if application \"Spotify\" is running then\rtell application \"Spotify\"\rif player state is playing then\rreturn (get artist of current track) & \" – \" & (get name of current track)\relse\rreturn \"\"\rend if\rend tell\rend if\rreturn \"\"\r"
|
||||
// },
|
||||
// "action": "appleScript",
|
||||
// "actionAppleScript": {
|
||||
// "inline":
|
||||
// "if application \"Spotify\" is running then\rtell application \"Spotify\"\rif player state is playing then\rnext track\rend if\rend tell\rend if\r"
|
||||
// },
|
||||
// "refreshInterval": 1,
|
||||
// "image": {
|
||||
// "base64":
|
||||
// "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAYUExURUdwTB3WXx3UXh3VXx7XYBkXFRpVLRyURmIaeAQAAAAEdFJOUwDDO3fSqUUkAAABbklEQVRIx61VbW6DMAztoAeYNA7ApB6gkzhAWS24wIAL0HABaK6/pHFNEhy8TXu/kPzkPD/8cTj8K7KPAqB+K5NhQPCUrABCXe7HOUYYZxgVRLiG8RfY4DUgFFtC7cffAfZTFBwBdhWEKfgEq4ocEjgj4ZQifO6/QG9kkETp1dDeVWfRKx3XYSW0LoqY5kCElXDrQkyeCCuh6WL0M4nIWQIyzqixdfKU1koFDKvyCA8NJMzU4xiD+b4kfHRpsIyKc6hBwjVptFHVY51EMAINNDFGJITKDNQcdpX74Hz0CQ3rY5qwMp4EIxrlafzrsYZ2Veb0DkRgfNCUok4Y1fqEijfyi2b8RE9beWqa48Y/uvCNMcH9btfUi+/CGLR1vhL6Zz9N/vBlaCU+7lwY/cmJ67Ryen/2tj23PLqJBodZH8vgj544vOL4pxfI5acrSFxi8hrkU9TSKr78ZpnL50A8KPJJEo+afBblwyqf5j/iGys5j6ScrST2AAAAAElFTkSuQmCC"
|
||||
// }
|
||||
// },
|
||||
// --- VOX ---
|
||||
// {
|
||||
// "type": "appleScriptTitledButton",
|
||||
// "source": {
|
||||
// "inline":
|
||||
// "if application \"VOX\" is running then\rtell application \"VOX\"\rif player state is 1 then\rreturn (get artist) & \" – \" & (get track)\relse\rreturn \"\"\rend if\rend tell\rend if\rreturn \"\"\r"
|
||||
// },
|
||||
// "action": "appleScript",
|
||||
// "actionAppleScript": {
|
||||
// "inline":
|
||||
// "if application \"VOX\" is running then\rtell application \"VOX\"\rif player state is 1 then\rnext\rend if\rend tell\rend if\r"
|
||||
// },
|
||||
// "refreshInterval": 1,
|
||||
// "image": {
|
||||
// "base64":
|
||||
// "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAADAUExURUdwTHd7gqeqtKClrd/k7n+Di7e7xI6TnNHX4cPI0Xp9hJibpOfs9u/1/vX7/rq/yZiborK3wEpOUxgYFlFXYiIhHycpLD9ESjI0NgsLCj09O4SKk19lcbBkALhoAHJ3gT8rAzMvJJugqKhcAL5xAOSxB4I/AJ5SAGpweXuAiZJJAG8zAeXr9WNiYM+NANqeAMd9APHACfr9/e7JPrO5w6mrsA4bKC0gCHhtTyAYBFcpAZduKK2JP/fost/Eb5SUlFFfi9AAAAASdFJOUwDJE9FgWjb+/vyHppTXtbn9mDupvZ0AAAdoSURBVFjDlZcLQ6O6FoWrtgI+Owl5EGgp2DrEgnV6wD4c7f//V3ftAE7nzOj17NGxpayPtXfSZGcw+CjOh1c3N9eIm5ur4fngv8Xp8KZE+F2U5bq8GZ5+WU5qP6jzsRdTeF7e1AEoN8Ovya/LMsg9mxZJErpIksJarwnK8nr4FblfQ52EDOH0zL1KUuvVfnn9eTVOryCPoVZQuGj/FOApMAhx9Uktzq/L2ksT3FuQhIVVVVRVRa+SogA1KbzgExPD0s/xdBOmKdOqODR95IdEaZba0LAkbfzyg0rA/pgekxZKV4cmtxXTEmFUEufNodIKYJjLkcbf9UEM90mqZJU3qeJRxDkXAv/hlbJNXkmVJjCBNP5CGPq1TZSyiWB5XomIi+woRBSJKj8YUVgFQ4E//FMfQM8s40VTyIhDpLVRNIJKaWLwSNqm4mEMl/YPwrkP/9AbER+UkxtWbbcvLrbbkBlCcDa23BABHn4bi1PSM2a1PFgZwbwJty+TybSLyeRlyxQlIuNY6FgpDKd/PB+uXP2tFHEheCtvhW3Q65dtiEyQRixMrBjG4uo4gTpNFApvU9Kr6sWp77qY3BFj8lLBBJdpykOLwaqPkgioAEnFi1RCz7Z3uJ2U37sgCBB3W5ZJLm0VJQmVIXgfgSAvQpYK1ACDx7bTOT2dlA8uWsYEl0EQ3KDUKcOECvqRCGgGpApXf9M/PNx3QQwyMZ9uGWZWiGelsFAHvQFUMEx4WAku2HZC+k6+vF/ip0U4wmSrBJcFZgss9xZuYYAlWhaGC1PhMb1++R6EaAl3lRFcFUI5C7duDlAFwpCzSogsfCH93fdWvm+jRYCASs5fwkyIinGsVrBAc2FYxwVLlKhgQG3n8+kv/WwjhNhsZvveQ5+EqrhKWOHVlMNtgyUkhHkpdPjy1CZA+pl4bkOIfWcBQ/EEC1xWWmKxsi6HussA9WUwQBV0BmbPz3y32+x2nD8/z/okpvM5LAjGeEg51JiFtQeAEqHhWUIGJq0B0m9mLjYdgSxMnQVhGHIIkcP5YNjEAGjJJDfF5AnzzRnY/9K3hP3SjSUAk0oLzaQOwyJGEb41FgWVuOIymHYZCKfPGFaxzBHEcQ5cYrXD3LHNt8E3WkdDbpBY8vMdMHsW0Jui9v26MCDAggNMAfgZoghGdIDbPMXewY0RWfHzqQMsN2QgC/MAkVcZWZi1DuYAJJlQBlVM0vx2cDZOw4QAPEt/AcTzDgkkh3w8Hh8SPZvtKIc2haefKapo2mE4G5x5nQOuLQA0jwggCcAqF1SFnZQEwEwCwGZ0P+sAXQqa69gBJvgeLCUBhMS6arSWogV0NWwB2gHG5KAggDYO0OXQATghJP4QIPsFiJHCEYB2YgBE5gBzNxEyjVHYcOxKKDfquRE6u39wFXh6dADJaccG4HLsANIIEb89PnaEvSYLG2kYAG0G+3YMnh4fDxbfe4wkAS47gAAyShsA2iSWUgsiYHfJMCF2ZKDVA9AkET4WbhgvB6OxxeoiuZZRVT/2BFjQfOemMX53qNn+e5fA42OtAOCYiYXNR4PznL4LJoLA1G8rQjjCTCmxc9+GzU4oNXvonr9avTUZPc7QdyHH0j4mgIqQVZQHq1VvAgRKf7MRKISZPWAG0ONXq1Vg6WYahMIbYz24pJ6ECYIyf7EiBBGm3/da0c6KX/ifTnv9P74iu66G3iUAI4+KoCNpeNS8rha9ifnkfmlcLO+n816+WL3mEVVcY2ew4xEtqsgBjUWEQkWsfFssWhdgPM0xoBg8iKl2JF8s3kpngCtMo3jsNljkUDAmYQFVWC9+tAgHeQ93AR/8WKw9d6MMWWFdBn0OJsJsjERZLn4QomOsWmmrpk9Kn0eYxpGiMfBG7dZ0FrcW8B2N1PoV9zkEUehn1b2hy68lxg/F0owVaXzW7Y0j6kwZuiqhUIaW8M54F9Olcq0irF0R1vAkfTdAFmwaKhjDUgfCur39n+NwF9ZrFhnMWm5YiM737L0/GHkxtYD4RKIWILz1+jf86/Vv69I4fSTRTNojAxgIdPUgCE7VjXhzhHAEJ1/nUUSl4qTHKeDyuMnCycCzjiCwyUYsWK9fofzhxIC8rtcBi2SlqPeEnu7/rekGwcutwhTHhKoYHlWvEa8u6FVN17D/Or3Ncfu/Wu5R7I2bmNECRiYYRpuaYtKiBa+0u0j9K7aguMFZZvTvVvUCFuoce5ygSmA9xlcRDR8iyzaZqVq50Coc1zBw8WezfBEfmqBGX+8QXLs1HY9tV3aMMeQSp4A6aP6qdx4aNHyMWnxBHbpwzTIW9vadkGTf/1BPdYhxsqrR7zuGoD4/6pp+iKVkaY3zWGxHHx55TuJxXZa1RSmwIyAyeoGVlf4wG9CBLD755Nx1ehHHub9e+3lBpxUh+0DuuO4ef/H5AXR0gkpg+EofjQed1ej8VsTuEk6T8cno/54cRyc2zms3Bcr+4Esvazz9C/IOYWlESNseoWtU3n5V3tYCDEA8tAce5j3enFyc/scT/Pno4qSLi9HHhf8f8eOIRf9lFswAAAAASUVORK5CYII="
|
||||
// }
|
||||
// },
|
||||
{ "type": "previous", "width": 44 },
|
||||
{ "type": "play", "width": 44 },
|
||||
{ "type": "next", "width": 44 },
|
||||
@@ -74,6 +77,6 @@
|
||||
{ "type": "volume", "width": 60, "align": "right" },
|
||||
{ "type": "volumeUp", "width": 34, "align": "right" },
|
||||
{ "type": "inputsource", "align": "right" },
|
||||
{ "type": "battery", "align": "right" },
|
||||
{ "type": "timeButton", "align": "right" }
|
||||
{ "type": "battery", "align": "right", "bordered": false },
|
||||
{ "type": "timeButton", "align": "right", "bordered": false }
|
||||
]
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
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
|
||||
35sZE2RHp4aEb9WceYHpjz8orPiLHJ/7OPbZ
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -4,6 +4,9 @@
|
||||
</p>
|
||||
|
||||
# My TouchBar. My rules
|
||||
|
||||
*The TouchBar Customization App for your MacBook Pro*
|
||||
|
||||
[](https://github.com/Toxblh/MTMR/releases)
|
||||
[](https://github.com/Toxblh/MTMR/blob/master/LICENSE) [](https://github.com/Toxblh/MTMR/releases/latest)  
|
||||
|
||||
@@ -11,6 +14,16 @@
|
||||
<img src="Resources/TouchBar-v0.8.1.png">
|
||||
</p>
|
||||
|
||||
**MTMR** Community:
|
||||
[<img height="24px" src="https://github.com/discourse/DiscourseMobile/raw/master/icon.png" /> Discourse](https://forum.mtmr.app)
|
||||
[<img height="24px" src="https://telegram.org/img/t_logo.png" /> Telegram](https://t.me/joinchat/AmVYGg8vW38c13_3MxdE_g)
|
||||
|
||||
<a href="https://www.buymeacoffee.com/toxblh" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" height="32px" ></a>
|
||||
<a href="https://www.patreon.com/bePatron?u=9900748"><img height="32px" src="https://c5.patreon.com/external/logo/become_a_patron_button.png" srcset="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png 2x"></a>
|
||||
[<img src="https://d1qb2nb5cznatu.cloudfront.net/startups/i/854859-e299e139ab7f79855c0bc589f10b0ec6-medium_jpg.jpg?buster=1453074480" height="32px" /> Become a backer](https://opencollective.com/MTMR#backer)
|
||||
[<img src="https://d1qb2nb5cznatu.cloudfront.net/startups/i/854859-e299e139ab7f79855c0bc589f10b0ec6-medium_jpg.jpg?buster=1453074480" height="32px" /> Become a sponsor](https://opencollective.com/MTMR#sponsor)
|
||||
|
||||
|
||||
My the idea is to create the program like a platform for plugins for customization TouchBar. I very like BTT and a full custom TouchBar (my [BTT preset](https://github.com/Toxblh/btt-touchbar-preset)). And I want to create it. And it's my the first Swift project for MacOS :)
|
||||
|
||||
### Roadmap
|
||||
@@ -27,16 +40,16 @@ My the idea is to create the program like a platform for plugins for customizati
|
||||
- [x] JSON or another approch for save preset, maybe in `~/Library/Application Support/MTMR/`
|
||||
- [x] Custom buttons size, actions by click
|
||||
- [x] Layout: [always left, NSSliderView for center, always right]
|
||||
- [x] System for autoupdate (https://sparkle-project.org/)
|
||||
- [ ] Overwrite default values from item types (e.g. title for brightness)
|
||||
- [ ] Custom settings for paddings and margins for buttons
|
||||
- [ ] XPC Service for scripts
|
||||
- [ ] UI for settings
|
||||
- [ ] Import config from BTT
|
||||
- [ ] System for autoupdate (maybe https://sparkle-project.org/)
|
||||
|
||||
Settings:
|
||||
- [ ] Interface for plugins and export like presets
|
||||
- [ ] Startup at login
|
||||
- [x] Startup at login
|
||||
- [ ] Show on/off in Dock
|
||||
- [ ] Show on/off in StatusBar
|
||||
- [ ] On/off Haptic Feedback
|
||||
@@ -59,10 +72,14 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
||||
- exitTouchbar
|
||||
- brightnessUp
|
||||
- brightnessDown
|
||||
- illuminationUp (keyboard illumination)
|
||||
- illuminationDown (keyboard illumination)
|
||||
- volumeDown
|
||||
- volumeUp
|
||||
- mute
|
||||
- dock
|
||||
- dock (half-long click to open app, full-long click to kill app)
|
||||
- nightShift
|
||||
- dnd (Dont disturb)
|
||||
|
||||
> Native Plugins
|
||||
- battery
|
||||
@@ -80,6 +97,10 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
||||
- sleep
|
||||
- displaySleep
|
||||
|
||||
## Gestures on central part:
|
||||
- two finger slide: change you Volume
|
||||
- three finger slide: change you Brightness
|
||||
|
||||
## Built-in slider types:
|
||||
|
||||
- brightness
|
||||
@@ -111,6 +132,17 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
||||
"formatTemplate": "HH:mm" //optional
|
||||
```
|
||||
|
||||
## Groups
|
||||
```js
|
||||
{
|
||||
"type": "group",
|
||||
"align": "center",
|
||||
"bordered": true,
|
||||
"title": "stats",
|
||||
"items": [{ button }, {button}, ...]
|
||||
}
|
||||
```
|
||||
|
||||
## Native plugins
|
||||
- `weather`
|
||||
> Provider: https://openweathermap.org Need allowance location service
|
||||
@@ -180,6 +212,20 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
||||
"url": "https://google.com",
|
||||
```
|
||||
|
||||
## LongActions
|
||||
This then you want to use longPress for some operations is will the same values like for Actions but different additional parameters, example:
|
||||
```js
|
||||
"longAction": "hidKey",
|
||||
"longKeycode": 53,
|
||||
```
|
||||
|
||||
- longAction
|
||||
- longKeycode
|
||||
- longActionAppleScript
|
||||
- longExecutablePath
|
||||
- longShellArguments
|
||||
- longUrl
|
||||
|
||||
## Additional parameters:
|
||||
|
||||
- `width` allow to restrict how much room a particular button will take
|
||||
@@ -256,8 +302,13 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
||||
|
||||
[@ReDetection preset](Resources/ReDetection.json)
|
||||
|
||||
### User's presets
|
||||
|
||||
[@luongvo209 preset](Resources/luongvo209.json)
|
||||

|
||||
|
||||
## Credits
|
||||
|
||||
<a href="https://www.buymeacoffee.com/toxblh" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
|
||||
|
||||
Built by [@Toxblh](https://patreon.com/toxblh) and [@ReDetection](http://patreon.com/ReDetection).
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
|
After Width: | Height: | Size: 62 KiB |
@@ -0,0 +1 @@
|
||||
Versions/Current/Headers
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Modules
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/PrivateHeaders
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Resources
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Sparkle
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// SPUDownloadData.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import "SUExport.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* A class for containing downloaded data along with some information about it.
|
||||
*/
|
||||
SU_EXPORT @interface SPUDownloadData : NSObject <NSSecureCoding>
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType;
|
||||
|
||||
/*!
|
||||
* The raw data that was downloaded.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSData *data;
|
||||
|
||||
/*!
|
||||
* The IANA charset encoding name if available. Eg: "utf-8"
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *textEncodingName;
|
||||
|
||||
/*!
|
||||
* The MIME type if available. Eg: "text/plain"
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *MIMEType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// SPUDownloader.h
|
||||
// Downloader
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/1/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SPUDownloaderProtocol.h"
|
||||
|
||||
@protocol SPUDownloaderDelegate;
|
||||
|
||||
// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
|
||||
@interface SPUDownloader : NSObject <SPUDownloaderProtocol>
|
||||
|
||||
// Due to XPC remote object reasons, this delegate is strongly referenced
|
||||
// Invoke cleanup when done with this instance
|
||||
- (instancetype)initWithDelegate:(id <SPUDownloaderDelegate>)delegate;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// SPUDownloaderDelegate.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/1/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SPUDownloadData;
|
||||
|
||||
@protocol SPUDownloaderDelegate <NSObject>
|
||||
|
||||
// This is only invoked for persistent downloads
|
||||
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory;
|
||||
|
||||
// Under rare cases, this may be called more than once, in which case the current progress should be reset back to 0
|
||||
// This is only invoked for persistent downloads
|
||||
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)expectedContentLength;
|
||||
|
||||
// This is only invoked for persistent downloads
|
||||
- (void)downloaderDidReceiveDataOfLength:(uint64_t)length;
|
||||
|
||||
// downloadData is nil if this is a persisent download, otherwise it's non-nil if it's a temporary download
|
||||
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)downloadData;
|
||||
|
||||
- (void)downloaderDidFailWithError:(NSError *)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// SPUDownloaderDeprecated.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Deadpikle on 12/20/17.
|
||||
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SPUDownloader.h"
|
||||
|
||||
@interface SPUDownloaderDeprecated : SPUDownloader <SPUDownloaderProtocol>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// SPUDownloaderProtocol.h
|
||||
// PersistentDownloader
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/1/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SPUURLRequest;
|
||||
|
||||
// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
|
||||
@protocol SPUDownloaderProtocol
|
||||
|
||||
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename;
|
||||
|
||||
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request;
|
||||
|
||||
- (void)downloadDidFinish;
|
||||
|
||||
- (void)cleanup;
|
||||
|
||||
- (void)cancel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// SPUDownloaderSession.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Deadpikle on 12/20/17.
|
||||
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SPUDownloader.h"
|
||||
#import "SPUDownloaderProtocol.h"
|
||||
|
||||
NS_CLASS_AVAILABLE(NSURLSESSION_AVAILABLE, 7_0)
|
||||
@interface SPUDownloaderSession : SPUDownloader <SPUDownloaderProtocol>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// SPUURLRequest.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 5/19/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// A class that wraps NSURLRequest and implements NSSecureCoding
|
||||
// This class exists because NSURLRequest did not support NSSecureCoding in macOS 10.8
|
||||
// I have not verified if NSURLRequest in 10.9 implements NSSecureCoding or not
|
||||
@interface SPUURLRequest : NSObject <NSSecureCoding>
|
||||
|
||||
// Creates a new URL request
|
||||
// Only these properties are currently tracked:
|
||||
// * URL
|
||||
// * Cache policy
|
||||
// * Timeout interval
|
||||
// * HTTP header fields
|
||||
// * networkServiceType
|
||||
+ (instancetype)URLRequestWithRequest:(NSURLRequest *)request;
|
||||
|
||||
@property (nonatomic, readonly) NSURLRequest *request;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// SUAppcast.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/12/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUAPPCAST_H
|
||||
#define SUAPPCAST_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUAppcastItem;
|
||||
SU_EXPORT @interface SUAppcast : NSObject
|
||||
|
||||
@property (copy, nullable) NSString *userAgentString;
|
||||
@property (copy, nullable) NSDictionary<NSString *, NSString *> *httpHeaders;
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)bg completionBlock:(void (^)(NSError *_Nullable))err;
|
||||
- (SUAppcast *)copyWithoutDeltaUpdates;
|
||||
|
||||
@property (readonly, copy, nullable) NSArray *items;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// SUAppcastItem.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/12/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUAPPCASTITEM_H
|
||||
#define SUAPPCASTITEM_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSString *dateString;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||
@property (copy, readonly) NSString *DSASignature;
|
||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||
@property (strong, readonly) NSURL *fileURL;
|
||||
@property (nonatomic, readonly) uint64_t contentLength;
|
||||
@property (copy, readonly) NSString *versionString;
|
||||
@property (copy, readonly) NSString *osString;
|
||||
@property (copy, readonly) NSString *displayVersionString;
|
||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||
@property (strong, readonly) NSURL *infoURL;
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString **)error;
|
||||
|
||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
|
||||
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
||||
|
||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||
@property (readonly, copy) NSDictionary *propertiesDictionary;
|
||||
|
||||
- (NSURL *)infoURL;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// SUCodeSigningVerifier.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 7/5/12.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef SUCODESIGNINGVERIFIER_H
|
||||
#define SUCODESIGNINGVERIFIER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUExport.h"
|
||||
|
||||
SU_EXPORT @interface SUCodeSigningVerifier : NSObject
|
||||
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
|
||||
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
|
||||
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
|
||||
+ (NSDictionary *)codeSignatureInfoAtBundleURL:(NSURL *)bundlePath;
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// SUErrors.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by C.W. Betts on 10/13/14.
|
||||
// Copyright (c) 2014 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUERRORS_H
|
||||
#define SUERRORS_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
/**
|
||||
* Error domain used by Sparkle
|
||||
*/
|
||||
SU_EXPORT extern NSString *const SUSparkleErrorDomain;
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wc++98-compat"
|
||||
typedef NS_ENUM(OSStatus, SUError) {
|
||||
// Appcast phase errors.
|
||||
SUAppcastParseError = 1000,
|
||||
SUNoUpdateError = 1001,
|
||||
SUAppcastError = 1002,
|
||||
SURunningFromDiskImageError = 1003,
|
||||
|
||||
// Download phase errors.
|
||||
SUTemporaryDirectoryError = 2000,
|
||||
SUDownloadError = 2001,
|
||||
|
||||
// Extraction phase errors.
|
||||
SUUnarchivingError = 3000,
|
||||
SUSignatureError = 3001,
|
||||
|
||||
// Installation phase errors.
|
||||
SUFileCopyFailure = 4000,
|
||||
SUAuthenticationFailure = 4001,
|
||||
SUMissingUpdateError = 4002,
|
||||
SUMissingInstallerToolError = 4003,
|
||||
SURelaunchError = 4004,
|
||||
SUInstallationError = 4005,
|
||||
SUDowngradeError = 4006,
|
||||
SUInstallationCancelledError = 4007,
|
||||
|
||||
// System phase errors
|
||||
SUSystemPowerOffError = 5000
|
||||
};
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// SUExport.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Jake Petroules on 2014-08-23.
|
||||
// Copyright (c) 2014 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUEXPORT_H
|
||||
#define SUEXPORT_H
|
||||
|
||||
#ifdef BUILDING_SPARKLE
|
||||
#define SU_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define SU_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// SUStandardVersionComparator.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 12/21/07.
|
||||
// Copyright 2007 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
|
||||
#define SUSTANDARDVERSIONCOMPARATOR_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
Sparkle's default version comparator.
|
||||
|
||||
This comparator is adapted from MacPAD, by Kevin Ballard.
|
||||
It's "dumb" in that it does essentially string comparison,
|
||||
in components split by character type.
|
||||
*/
|
||||
SU_EXPORT @interface SUStandardVersionComparator : NSObject <SUVersionComparison>
|
||||
|
||||
/*!
|
||||
Initializes a new instance of the standard version comparator.
|
||||
*/
|
||||
- (instancetype)init;
|
||||
|
||||
/*!
|
||||
Returns a singleton instance of the comparator.
|
||||
|
||||
It is usually preferred to alloc/init new a comparator instead.
|
||||
*/
|
||||
+ (SUStandardVersionComparator *)defaultComparator;
|
||||
|
||||
/*!
|
||||
Compares version strings through textual analysis.
|
||||
|
||||
See the implementation for more details.
|
||||
*/
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
#endif
|
||||
@@ -0,0 +1,231 @@
|
||||
//
|
||||
// SUUpdater.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 1/4/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUUPDATER_H
|
||||
#define SUUPDATER_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Cocoa;
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
|
||||
@class SUAppcastItem, SUAppcast;
|
||||
|
||||
@protocol SUUpdaterDelegate;
|
||||
|
||||
/*!
|
||||
The main API in Sparkle for controlling the update mechanism.
|
||||
|
||||
This class is used to configure the update paramters as well as manually
|
||||
and automatically schedule and control checks for updates.
|
||||
*/
|
||||
SU_EXPORT @interface SUUpdater : NSObject
|
||||
|
||||
@property (unsafe_unretained) IBOutlet id<SUUpdaterDelegate> delegate;
|
||||
|
||||
/*!
|
||||
The shared updater for the main bundle.
|
||||
|
||||
This is equivalent to passing [NSBundle mainBundle] to SUUpdater::updaterForBundle:
|
||||
*/
|
||||
+ (SUUpdater *)sharedUpdater;
|
||||
|
||||
/*!
|
||||
The shared updater for a specified bundle.
|
||||
|
||||
If an updater has already been initialized for the provided bundle, that shared instance will be returned.
|
||||
*/
|
||||
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
|
||||
|
||||
/*!
|
||||
Designated initializer for SUUpdater.
|
||||
|
||||
If an updater has already been initialized for the provided bundle, that shared instance will be returned.
|
||||
*/
|
||||
- (instancetype)initForBundle:(NSBundle *)bundle;
|
||||
|
||||
/*!
|
||||
Explicitly checks for updates and displays a progress dialog while doing so.
|
||||
|
||||
This method is meant for a main menu item.
|
||||
Connect any menu item to this action in Interface Builder,
|
||||
and Sparkle will check for updates and report back its findings verbosely
|
||||
when it is invoked.
|
||||
|
||||
This will find updates that the user has opted into skipping.
|
||||
*/
|
||||
- (IBAction)checkForUpdates:(id)sender;
|
||||
|
||||
/*!
|
||||
The menu item validation used for the -checkForUpdates: action
|
||||
*/
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
|
||||
|
||||
/*!
|
||||
Checks for updates, but does not display any UI unless an update is found.
|
||||
|
||||
This is meant for programmatically initating a check for updates. That is,
|
||||
it will display no UI unless it actually finds an update, in which case it
|
||||
proceeds as usual.
|
||||
|
||||
If automatic downloading of updates it turned on and allowed, however,
|
||||
this will invoke that behavior, and if an update is found, it will be downloaded
|
||||
in the background silently and will be prepped for installation.
|
||||
|
||||
This will not find updates that the user has opted into skipping.
|
||||
*/
|
||||
- (void)checkForUpdatesInBackground;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not to check for updates automatically.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
The update schedule cycle will be reset in a short delay after the property's new value is set.
|
||||
This is to allow reverting this property without kicking off a schedule change immediately
|
||||
*/
|
||||
@property BOOL automaticallyChecksForUpdates;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not updates can be automatically downloaded in the background.
|
||||
|
||||
Note that automatic downloading of updates can be disallowed by the developer
|
||||
or by the user's system if silent updates cannot be done (eg: if they require authentication).
|
||||
In this case, -automaticallyDownloadsUpdates will return NO regardless of how this property is set.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
*/
|
||||
@property BOOL automaticallyDownloadsUpdates;
|
||||
|
||||
/*!
|
||||
A property indicating the current automatic update check interval.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
The update schedule cycle will be reset in a short delay after the property's new value is set.
|
||||
This is to allow reverting this property without kicking off a schedule change immediately
|
||||
*/
|
||||
@property NSTimeInterval updateCheckInterval;
|
||||
|
||||
/*!
|
||||
Begins a "probing" check for updates which will not actually offer to
|
||||
update to that version.
|
||||
|
||||
However, the delegate methods
|
||||
SUUpdaterDelegate::updater:didFindValidUpdate: and
|
||||
SUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
|
||||
so you can use that information in your UI.
|
||||
|
||||
Updates that have been skipped by the user will not be found.
|
||||
*/
|
||||
- (void)checkForUpdateInformation;
|
||||
|
||||
/*!
|
||||
The URL of the appcast used to download update information.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
If you don't want persistence, you may want to consider instead implementing
|
||||
SUUpdaterDelegate::feedURLStringForUpdater: or SUUpdaterDelegate::feedParametersForUpdater:sendingSystemProfile:
|
||||
|
||||
This property must be called on the main thread.
|
||||
*/
|
||||
@property (copy) NSURL *feedURL;
|
||||
|
||||
/*!
|
||||
The host bundle that is being updated.
|
||||
*/
|
||||
@property (readonly, strong) NSBundle *hostBundle;
|
||||
|
||||
/*!
|
||||
The bundle this class (SUUpdater) is loaded into.
|
||||
*/
|
||||
@property (strong, readonly) NSBundle *sparkleBundle;
|
||||
|
||||
/*!
|
||||
The user agent used when checking for updates.
|
||||
|
||||
The default implementation can be overrided.
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *userAgentString;
|
||||
|
||||
/*!
|
||||
The HTTP headers used when checking for updates.
|
||||
|
||||
The keys of this dictionary are HTTP header fields (NSString) and values are corresponding values (NSString)
|
||||
*/
|
||||
@property (copy) NSDictionary<NSString *, NSString *> *httpHeaders;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not the user's system profile information is sent when checking for updates.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
*/
|
||||
@property BOOL sendsSystemProfile;
|
||||
|
||||
/*!
|
||||
A property indicating the decryption password used for extracting updates shipped as Apple Disk Images (dmg)
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *decryptionPassword;
|
||||
|
||||
/*!
|
||||
This function ignores normal update schedule, ignores user preferences,
|
||||
and interrupts users with an unwanted immediate app update.
|
||||
|
||||
WARNING: this function should not be used in regular apps. This function
|
||||
is a user-unfriendly hack only for very special cases, like unstable
|
||||
rapidly-changing beta builds that would not run correctly if they were
|
||||
even one day out of date.
|
||||
|
||||
Instead of this function you should set `SUAutomaticallyUpdate` to `YES`,
|
||||
which will gracefully install updates when the app quits.
|
||||
|
||||
For UI-less/daemon apps that aren't usually quit, instead of this function,
|
||||
you can use the delegate method
|
||||
SUUpdaterDelegate::updater:willInstallUpdateOnQuit:immediateInstallationInvocation:
|
||||
to immediately start installation when an update was found.
|
||||
|
||||
A progress dialog is shown but the user will never be prompted to read the
|
||||
release notes.
|
||||
|
||||
This function will cause update to be downloaded twice if automatic updates are
|
||||
enabled.
|
||||
|
||||
You may want to respond to the userDidCancelDownload delegate method in case
|
||||
the user clicks the "Cancel" button while the update is downloading.
|
||||
*/
|
||||
- (void)installUpdatesIfAvailable;
|
||||
|
||||
/*!
|
||||
Returns the date of last update check.
|
||||
|
||||
\returns \c nil if no check has been performed.
|
||||
*/
|
||||
@property (readonly, copy) NSDate *lastUpdateCheckDate;
|
||||
|
||||
/*!
|
||||
Appropriately schedules or cancels the update checking timer according to
|
||||
the preferences for time interval and automatic checks.
|
||||
|
||||
This call does not change the date of the next check,
|
||||
but only the internal NSTimer.
|
||||
*/
|
||||
- (void)resetUpdateCycle;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not an update is in progress.
|
||||
|
||||
Note this property is not indicative of whether or not user initiated updates can be performed.
|
||||
Use SUUpdater::validateMenuItem: for that instead.
|
||||
*/
|
||||
@property (readonly) BOOL updateInProgress;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,301 @@
|
||||
//
|
||||
// SUUpdaterDelegate.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 12/25/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import "SUExport.h"
|
||||
|
||||
@protocol SUVersionComparison, SUVersionDisplay;
|
||||
@class SUUpdater, SUAppcast, SUAppcastItem;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Notifications for events that might be interesting to more than just the delegate
|
||||
// The updater will be the notification object
|
||||
// -----------------------------------------------------------------------------
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidFindValidUpdateNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidNotFindUpdateNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterWillRestartNotification;
|
||||
#define SUUpdaterWillRelaunchApplicationNotification SUUpdaterWillRestartNotification;
|
||||
#define SUUpdaterWillInstallUpdateNotification SUUpdaterWillRestartNotification;
|
||||
|
||||
// Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification userInfo
|
||||
SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
|
||||
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
|
||||
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Delegate:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/*!
|
||||
Provides methods to control the behavior of an SUUpdater object.
|
||||
*/
|
||||
@protocol SUUpdaterDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
/*!
|
||||
Returns whether to allow Sparkle to pop up.
|
||||
|
||||
For example, this may be used to prevent Sparkle from interrupting a setup assistant.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns additional parameters to append to the appcast URL's query string.
|
||||
|
||||
This is potentially based on whether or not Sparkle will also be sending along the system profile.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param sendingProfile Whether the system profile will also be sent.
|
||||
|
||||
\return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
|
||||
*/
|
||||
- (NSArray<NSDictionary<NSString *, NSString *> *> *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
|
||||
/*!
|
||||
Returns a custom appcast URL.
|
||||
|
||||
Override this to dynamically specify the entire URL.
|
||||
|
||||
An alternative may be to use SUUpdaterDelegate::feedParametersForUpdater:sendingSystemProfile:
|
||||
and let the server handle what kind of feed to provide.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable NSString *)feedURLStringForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether Sparkle should prompt the user about automatic update checks.
|
||||
|
||||
Use this to override the default behavior.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called after Sparkle has downloaded the appcast from the remote server.
|
||||
|
||||
Implement this if you want to do some special handling with the appcast once it finishes loading.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
|
||||
|
||||
/*!
|
||||
Returns the item in the appcast corresponding to the update that should be installed.
|
||||
|
||||
If you're using special logic or extensions in your appcast,
|
||||
implement this to use your own logic for finding a valid update, if any,
|
||||
in the given appcast.
|
||||
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called when a valid update is found by the update driver.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called when a valid update is not found.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before downloading the specified update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be downloaded.
|
||||
\param request The mutable URL request that will be used to download the update.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
|
||||
|
||||
/*!
|
||||
Called immediately after succesfull download of the specified update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that has been downloaded.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didDownloadUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called after the specified update failed to download.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that failed to download.
|
||||
\param error The error generated by the failed download.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
|
||||
|
||||
/*!
|
||||
Called when the user clicks the cancel button while and update is being downloaded.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)userDidCancelDownload:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before extracting the specified downloaded update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be extracted.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willExtractUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called immediately after extracting the specified downloaded update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that has been extracted.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didExtractUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called immediately before installing the specified update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Returns whether the relaunch should be delayed in order to perform other tasks.
|
||||
|
||||
This is not called if the user didn't relaunch on the previous update,
|
||||
in that case it will immediately restart.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param invocation The invocation that must be completed with `[invocation invoke]` before continuing with the relaunch.
|
||||
|
||||
\return \c YES to delay the relaunch until \p invocation is invoked.
|
||||
*/
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation;
|
||||
|
||||
/*!
|
||||
Returns whether the application should be relaunched at all.
|
||||
|
||||
Some apps \b cannot be relaunched under certain circumstances.
|
||||
This method can be used to explicitly prevent a relaunch.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (BOOL)updaterShouldRelaunchApplication:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before relaunching.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately after relaunching. SUUpdater delegate must be set before applicationDidFinishLaunching: to catch this event.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterDidRelaunchApplication:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns an object that compares version numbers to determine their arithmetic relation to each other.
|
||||
|
||||
This method allows you to provide a custom version comparator.
|
||||
If you don't implement this method or return \c nil,
|
||||
the standard version comparator will be used.
|
||||
|
||||
\sa SUStandardVersionComparator
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns an object that formats version numbers for display to the user.
|
||||
|
||||
If you don't implement this method or return \c nil,
|
||||
the standard version formatter will be used.
|
||||
|
||||
\sa SUUpdateAlert
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable id<SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns the path which is used to relaunch the client after the update is installed.
|
||||
|
||||
The default is the path of the host bundle.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called before an updater shows a modal alert window,
|
||||
to give the host the opportunity to hide attached windows that may get in the way.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterWillShowModalAlert:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called after an updater shows a modal alert window,
|
||||
to give the host the opportunity to hide attached windows that may get in the way.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterDidShowModalAlert:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called when an update is scheduled to be silently installed on quit.
|
||||
This is after an update has been automatically downloaded in the background.
|
||||
(i.e. SUUpdater::automaticallyDownloadsUpdates is YES)
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param invocation Can be used to trigger an immediate silent install and relaunch.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation;
|
||||
|
||||
/*!
|
||||
Calls after an update that was scheduled to be silently installed on quit has been canceled.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that was proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called after an update is aborted due to an error.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param error The error that caused the abort
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// SUVersionComparisonProtocol.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 12/21/07.
|
||||
// Copyright 2007 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUVERSIONCOMPARISONPROTOCOL_H
|
||||
#define SUVERSIONCOMPARISONPROTOCOL_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
Provides version comparison facilities for Sparkle.
|
||||
*/
|
||||
@protocol SUVersionComparison
|
||||
|
||||
/*!
|
||||
An abstract method to compare two version strings.
|
||||
|
||||
Should return NSOrderedAscending if b > a, NSOrderedDescending if b < a,
|
||||
and NSOrderedSame if they are equivalent.
|
||||
*/
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB; // *** MAY BE CALLED ON NON-MAIN THREAD!
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// SUVersionDisplayProtocol.h
|
||||
// EyeTV
|
||||
//
|
||||
// Created by Uli Kusterer on 08.12.09.
|
||||
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import "SUExport.h"
|
||||
|
||||
/*!
|
||||
Applies special display formatting to version numbers.
|
||||
*/
|
||||
@protocol SUVersionDisplay
|
||||
|
||||
/*!
|
||||
Formats two version strings.
|
||||
|
||||
Both versions are provided so that important distinguishing information
|
||||
can be displayed while also leaving out unnecessary/confusing parts.
|
||||
*/
|
||||
- (void)formatVersion:(NSString *_Nonnull*_Nonnull)inOutVersionA andVersion:(NSString *_Nonnull*_Nonnull)inOutVersionB;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Sparkle.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06. (Modified by CDHW on 23/12/07)
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SPARKLE_H
|
||||
#define SPARKLE_H
|
||||
|
||||
// This list should include the shared headers. It doesn't matter if some of them aren't shared (unless
|
||||
// there are name-space collisions) so we can list all of them to start with:
|
||||
|
||||
#import "SUAppcast.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUStandardVersionComparator.h"
|
||||
#import "SUUpdater.h"
|
||||
#import "SUUpdaterDelegate.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SUVersionDisplayProtocol.h"
|
||||
#import "SUErrors.h"
|
||||
|
||||
#import "SPUDownloader.h"
|
||||
#import "SPUDownloaderDelegate.h"
|
||||
#import "SPUDownloaderDeprecated.h"
|
||||
#import "SPUDownloadData.h"
|
||||
#import "SPUDownloaderProtocol.h"
|
||||
#import "SPUDownloaderSession.h"
|
||||
#import "SPUURLRequest.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
framework module Sparkle {
|
||||
umbrella header "Sparkle.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// SUUnarchiver.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SUUnarchiverProtocol;
|
||||
|
||||
@interface SUUnarchiver : NSObject
|
||||
|
||||
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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>BuildMachineOSBuild</key>
|
||||
<string>18A336e</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Autoupdate</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>AppIcon.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.sparkle-project.Sparkle.Autoupdate</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.20.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.20.0</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>10L213o</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>18A336d</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.14</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1000</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>10L213o</string>
|
||||
<key>LSBackgroundOnly</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.7</string>
|
||||
<key>LSUIElement</key>
|
||||
<string>1</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1 @@
|
||||
APPL????
|
||||