Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc66b375d3 | ||
|
|
ce8004641d | ||
|
|
155e48a693 | ||
|
|
76a7d59fe5 | ||
|
|
6a85bea5b5 | ||
|
|
000b825ec9 | ||
|
|
3432e24a55 | ||
|
|
705d0a64b5 | ||
|
|
9f0944b06b | ||
|
|
efc52293a8 | ||
|
|
7b853b5d47 | ||
|
|
439246e85b | ||
|
|
c254ee430d | ||
|
|
cfcda6e46f | ||
|
|
144ff9cf79 | ||
|
|
91a4e5bded | ||
|
|
68dfcddb29 | ||
|
|
82ec231700 | ||
|
|
ed261c2349 | ||
|
|
f06d1f4329 | ||
|
|
3dabd598f4 | ||
|
|
0a09ea7117 | ||
|
|
02cf911336 | ||
|
|
d831069025 | ||
|
|
33206ab457 | ||
|
|
c6c808369f | ||
|
|
cbad06ac07 | ||
|
|
64171d5c51 | ||
|
|
5504e5d640 | ||
|
|
164295820b | ||
|
|
ae469bb92a | ||
|
|
57b5129135 | ||
|
|
7cc72de66f | ||
|
|
2e5db4ffa0 | ||
|
|
8a73fe01e4 | ||
|
|
5fbb2bafc6 | ||
|
|
5b6b6dfa56 | ||
|
|
65e5a52383 | ||
|
|
03304bd030 | ||
|
|
f264425ba7 | ||
|
|
c377b9494c | ||
|
|
f5b36ec012 | ||
|
|
999c4cf6e2 | ||
|
|
b8d5d0a8a5 | ||
|
|
6bb5aade07 | ||
|
|
b6bcc31456 | ||
|
|
9d09646742 | ||
|
|
55f988e393 | ||
|
|
2f4cf9e5f6 | ||
|
|
327d38e47d | ||
|
|
cd380b289d | ||
|
|
6a26b2f5ca | ||
|
|
d7186aac18 | ||
|
|
cef07dc965 | ||
|
|
471c0c5d57 | ||
|
|
5b93525806 | ||
|
|
b87bc632ab | ||
|
|
1763a24942 | ||
|
|
627e6951c1 | ||
|
|
918054df78 | ||
|
|
25fb0d4f04 | ||
|
|
61a357ffc3 | ||
|
|
f4116a95df | ||
|
|
c952505c1c | ||
|
|
f10b58b996 | ||
|
|
88a8ae3ae8 | ||
|
|
d783448567 | ||
|
|
595ae165d3 | ||
|
|
da406713dd | ||
|
|
938b83f37e | ||
|
|
a8a085df1e | ||
|
|
b188f45c8e | ||
|
|
3319c5d45a | ||
|
|
6174d14925 | ||
|
|
c8197239d7 | ||
|
|
d2854e3dae | ||
|
|
4f9c3258ae | ||
|
|
dfeda1e874 | ||
|
|
82f82039ae | ||
|
|
324c3f711e | ||
|
|
a81d6fc595 | ||
|
|
3bde1fe4b1 | ||
|
|
7c9dd26eb0 | ||
|
|
40fa61fcb5 | ||
|
|
5a8117ac7f | ||
|
|
a606767ddc | ||
|
|
6badc37dc3 | ||
|
|
4497c7102c | ||
|
|
b6c6bb945b | ||
|
|
3e399d14c2 | ||
|
|
624c8ac6d8 | ||
|
|
ea68ce33c1 | ||
|
|
744ea067db | ||
|
|
8064ab759c | ||
|
|
556c28df85 | ||
|
|
e68f930efa | ||
|
|
647ac0ba20 | ||
|
|
780a8ba81e | ||
|
|
71f5030fa6 | ||
|
|
f435c0b530 | ||
|
|
e278482807 | ||
|
|
51d246bf7f | ||
|
|
c1cd402241 | ||
|
|
c496156cf2 | ||
|
|
154ea09e98 | ||
|
|
3b493fd5be | ||
|
|
b718b1c9dd | ||
|
|
acc248a579 | ||
|
|
59581ffdc8 | ||
|
|
238b15b6a4 | ||
|
|
732fd5c5b5 | ||
|
|
f4b8e1f39a | ||
|
|
e988951ff9 | ||
|
|
807290ff0c | ||
|
|
0775ea0412 | ||
|
|
1d1d666986 | ||
|
|
560d8ed508 | ||
|
|
06d6f06adf | ||
|
|
0fafe3912e | ||
|
|
319241d4d4 | ||
|
|
61d5e8f77e | ||
|
|
e62530d7ab | ||
|
|
43675027d5 | ||
|
|
b70c040111 | ||
|
|
e795f77ba1 | ||
|
|
37b0462bc1 | ||
|
|
d2d33dee3b | ||
|
|
c0fc40b1c9 | ||
|
|
47a2027443 | ||
|
|
b3c1d6b323 | ||
|
|
a15cc6506f | ||
|
|
35a6ceae07 | ||
|
|
be1c439867 | ||
|
|
9f84b38084 | ||
|
|
86954a7981 | ||
|
|
8554dfeb5e | ||
|
|
bd2cd6d0b7 | ||
|
|
06ecdfe016 | ||
|
|
85d54e4f53 | ||
|
|
b368a21f62 | ||
|
|
644b15ffcd | ||
|
|
b0b10074f8 | ||
|
|
2023ab29f3 | ||
|
|
9a265887cf | ||
|
|
62e87c53f5 | ||
|
|
dbab502d14 | ||
|
|
ae79e8b90e | ||
|
|
d7eddb8484 | ||
|
|
457fa9481e | ||
|
|
69e8e6eefd | ||
|
|
ffc101b455 | ||
|
|
bbe9a1f10e | ||
|
|
71051d7ad0 | ||
|
|
e5136d5991 | ||
|
|
09d9f9618f | ||
|
|
534dbc2284 | ||
|
|
9e0f103ba6 | ||
|
|
c6b6f7bbd5 | ||
|
|
eee4082a1a | ||
|
|
10d94d65e2 | ||
|
|
7de87ad029 | ||
|
|
ad27d26c86 | ||
|
|
ecbd2beb48 | ||
|
|
0aed9a8680 |
@@ -0,0 +1,4 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
patreon: toxblh
|
||||||
|
ko_fi: toxblh
|
||||||
@@ -69,3 +69,5 @@ fastlane/report.xml
|
|||||||
fastlane/Preview.html
|
fastlane/Preview.html
|
||||||
fastlane/screenshots
|
fastlane/screenshots
|
||||||
fastlane/test_output
|
fastlane/test_output
|
||||||
|
|
||||||
|
.vscode
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
language: swift
|
language: swift
|
||||||
xcode_project: MTMR.xcodeproj
|
xcode_project: MTMR.xcodeproj
|
||||||
xcode_scheme: UnitTests
|
xcode_scheme: UnitTests
|
||||||
osx_image: xcode9.3
|
osx_image: xcode10
|
||||||
install: gem install xcpretty
|
install: gem install xcpretty
|
||||||
script: "xcodebuild test -project MTMR.xcodeproj -scheme 'UnitTests' | xcpretty -c && exit ${PIPESTATUS[0]}"
|
script: "xcodebuild test -project MTMR.xcodeproj -scheme 'UnitTests' | xcpretty -c && exit ${PIPESTATUS[0]}"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
36C2ECDD207C723B003CDA33 /* ParseConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36C2ECDC207C723B003CDA33 /* ParseConfigTests.swift */; };
|
36C2ECDD207C723B003CDA33 /* ParseConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36C2ECDC207C723B003CDA33 /* ParseConfigTests.swift */; };
|
||||||
36C2ECDE207C82DE003CDA33 /* ItemsParsing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36C2ECDA207C3FE7003CDA33 /* ItemsParsing.swift */; };
|
36C2ECDE207C82DE003CDA33 /* ItemsParsing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36C2ECDA207C3FE7003CDA33 /* ItemsParsing.swift */; };
|
||||||
36C2ECE0207CB1B0003CDA33 /* defaultPreset.json in Resources */ = {isa = PBXBuildFile; fileRef = 36C2ECDF207CB1B0003CDA33 /* defaultPreset.json */; };
|
36C2ECE0207CB1B0003CDA33 /* defaultPreset.json in Resources */ = {isa = PBXBuildFile; fileRef = 36C2ECDF207CB1B0003CDA33 /* defaultPreset.json */; };
|
||||||
|
4CFF5E5C22E623DD00BFB1EE /* YandexWeatherBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF5E5B22E623DD00BFB1EE /* YandexWeatherBarItem.swift */; };
|
||||||
60173D3E20C0031B002C305F /* LaunchAtLoginController.m in Sources */ = {isa = PBXBuildFile; fileRef = 60173D3D20C0031B002C305F /* LaunchAtLoginController.m */; };
|
60173D3E20C0031B002C305F /* LaunchAtLoginController.m in Sources */ = {isa = PBXBuildFile; fileRef = 60173D3D20C0031B002C305F /* LaunchAtLoginController.m */; };
|
||||||
6027D1B92080E52A004FFDC7 /* BrightnessViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */; };
|
6027D1B92080E52A004FFDC7 /* BrightnessViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */; };
|
||||||
6027D1BA2080E52A004FFDC7 /* VolumeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */; };
|
6027D1BA2080E52A004FFDC7 /* VolumeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */; };
|
||||||
@@ -29,14 +30,24 @@
|
|||||||
60C44AFD20A373A100C0EC91 /* MusicBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */; };
|
60C44AFD20A373A100C0EC91 /* MusicBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */; };
|
||||||
60F7D454208CC31400ABF5D2 /* InputSourceBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */; };
|
60F7D454208CC31400ABF5D2 /* InputSourceBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */; };
|
||||||
B0008E552080286C003AD4DD /* SupportHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0008E542080286C003AD4DD /* SupportHelpers.swift */; };
|
B0008E552080286C003AD4DD /* SupportHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0008E542080286C003AD4DD /* SupportHelpers.swift */; };
|
||||||
|
B002E642216C0E38002774BA /* CoreDisplay.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B002E641216C0E38002774BA /* CoreDisplay.framework */; };
|
||||||
|
B00D181D2152F4A5000806F4 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B00D181C2152F4A5000806F4 /* Sparkle.framework */; };
|
||||||
|
B00D181F2152F521000806F4 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = B00D181C2152F4A5000806F4 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
B04B7BB72087398C00C835D0 /* BatteryBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */; };
|
B04B7BB72087398C00C835D0 /* BatteryBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */; };
|
||||||
B05600D32083E9BB00EB218D /* CustomSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B05600D22083E9BB00EB218D /* CustomSlider.swift */; };
|
B05600D32083E9BB00EB218D /* CustomSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B05600D22083E9BB00EB218D /* CustomSlider.swift */; };
|
||||||
B059D622205E03F5006E6B86 /* TouchBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B059D621205E03F5006E6B86 /* TouchBarController.swift */; };
|
B059D622205E03F5006E6B86 /* TouchBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B059D621205E03F5006E6B86 /* TouchBarController.swift */; };
|
||||||
B059D624205E04F3006E6B86 /* CustomButtonTouchBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B059D623205E04F3006E6B86 /* CustomButtonTouchBarItem.swift */; };
|
B059D624205E04F3006E6B86 /* CustomButtonTouchBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B059D623205E04F3006E6B86 /* CustomButtonTouchBarItem.swift */; };
|
||||||
B059D62D205F11E8006E6B86 /* DFRFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B059D62C205F11E8006E6B86 /* DFRFoundation.framework */; };
|
B059D62D205F11E8006E6B86 /* DFRFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B059D62C205F11E8006E6B86 /* DFRFoundation.framework */; };
|
||||||
|
B0679BC1215AE73F000FC6B4 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = B0679BC0215AE73F000FC6B4 /* dsa_pub.pem */; };
|
||||||
|
B08126EF217BD0B900A98970 /* PomodoroBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B08126EE217BD0B900A98970 /* PomodoroBarItem.swift */; };
|
||||||
|
B08126F1217BE19000A98970 /* WidgetProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B08126F0217BE19000A98970 /* WidgetProtocol.swift */; };
|
||||||
|
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 */; };
|
B082B253205C7D8000BC04DC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B082B252205C7D8000BC04DC /* AppDelegate.swift */; };
|
||||||
B082B257205C7D8000BC04DC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B082B256205C7D8000BC04DC /* Assets.xcassets */; };
|
B082B257205C7D8000BC04DC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B082B256205C7D8000BC04DC /* Assets.xcassets */; };
|
||||||
B082B25A205C7D8000BC04DC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B082B258205C7D8000BC04DC /* Main.storyboard */; };
|
B082B25A205C7D8000BC04DC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B082B258205C7D8000BC04DC /* Main.storyboard */; };
|
||||||
|
B0846A752220C968000288A7 /* NetworkBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0846A742220C968000288A7 /* NetworkBarItem.swift */; };
|
||||||
B09EB1E4207C082000D5C1E0 /* HapticFeedback.swift in Sources */ = {isa = PBXBuildFile; fileRef = B09EB1E3207C082000D5C1E0 /* HapticFeedback.swift */; };
|
B09EB1E4207C082000D5C1E0 /* HapticFeedback.swift in Sources */ = {isa = PBXBuildFile; fileRef = B09EB1E3207C082000D5C1E0 /* HapticFeedback.swift */; };
|
||||||
B09EB1E6207C0F8E00D5C1E0 /* MultitouchSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */; };
|
B09EB1E6207C0F8E00D5C1E0 /* MultitouchSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */; };
|
||||||
B0A7E9AA205D6AA400EEF070 /* KeyPress.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0A7E9A9205D6AA400EEF070 /* KeyPress.swift */; };
|
B0A7E9AA205D6AA400EEF070 /* KeyPress.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0A7E9A9205D6AA400EEF070 /* KeyPress.swift */; };
|
||||||
@@ -51,9 +62,23 @@
|
|||||||
B0B17439207D6B590004B740 /* Vox.nowPlaying.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B0B1742F207D6B590004B740 /* Vox.nowPlaying.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 */; };
|
B0B1743A207D6B590004B740 /* iTunes.nowPlaying.scpt in Resources */ = {isa = PBXBuildFile; fileRef = B0B17430207D6B590004B740 /* iTunes.nowPlaying.scpt */; };
|
||||||
B0F3112520C9E35F0076BB88 /* SupportNSTouchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F3112420C9E35F0076BB88 /* SupportNSTouchBar.swift */; };
|
B0F3112520C9E35F0076BB88 /* SupportNSTouchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F3112420C9E35F0076BB88 /* SupportNSTouchBar.swift */; };
|
||||||
|
B0F54A7A2295AC7D00B4C509 /* DarkModeBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0F54A792295AC7D00B4C509 /* DarkModeBarItem.swift */; };
|
||||||
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */; };
|
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */; };
|
||||||
/* End PBXBuildFile section */
|
/* 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 */
|
/* Begin PBXFileReference section */
|
||||||
36300E85209FD16700B31C71 /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .travis.yml; sourceTree = SOURCE_ROOT; };
|
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>"; };
|
36300E8E20A2CF3400B31C71 /* AppleScriptDefinitionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleScriptDefinitionTests.swift; sourceTree = "<group>"; };
|
||||||
@@ -67,6 +92,7 @@
|
|||||||
36C2ECDA207C3FE7003CDA33 /* ItemsParsing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemsParsing.swift; sourceTree = "<group>"; };
|
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>"; };
|
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>"; };
|
36C2ECDF207CB1B0003CDA33 /* defaultPreset.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = defaultPreset.json; sourceTree = "<group>"; };
|
||||||
|
4CFF5E5B22E623DD00BFB1EE /* YandexWeatherBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YandexWeatherBarItem.swift; sourceTree = "<group>"; };
|
||||||
60173D3C20C0031B002C305F /* LaunchAtLoginController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LaunchAtLoginController.h; 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>"; };
|
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>"; };
|
6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BrightnessViewController.swift; sourceTree = "<group>"; };
|
||||||
@@ -80,6 +106,8 @@
|
|||||||
60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicBarItem.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>"; };
|
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>"; };
|
B0008E542080286C003AD4DD /* SupportHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportHelpers.swift; sourceTree = "<group>"; };
|
||||||
|
B002E641216C0E38002774BA /* CoreDisplay.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreDisplay.framework; path = ../../../../../System/Library/Frameworks/CoreDisplay.framework; sourceTree = "<group>"; };
|
||||||
|
B00D181C2152F4A5000806F4 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
|
||||||
B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BatteryBarItem.swift; sourceTree = "<group>"; };
|
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>"; };
|
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>"; };
|
B059D621205E03F5006E6B86 /* TouchBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchBarController.swift; sourceTree = "<group>"; };
|
||||||
@@ -87,6 +115,13 @@
|
|||||||
B059D629205E13E5006E6B86 /* TouchBarPrivateApi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarPrivateApi.h; sourceTree = "<group>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
||||||
|
B08126EE217BD0B900A98970 /* PomodoroBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PomodoroBarItem.swift; sourceTree = "<group>"; };
|
||||||
|
B08126F0217BE19000A98970 /* WidgetProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetProtocol.swift; 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; };
|
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>"; };
|
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>"; };
|
B082B256205C7D8000BC04DC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
@@ -95,6 +130,7 @@
|
|||||||
B082B25C205C7D8000BC04DC /* MTMR.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MTMR.entitlements; sourceTree = "<group>"; };
|
B082B25C205C7D8000BC04DC /* MTMR.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MTMR.entitlements; sourceTree = "<group>"; };
|
||||||
B082B261205C7D8000BC04DC /* MTMRTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MTMRTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
B082B261205C7D8000BC04DC /* MTMRTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MTMRTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
B082B267205C7D8000BC04DC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
B082B267205C7D8000BC04DC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
B0846A742220C968000288A7 /* NetworkBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkBarItem.swift; sourceTree = "<group>"; };
|
||||||
B09EB1E3207C082000D5C1E0 /* HapticFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticFeedback.swift; sourceTree = "<group>"; };
|
B09EB1E3207C082000D5C1E0 /* HapticFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticFeedback.swift; sourceTree = "<group>"; };
|
||||||
B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MultitouchSupport.framework; path = ../../../../../System/Library/PrivateFrameworks/MultitouchSupport.framework; sourceTree = "<group>"; };
|
B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MultitouchSupport.framework; path = ../../../../../System/Library/PrivateFrameworks/MultitouchSupport.framework; sourceTree = "<group>"; };
|
||||||
B0A7E9A9205D6AA400EEF070 /* KeyPress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyPress.swift; sourceTree = "<group>"; };
|
B0A7E9A9205D6AA400EEF070 /* KeyPress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyPress.swift; sourceTree = "<group>"; };
|
||||||
@@ -109,6 +145,7 @@
|
|||||||
B0B1742F207D6B590004B740 /* Vox.nowPlaying.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Vox.nowPlaying.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>"; };
|
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>"; };
|
B0F3112420C9E35F0076BB88 /* SupportNSTouchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportNSTouchBar.swift; sourceTree = "<group>"; };
|
||||||
|
B0F54A792295AC7D00B4C509 /* DarkModeBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DarkModeBarItem.swift; sourceTree = "<group>"; };
|
||||||
B0F87719207AC1EA00D6E430 /* TouchBarSupport.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TouchBarSupport.m; 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>"; };
|
B0F8771B207AC92700D6E430 /* TouchBarSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarSupport.h; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
@@ -118,8 +155,11 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
B002E642216C0E38002774BA /* CoreDisplay.framework in Frameworks */,
|
||||||
|
B081732A2135F354005D4908 /* CoreBrightness.framework in Frameworks */,
|
||||||
B059D62D205F11E8006E6B86 /* DFRFoundation.framework in Frameworks */,
|
B059D62D205F11E8006E6B86 /* DFRFoundation.framework in Frameworks */,
|
||||||
B09EB1E6207C0F8E00D5C1E0 /* MultitouchSupport.framework in Frameworks */,
|
B09EB1E6207C0F8E00D5C1E0 /* MultitouchSupport.framework in Frameworks */,
|
||||||
|
B00D181D2152F4A5000806F4 /* Sparkle.framework in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -136,6 +176,9 @@
|
|||||||
B059D62B205F11E8006E6B86 /* Frameworks */ = {
|
B059D62B205F11E8006E6B86 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
B002E641216C0E38002774BA /* CoreDisplay.framework */,
|
||||||
|
B00D181C2152F4A5000806F4 /* Sparkle.framework */,
|
||||||
|
B08173292135F354005D4908 /* CoreBrightness.framework */,
|
||||||
B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */,
|
B09EB1E5207C0F8E00D5C1E0 /* MultitouchSupport.framework */,
|
||||||
B059D62C205F11E8006E6B86 /* DFRFoundation.framework */,
|
B059D62C205F11E8006E6B86 /* DFRFoundation.framework */,
|
||||||
);
|
);
|
||||||
@@ -172,6 +215,7 @@
|
|||||||
B082B256205C7D8000BC04DC /* Assets.xcassets */,
|
B082B256205C7D8000BC04DC /* Assets.xcassets */,
|
||||||
B082B258205C7D8000BC04DC /* Main.storyboard */,
|
B082B258205C7D8000BC04DC /* Main.storyboard */,
|
||||||
B082B25B205C7D8000BC04DC /* Info.plist */,
|
B082B25B205C7D8000BC04DC /* Info.plist */,
|
||||||
|
B0679BC0215AE73F000FC6B4 /* dsa_pub.pem */,
|
||||||
B082B25C205C7D8000BC04DC /* MTMR.entitlements */,
|
B082B25C205C7D8000BC04DC /* MTMR.entitlements */,
|
||||||
36C2ECDF207CB1B0003CDA33 /* defaultPreset.json */,
|
36C2ECDF207CB1B0003CDA33 /* defaultPreset.json */,
|
||||||
B082B252205C7D8000BC04DC /* AppDelegate.swift */,
|
B082B252205C7D8000BC04DC /* AppDelegate.swift */,
|
||||||
@@ -230,6 +274,7 @@
|
|||||||
6042B6A92083E27000C525C8 /* DeprecatedCarbonAPI.c */,
|
6042B6A92083E27000C525C8 /* DeprecatedCarbonAPI.c */,
|
||||||
60173D3C20C0031B002C305F /* LaunchAtLoginController.h */,
|
60173D3C20C0031B002C305F /* LaunchAtLoginController.h */,
|
||||||
60173D3D20C0031B002C305F /* LaunchAtLoginController.m */,
|
60173D3D20C0031B002C305F /* LaunchAtLoginController.m */,
|
||||||
|
B08173282135F128005D4908 /* CBBlueLightClient.h */,
|
||||||
);
|
);
|
||||||
path = CBridge;
|
path = CBridge;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -237,16 +282,23 @@
|
|||||||
B0B88A07208CD12000A2C160 /* Widgets */ = {
|
B0B88A07208CD12000A2C160 /* Widgets */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
36C2ECD6207B6DAE003CDA33 /* TimeTouchBarItem.swift */,
|
|
||||||
6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */,
|
|
||||||
6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */,
|
|
||||||
B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */,
|
|
||||||
607EEA4A2087835F009DA5F0 /* WeatherBarItem.swift */,
|
|
||||||
607EEA4C2087A8DA009DA5F0 /* CurrencyBarItem.swift */,
|
|
||||||
6042B6A62083E03A00C525C8 /* AppScrubberTouchBarItem.swift */,
|
6042B6A62083E03A00C525C8 /* AppScrubberTouchBarItem.swift */,
|
||||||
|
B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */,
|
||||||
|
6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */,
|
||||||
|
607EEA4C2087A8DA009DA5F0 /* CurrencyBarItem.swift */,
|
||||||
|
B081732B213739FE005D4908 /* DnDBarItem.swift */,
|
||||||
|
60669B4220AD8FA80074E817 /* GroupBarItem.swift */,
|
||||||
60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */,
|
60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */,
|
||||||
60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */,
|
60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */,
|
||||||
60669B4220AD8FA80074E817 /* GroupBarItem.swift */,
|
B0846A742220C968000288A7 /* NetworkBarItem.swift */,
|
||||||
|
B08173262135F02B005D4908 /* NightShiftBarItem.swift */,
|
||||||
|
B08126EE217BD0B900A98970 /* PomodoroBarItem.swift */,
|
||||||
|
36C2ECD6207B6DAE003CDA33 /* TimeTouchBarItem.swift */,
|
||||||
|
6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */,
|
||||||
|
607EEA4A2087835F009DA5F0 /* WeatherBarItem.swift */,
|
||||||
|
4CFF5E5B22E623DD00BFB1EE /* YandexWeatherBarItem.swift */,
|
||||||
|
B08126F0217BE19000A98970 /* WidgetProtocol.swift */,
|
||||||
|
B0F54A792295AC7D00B4C509 /* DarkModeBarItem.swift */,
|
||||||
);
|
);
|
||||||
path = Widgets;
|
path = Widgets;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -261,6 +313,8 @@
|
|||||||
B082B24B205C7D8000BC04DC /* Sources */,
|
B082B24B205C7D8000BC04DC /* Sources */,
|
||||||
B082B24C205C7D8000BC04DC /* Frameworks */,
|
B082B24C205C7D8000BC04DC /* Frameworks */,
|
||||||
B082B24D205C7D8000BC04DC /* Resources */,
|
B082B24D205C7D8000BC04DC /* Resources */,
|
||||||
|
B00D181E2152F507000806F4 /* CopyFiles */,
|
||||||
|
B0679BBF215AE085000FC6B4 /* ShellScript */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
@@ -295,11 +349,12 @@
|
|||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastSwiftUpdateCheck = 0920;
|
LastSwiftUpdateCheck = 0920;
|
||||||
LastUpgradeCheck = 0930;
|
LastUpgradeCheck = 1010;
|
||||||
ORGANIZATIONNAME = "Anton Palgunov";
|
ORGANIZATIONNAME = "Anton Palgunov";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
B082B24E205C7D8000BC04DC = {
|
B082B24E205C7D8000BC04DC = {
|
||||||
CreatedOnToolsVersion = 9.2;
|
CreatedOnToolsVersion = 9.2;
|
||||||
|
LastSwiftMigration = 1000;
|
||||||
ProvisioningStyle = Manual;
|
ProvisioningStyle = Manual;
|
||||||
SystemCapabilities = {
|
SystemCapabilities = {
|
||||||
com.apple.Sandbox = {
|
com.apple.Sandbox = {
|
||||||
@@ -309,6 +364,7 @@
|
|||||||
};
|
};
|
||||||
B082B260205C7D8000BC04DC = {
|
B082B260205C7D8000BC04DC = {
|
||||||
CreatedOnToolsVersion = 9.2;
|
CreatedOnToolsVersion = 9.2;
|
||||||
|
LastSwiftMigration = 1000;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -343,6 +399,7 @@
|
|||||||
B0B17436207D6B590004B740 /* iTunes.next.scpt in Resources */,
|
B0B17436207D6B590004B740 /* iTunes.next.scpt in Resources */,
|
||||||
B082B25A205C7D8000BC04DC /* Main.storyboard in Resources */,
|
B082B25A205C7D8000BC04DC /* Main.storyboard in Resources */,
|
||||||
B0B17435207D6B590004B740 /* Spotify.next.scpt in Resources */,
|
B0B17435207D6B590004B740 /* Spotify.next.scpt in Resources */,
|
||||||
|
B0679BC1215AE73F000FC6B4 /* dsa_pub.pem in Resources */,
|
||||||
B0B17433207D6B590004B740 /* Finder.scpt in Resources */,
|
B0B17433207D6B590004B740 /* Finder.scpt in Resources */,
|
||||||
B0B17439207D6B590004B740 /* Vox.nowPlaying.scpt in Resources */,
|
B0B17439207D6B590004B740 /* Vox.nowPlaying.scpt in Resources */,
|
||||||
B0B17438207D6B590004B740 /* Vox.next.scpt in Resources */,
|
B0B17438207D6B590004B740 /* Vox.next.scpt in Resources */,
|
||||||
@@ -361,6 +418,26 @@
|
|||||||
};
|
};
|
||||||
/* End PBXResourcesBuildPhase section */
|
/* 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 */
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
B082B24B205C7D8000BC04DC /* Sources */ = {
|
B082B24B205C7D8000BC04DC /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
@@ -369,18 +446,25 @@
|
|||||||
B059D622205E03F5006E6B86 /* TouchBarController.swift in Sources */,
|
B059D622205E03F5006E6B86 /* TouchBarController.swift in Sources */,
|
||||||
B05600D32083E9BB00EB218D /* CustomSlider.swift in Sources */,
|
B05600D32083E9BB00EB218D /* CustomSlider.swift in Sources */,
|
||||||
36C2ECD9207B74B4003CDA33 /* AppleScriptTouchBarItem.swift in Sources */,
|
36C2ECD9207B74B4003CDA33 /* AppleScriptTouchBarItem.swift in Sources */,
|
||||||
|
B0846A752220C968000288A7 /* NetworkBarItem.swift in Sources */,
|
||||||
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */,
|
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */,
|
||||||
|
B08126F1217BE19000A98970 /* WidgetProtocol.swift in Sources */,
|
||||||
B0008E552080286C003AD4DD /* SupportHelpers.swift in Sources */,
|
B0008E552080286C003AD4DD /* SupportHelpers.swift in Sources */,
|
||||||
6042B6A72083E03A00C525C8 /* AppScrubberTouchBarItem.swift in Sources */,
|
6042B6A72083E03A00C525C8 /* AppScrubberTouchBarItem.swift in Sources */,
|
||||||
B082B253205C7D8000BC04DC /* AppDelegate.swift in Sources */,
|
B082B253205C7D8000BC04DC /* AppDelegate.swift in Sources */,
|
||||||
|
B0F54A7A2295AC7D00B4C509 /* DarkModeBarItem.swift in Sources */,
|
||||||
|
B08126EF217BD0B900A98970 /* PomodoroBarItem.swift in Sources */,
|
||||||
|
B081732C213739FE005D4908 /* DnDBarItem.swift in Sources */,
|
||||||
60C44AFD20A373A100C0EC91 /* MusicBarItem.swift in Sources */,
|
60C44AFD20A373A100C0EC91 /* MusicBarItem.swift in Sources */,
|
||||||
B059D624205E04F3006E6B86 /* CustomButtonTouchBarItem.swift in Sources */,
|
B059D624205E04F3006E6B86 /* CustomButtonTouchBarItem.swift in Sources */,
|
||||||
60173D3E20C0031B002C305F /* LaunchAtLoginController.m in Sources */,
|
60173D3E20C0031B002C305F /* LaunchAtLoginController.m in Sources */,
|
||||||
6027D1BA2080E52A004FFDC7 /* VolumeViewController.swift in Sources */,
|
6027D1BA2080E52A004FFDC7 /* VolumeViewController.swift in Sources */,
|
||||||
607EEA4B2087835F009DA5F0 /* WeatherBarItem.swift in Sources */,
|
607EEA4B2087835F009DA5F0 /* WeatherBarItem.swift in Sources */,
|
||||||
B0F3112520C9E35F0076BB88 /* SupportNSTouchBar.swift in Sources */,
|
B0F3112520C9E35F0076BB88 /* SupportNSTouchBar.swift in Sources */,
|
||||||
|
4CFF5E5C22E623DD00BFB1EE /* YandexWeatherBarItem.swift in Sources */,
|
||||||
6042B6AA2083E27000C525C8 /* DeprecatedCarbonAPI.c in Sources */,
|
6042B6AA2083E27000C525C8 /* DeprecatedCarbonAPI.c in Sources */,
|
||||||
B09EB1E4207C082000D5C1E0 /* HapticFeedback.swift in Sources */,
|
B09EB1E4207C082000D5C1E0 /* HapticFeedback.swift in Sources */,
|
||||||
|
B08173272135F02B005D4908 /* NightShiftBarItem.swift in Sources */,
|
||||||
60F7D454208CC31400ABF5D2 /* InputSourceBarItem.swift in Sources */,
|
60F7D454208CC31400ABF5D2 /* InputSourceBarItem.swift in Sources */,
|
||||||
36A778BE20A6C27100B38714 /* GeneralExtensions.swift in Sources */,
|
36A778BE20A6C27100B38714 /* GeneralExtensions.swift in Sources */,
|
||||||
60669B4320AD8FA80074E817 /* GroupBarItem.swift in Sources */,
|
60669B4320AD8FA80074E817 /* GroupBarItem.swift in Sources */,
|
||||||
@@ -538,14 +622,15 @@
|
|||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
|
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
|
||||||
|
"$(PROJECT_DIR)",
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = MTMR/Info.plist;
|
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_BUNDLE_IDENTIFIER = Toxblh.MTMR;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h";
|
||||||
SWIFT_VERSION = 4.0;
|
SWIFT_VERSION = 4.2;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
@@ -553,20 +638,22 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||||
CODE_SIGN_STYLE = Manual;
|
CODE_SIGN_STYLE = Manual;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEVELOPMENT_TEAM = D6D8BR2QNB;
|
DEVELOPMENT_TEAM = D6D8BR2QNB;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
|
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
|
||||||
|
"$(PROJECT_DIR)",
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = MTMR/Info.plist;
|
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_BUNDLE_IDENTIFIER = Toxblh.MTMR;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "MTMR/CBridge/TouchBarPrivateApi-Bridging.h";
|
||||||
SWIFT_VERSION = 4.0;
|
SWIFT_VERSION = 4.2;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
@@ -579,7 +666,7 @@
|
|||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests;
|
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 4.0;
|
SWIFT_VERSION = 4.2;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
@@ -594,7 +681,7 @@
|
|||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests;
|
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMRTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 4.0;
|
SWIFT_VERSION = 4.2;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>BuildSystemType</key>
|
<key>BuildSystemType</key>
|
||||||
<string>Latest</string>
|
<string>Original</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0920"
|
LastUpgradeVersion = "1010"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -26,7 +26,6 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
language = ""
|
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
@@ -56,7 +55,6 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
language = ""
|
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0920"
|
LastUpgradeVersion = "1010"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -10,9 +10,8 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
language = ""
|
codeCoverageEnabled = "YES"
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
codeCoverageEnabled = "YES">
|
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
<TestableReference
|
||||||
skipped = "NO">
|
skipped = "NO">
|
||||||
@@ -32,7 +31,6 @@
|
|||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
language = ""
|
|
||||||
launchStyle = "0"
|
launchStyle = "0"
|
||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
|||||||
@@ -7,30 +7,58 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
import Sparkle
|
||||||
|
|
||||||
@NSApplicationMain
|
@NSApplicationMain
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength)
|
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
|
||||||
|
var isBlockedApp: Bool = false
|
||||||
|
|
||||||
private var fileSystemSource: DispatchSourceFileSystemObject?
|
private var fileSystemSource: DispatchSourceFileSystemObject?
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_: Notification) {
|
||||||
let _ = AXIsProcessTrustedWithOptions([kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true] as NSDictionary)
|
// Configure Sparkle
|
||||||
|
SUUpdater.shared().automaticallyDownloadsUpdates = false
|
||||||
|
SUUpdater.shared().automaticallyChecksForUpdates = true
|
||||||
|
SUUpdater.shared().checkForUpdatesInBackground()
|
||||||
|
|
||||||
|
AXIsProcessTrustedWithOptions([kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true] as NSDictionary)
|
||||||
|
|
||||||
TouchBarController.shared.setupControlStripPresence()
|
TouchBarController.shared.setupControlStripPresence()
|
||||||
|
|
||||||
if let button = statusItem.button {
|
if let button = statusItem.button {
|
||||||
button.image = #imageLiteral(resourceName: "StatusImage")
|
button.image = #imageLiteral(resourceName: "StatusImage")
|
||||||
}
|
}
|
||||||
createMenu()
|
createMenu()
|
||||||
|
|
||||||
reloadOnDefaultConfigChanged()
|
reloadOnDefaultConfigChanged()
|
||||||
|
|
||||||
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(updateIsBlockedApp), name: NSWorkspace.didLaunchApplicationNotification, object: nil)
|
||||||
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(updateIsBlockedApp), name: NSWorkspace.didTerminateApplicationNotification, object: nil)
|
||||||
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(updateIsBlockedApp), name: NSWorkspace.didActivateApplicationNotification, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func applicationWillTerminate(_ aNotification: Notification) {
|
func applicationWillTerminate(_: Notification) {}
|
||||||
|
|
||||||
|
@objc func updateIsBlockedApp() {
|
||||||
|
var blacklistAppIdentifiers: [String] = []
|
||||||
|
if let blackListed = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.blackListedApps") {
|
||||||
|
blacklistAppIdentifiers = blackListed
|
||||||
|
}
|
||||||
|
var frontmostApplicationIdentifier: String? {
|
||||||
|
guard let frontmostId = NSWorkspace.shared.frontmostApplication?.bundleIdentifier else { return nil }
|
||||||
|
return frontmostId
|
||||||
|
}
|
||||||
|
|
||||||
|
if frontmostApplicationIdentifier != nil {
|
||||||
|
isBlockedApp = blacklistAppIdentifiers.index(of: frontmostApplicationIdentifier!) != nil
|
||||||
|
} else {
|
||||||
|
isBlockedApp = false
|
||||||
|
}
|
||||||
|
createMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func openPreferences(_ sender: Any?) {
|
@objc func openPreferences(_: Any?) {
|
||||||
let task = Process()
|
let task = Process()
|
||||||
let appSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR")
|
let appSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR")
|
||||||
let presetPath = appSupportDirectory.appending("/items.json")
|
let presetPath = appSupportDirectory.appending("/items.json")
|
||||||
@@ -38,14 +66,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
task.arguments = [presetPath]
|
task.arguments = [presetPath]
|
||||||
task.launch()
|
task.launch()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleControlStrip(_ sender: Any?) {
|
@objc func toggleControlStrip(_: Any?) {
|
||||||
TouchBarController.shared.controlStripState = !TouchBarController.shared.controlStripState
|
TouchBarController.shared.showControlStripState = !TouchBarController.shared.showControlStripState
|
||||||
createMenu()
|
|
||||||
TouchBarController.shared.resetControlStrip()
|
TouchBarController.shared.resetControlStrip()
|
||||||
|
createMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleBlackListedApp(_ sender: Any?) {
|
@objc func toggleBlackListedApp(_: Any?) {
|
||||||
let appIdentifier = TouchBarController.shared.frontmostApplicationIdentifier
|
let appIdentifier = TouchBarController.shared.frontmostApplicationIdentifier
|
||||||
if appIdentifier != nil {
|
if appIdentifier != nil {
|
||||||
if let index = TouchBarController.shared.blacklistAppIdentifiers.index(of: appIdentifier!) {
|
if let index = TouchBarController.shared.blacklistAppIdentifiers.index(of: appIdentifier!) {
|
||||||
@@ -53,54 +81,60 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
} else {
|
} else {
|
||||||
TouchBarController.shared.blacklistAppIdentifiers.append(appIdentifier!)
|
TouchBarController.shared.blacklistAppIdentifiers.append(appIdentifier!)
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDefaults.standard.set(TouchBarController.shared.blacklistAppIdentifiers, forKey: "com.toxblh.mtmr.blackListedApps")
|
UserDefaults.standard.set(TouchBarController.shared.blacklistAppIdentifiers, forKey: "com.toxblh.mtmr.blackListedApps")
|
||||||
UserDefaults.standard.synchronize()
|
UserDefaults.standard.synchronize()
|
||||||
|
|
||||||
TouchBarController.shared.updateActiveApp()
|
TouchBarController.shared.updateActiveApp()
|
||||||
|
updateIsBlockedApp()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func openPreset(_ sender: Any?) {
|
@objc func openPreset(_: Any?) {
|
||||||
let dialog = NSOpenPanel();
|
let dialog = NSOpenPanel()
|
||||||
|
|
||||||
dialog.title = "Choose a items.json file"
|
dialog.title = "Choose a items.json file"
|
||||||
dialog.showsResizeIndicator = true
|
dialog.showsResizeIndicator = true
|
||||||
dialog.showsHiddenFiles = true
|
dialog.showsHiddenFiles = true
|
||||||
dialog.canChooseDirectories = false
|
dialog.canChooseDirectories = false
|
||||||
dialog.canCreateDirectories = false
|
dialog.canCreateDirectories = false
|
||||||
dialog.allowsMultipleSelection = false
|
dialog.allowsMultipleSelection = false
|
||||||
dialog.allowedFileTypes = ["json"]
|
dialog.allowedFileTypes = ["json"]
|
||||||
dialog.directoryURL = NSURL.fileURL(withPath: NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR"), isDirectory: true)
|
dialog.directoryURL = NSURL.fileURL(withPath: NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR"), isDirectory: true)
|
||||||
|
|
||||||
if dialog.runModal() == .OK, let path = dialog.url?.path {
|
if dialog.runModal() == .OK, let path = dialog.url?.path {
|
||||||
TouchBarController.shared.reloadPreset(path: path)
|
TouchBarController.shared.reloadPreset(path: path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleStartAtLogin(_ sender: Any?) {
|
@objc func toggleStartAtLogin(_: Any?) {
|
||||||
LaunchAtLoginController().setLaunchAtLogin(!LaunchAtLoginController().launchAtLogin, for: NSURL.fileURL(withPath: Bundle.main.bundlePath))
|
LaunchAtLoginController().setLaunchAtLogin(!LaunchAtLoginController().launchAtLogin, for: NSURL.fileURL(withPath: Bundle.main.bundlePath))
|
||||||
createMenu()
|
createMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
func createMenu() {
|
func createMenu() {
|
||||||
let menu = NSMenu()
|
let menu = NSMenu()
|
||||||
|
|
||||||
let startAtLogin = NSMenuItem(title: "Start at login", action: #selector(toggleStartAtLogin(_:)), keyEquivalent: "L")
|
let startAtLogin = NSMenuItem(title: "Start at login", action: #selector(toggleStartAtLogin(_:)), keyEquivalent: "L")
|
||||||
startAtLogin.state = LaunchAtLoginController().launchAtLogin ? .on : .off
|
startAtLogin.state = LaunchAtLoginController().launchAtLogin ? .on : .off
|
||||||
|
|
||||||
|
let toggleBlackList = NSMenuItem(title: "Toggle current app in blacklist", action: #selector(toggleBlackListedApp(_:)), keyEquivalent: "B")
|
||||||
|
toggleBlackList.state = isBlockedApp ? .on : .off
|
||||||
|
|
||||||
let hideControlStrip = NSMenuItem(title: "Hide Control Strip", action: #selector(toggleControlStrip(_:)), keyEquivalent: "T")
|
let hideControlStrip = NSMenuItem(title: "Hide Control Strip", action: #selector(toggleControlStrip(_:)), keyEquivalent: "T")
|
||||||
hideControlStrip.state = TouchBarController.shared.controlStripState ? .on : .off
|
hideControlStrip.state = TouchBarController.shared.showControlStripState ? .off : .on
|
||||||
|
|
||||||
let settingSeparator = NSMenuItem(title: "Settings", action: nil, keyEquivalent: "")
|
let settingSeparator = NSMenuItem(title: "Settings", action: nil, keyEquivalent: "")
|
||||||
settingSeparator.isEnabled = false
|
settingSeparator.isEnabled = false
|
||||||
|
|
||||||
menu.addItem(withTitle: "Preferences", action: #selector(openPreferences(_:)), keyEquivalent: ",")
|
menu.addItem(withTitle: "Preferences", action: #selector(openPreferences(_:)), keyEquivalent: ",")
|
||||||
menu.addItem(withTitle: "Open preset", action: #selector(openPreset(_:)), keyEquivalent: "O")
|
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(NSMenuItem.separator())
|
||||||
menu.addItem(settingSeparator)
|
menu.addItem(settingSeparator)
|
||||||
menu.addItem(hideControlStrip)
|
menu.addItem(hideControlStrip)
|
||||||
menu.addItem(withTitle: "Toggle current app in blacklist" , action: #selector(toggleBlackListedApp(_:)), keyEquivalent: "B")
|
menu.addItem(toggleBlackList)
|
||||||
menu.addItem(startAtLogin)
|
menu.addItem(startAtLogin)
|
||||||
menu.addItem(NSMenuItem.separator())
|
menu.addItem(NSMenuItem.separator())
|
||||||
menu.addItem(withTitle: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
menu.addItem(withTitle: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
||||||
@@ -109,23 +143,22 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
|
|
||||||
func reloadOnDefaultConfigChanged() {
|
func reloadOnDefaultConfigChanged() {
|
||||||
let file = NSURL.fileURL(withPath: standardConfigPath)
|
let file = NSURL.fileURL(withPath: standardConfigPath)
|
||||||
|
|
||||||
let fd = open(file.path, O_EVTONLY)
|
let fd = open(file.path, O_EVTONLY)
|
||||||
|
|
||||||
self.fileSystemSource = DispatchSource.makeFileSystemObjectSource(fileDescriptor: fd, eventMask: .write, queue: DispatchQueue(label: "DefaultConfigChanged"))
|
fileSystemSource = DispatchSource.makeFileSystemObjectSource(fileDescriptor: fd, eventMask: .write, queue: DispatchQueue(label: "DefaultConfigChanged"))
|
||||||
|
|
||||||
self.fileSystemSource?.setEventHandler(handler: {
|
fileSystemSource?.setEventHandler(handler: {
|
||||||
print("Config changed, reloading...")
|
print("Config changed, reloading...")
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
TouchBarController.shared.reloadPreset(path: file.path)
|
TouchBarController.shared.reloadPreset(path: file.path)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.fileSystemSource?.setCancelHandler(handler: {
|
fileSystemSource?.setCancelHandler(handler: {
|
||||||
close(fd)
|
close(fd)
|
||||||
})
|
})
|
||||||
|
|
||||||
self.fileSystemSource?.resume()
|
fileSystemSource?.resume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,18 +4,24 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
|
|||||||
private var script: NSAppleScript!
|
private var script: NSAppleScript!
|
||||||
private let interval: TimeInterval
|
private let interval: TimeInterval
|
||||||
private var forceHideConstraint: NSLayoutConstraint!
|
private var forceHideConstraint: NSLayoutConstraint!
|
||||||
|
|
||||||
init?(identifier: NSTouchBarItem.Identifier, source: SourceProtocol, interval: TimeInterval) {
|
init?(identifier: NSTouchBarItem.Identifier, source: SourceProtocol, interval: TimeInterval) {
|
||||||
self.interval = interval
|
self.interval = interval
|
||||||
super.init(identifier: identifier, title: "⏳")
|
super.init(identifier: identifier, title: "⏳")
|
||||||
self.forceHideConstraint = self.view.widthAnchor.constraint(equalToConstant: 0)
|
forceHideConstraint = view.widthAnchor.constraint(equalToConstant: 0)
|
||||||
guard let script = source.appleScript else {
|
title = "scheduled"
|
||||||
self.title = "no script"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
self.script = script
|
|
||||||
self.isBordered = false
|
|
||||||
DispatchQueue.appleScriptQueue.async {
|
DispatchQueue.appleScriptQueue.async {
|
||||||
|
guard let script = source.appleScript else {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.title = "no script"
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.script = script
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.isBordered = false
|
||||||
|
}
|
||||||
|
|
||||||
var error: NSDictionary?
|
var error: NSDictionary?
|
||||||
guard script.compileAndReturnError(&error) else {
|
guard script.compileAndReturnError(&error) else {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -29,28 +35,28 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
|
|||||||
self.refreshAndSchedule()
|
self.refreshAndSchedule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshAndSchedule() {
|
func refreshAndSchedule() {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
print("refresh happened (interval \(self.interval)), self \(self.identifier.rawValue))")
|
print("refresh happened (interval \(interval)), self \(identifier.rawValue))")
|
||||||
#endif
|
#endif
|
||||||
let scriptResult = self.execute()
|
let scriptResult = execute()
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.title = scriptResult
|
self.title = scriptResult
|
||||||
self.forceHideConstraint.isActive = scriptResult == ""
|
self.forceHideConstraint.isActive = scriptResult == ""
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
print("did set new script result title \(scriptResult)")
|
print("did set new script result title \(scriptResult)")
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
DispatchQueue.appleScriptQueue.asyncAfter(deadline: .now() + self.interval) { [weak self] in
|
DispatchQueue.appleScriptQueue.asyncAfter(deadline: .now() + interval) { [weak self] in
|
||||||
self?.refreshAndSchedule()
|
self?.refreshAndSchedule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func execute() -> String {
|
func execute() -> String {
|
||||||
var error: NSDictionary?
|
var error: NSDictionary?
|
||||||
let output = script.executeAndReturnError(&error)
|
let output = script.executeAndReturnError(&error)
|
||||||
@@ -60,7 +66,6 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
|
|||||||
}
|
}
|
||||||
return output.stringValue ?? ""
|
return output.stringValue ?? ""
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension DispatchQueue {
|
extension DispatchQueue {
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "sun-icon-256.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"template-rendering-intent" : "template"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "39857.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"template-rendering-intent" : "template"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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"?>
|
<?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="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="macosx"/>
|
<deployment identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<scenes>
|
<scenes>
|
||||||
<!--Application-->
|
<!--Application-->
|
||||||
@@ -619,7 +619,7 @@
|
|||||||
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
|
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
|
||||||
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
|
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="toggleSourceList:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
|
<action selector="toggleSidebar:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
|
||||||
</connections>
|
</connections>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
|
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
|
||||||
@@ -676,6 +676,7 @@
|
|||||||
</application>
|
</application>
|
||||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="MTMR" customModuleProvider="target"/>
|
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="MTMR" customModuleProvider="target"/>
|
||||||
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
|
<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"/>
|
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
<point key="canvasLocation" x="75" y="0.0"/>
|
<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
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
#import "TouchBarPrivateApi.h"
|
#import "TouchBarPrivateApi.h"
|
||||||
#import "TouchBarSupport.h"
|
#import "TouchBarSupport.h"
|
||||||
#import "DeprecatedCarbonAPI.h"
|
#import "DeprecatedCarbonAPI.h"
|
||||||
#include "LaunchAtLoginController.h"
|
#import "CBBlueLightClient.h"
|
||||||
|
#import "LaunchAtLoginController.h"
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@@ -19,4 +20,7 @@ CF_EXPORT IOReturn MTActuatorClose(CFTypeRef actuatorRef);
|
|||||||
CF_EXPORT IOReturn MTActuatorActuate(CFTypeRef actuatorRef, SInt32 actuationID, UInt32 arg1, Float32 arg2, Float32 arg3);
|
CF_EXPORT IOReturn MTActuatorActuate(CFTypeRef actuatorRef, SInt32 actuationID, UInt32 arg1, Float32 arg2, Float32 arg3);
|
||||||
CF_EXPORT bool MTActuatorIsOpen(CFTypeRef actuatorRef);
|
CF_EXPORT bool MTActuatorIsOpen(CFTypeRef actuatorRef);
|
||||||
|
|
||||||
|
CF_EXPORT void CoreDisplay_Display_SetUserBrightness(int CGDirectDisplayID, double level);
|
||||||
|
CF_EXPORT double CoreDisplay_Display_GetUserBrightness(int CGDirectDisplayID);
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|||||||
@@ -9,69 +9,70 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
||||||
var tapClosure: (() -> ())?
|
var tapClosure: (() -> Void)?
|
||||||
var longTapClosure: (() -> ())?
|
var longTapClosure: (() -> Void)?
|
||||||
private var button: NSButton!
|
|
||||||
|
|
||||||
private var singleClick: NSClickGestureRecognizer!
|
private let hf: HapticFeedback = HapticFeedback()
|
||||||
|
private var button: NSButton!
|
||||||
|
private var singleClick: HapticClickGestureRecognizer!
|
||||||
private var longClick: NSPressGestureRecognizer!
|
private var longClick: NSPressGestureRecognizer!
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, title: String) {
|
init(identifier: NSTouchBarItem.Identifier, title: String) {
|
||||||
self.attributedTitle = title.defaultTouchbarAttributedString
|
attributedTitle = title.defaultTouchbarAttributedString
|
||||||
|
|
||||||
super.init(identifier: identifier)
|
super.init(identifier: identifier)
|
||||||
button = CustomHeightButton(title: title, target: nil, action: nil)
|
button = CustomHeightButton(title: title, target: nil, action: nil)
|
||||||
|
|
||||||
longClick = NSPressGestureRecognizer(target: self, action: #selector(handleGestureLong))
|
longClick = NSPressGestureRecognizer(target: self, action: #selector(handleGestureLong))
|
||||||
longClick.allowedTouchTypes = .direct
|
longClick.allowedTouchTypes = .direct
|
||||||
longClick.delegate = self
|
longClick.delegate = self
|
||||||
|
|
||||||
singleClick = NSClickGestureRecognizer(target: self, action: #selector(handleGestureSingle))
|
singleClick = HapticClickGestureRecognizer(target: self, action: #selector(handleGestureSingle))
|
||||||
singleClick.allowedTouchTypes = .direct
|
singleClick.allowedTouchTypes = .direct
|
||||||
singleClick.delegate = self
|
singleClick.delegate = self
|
||||||
|
|
||||||
reinstallButton()
|
reinstallButton()
|
||||||
button.attributedTitle = attributedTitle
|
button.attributedTitle = attributedTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
var isBordered: Bool = true {
|
var isBordered: Bool = true {
|
||||||
didSet {
|
didSet {
|
||||||
reinstallButton()
|
reinstallButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var backgroundColor: NSColor? {
|
var backgroundColor: NSColor? {
|
||||||
didSet {
|
didSet {
|
||||||
reinstallButton()
|
reinstallButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var title: String {
|
var title: String {
|
||||||
get {
|
get {
|
||||||
return self.attributedTitle.string
|
return attributedTitle.string
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
self.attributedTitle = newValue.defaultTouchbarAttributedString
|
attributedTitle = newValue.defaultTouchbarAttributedString
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var attributedTitle: NSAttributedString {
|
var attributedTitle: NSAttributedString {
|
||||||
didSet {
|
didSet {
|
||||||
self.button?.imagePosition = attributedTitle.length > 0 ? .imageLeading : .imageOnly
|
button?.imagePosition = attributedTitle.length > 0 ? .imageLeading : .imageOnly
|
||||||
self.button?.attributedTitle = attributedTitle
|
button?.attributedTitle = attributedTitle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var image: NSImage? {
|
var image: NSImage? {
|
||||||
didSet {
|
didSet {
|
||||||
button.image = image
|
button.image = image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func reinstallButton() {
|
private func reinstallButton() {
|
||||||
let title = button.attributedTitle
|
let title = button.attributedTitle
|
||||||
let image = button.image
|
let image = button.image
|
||||||
@@ -88,12 +89,12 @@ class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegat
|
|||||||
button.imageScaling = .scaleProportionallyDown
|
button.imageScaling = .scaleProportionallyDown
|
||||||
button.imageHugsTitle = true
|
button.imageHugsTitle = true
|
||||||
button.attributedTitle = title
|
button.attributedTitle = title
|
||||||
self.button?.imagePosition = title.length > 0 ? .imageLeading : .imageOnly
|
button?.imagePosition = title.length > 0 ? .imageLeading : .imageOnly
|
||||||
button.image = image
|
button.image = image
|
||||||
self.view = button
|
view = button
|
||||||
|
|
||||||
self.view.addGestureRecognizer(longClick)
|
view.addGestureRecognizer(longClick)
|
||||||
self.view.addGestureRecognizer(singleClick)
|
view.addGestureRecognizer(singleClick)
|
||||||
}
|
}
|
||||||
|
|
||||||
func gestureRecognizer(_ gestureRecognizer: NSGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: NSGestureRecognizer) -> Bool {
|
func gestureRecognizer(_ gestureRecognizer: NSGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: NSGestureRecognizer) -> Bool {
|
||||||
@@ -102,21 +103,18 @@ class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegat
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func handleGestureSingle(gr: NSClickGestureRecognizer) {
|
@objc func handleGestureSingle(gr: NSClickGestureRecognizer) {
|
||||||
let hf: HapticFeedback = HapticFeedback()
|
|
||||||
switch gr.state {
|
switch gr.state {
|
||||||
case .ended:
|
case .ended:
|
||||||
hf.tap(strong: 2)
|
tapClosure?()
|
||||||
self.tapClosure?()
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func handleGestureLong(gr: NSPressGestureRecognizer) {
|
@objc func handleGestureLong(gr: NSPressGestureRecognizer) {
|
||||||
let hf: HapticFeedback = HapticFeedback()
|
|
||||||
switch gr.state {
|
switch gr.state {
|
||||||
case .began:
|
case .began:
|
||||||
if let closure = self.longTapClosure {
|
if let closure = self.longTapClosure {
|
||||||
@@ -130,57 +128,66 @@ class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegat
|
|||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomHeightButton : NSButton {
|
class CustomHeightButton: NSButton {
|
||||||
|
|
||||||
override var intrinsicContentSize: NSSize {
|
override var intrinsicContentSize: NSSize {
|
||||||
var size = super.intrinsicContentSize
|
var size = super.intrinsicContentSize
|
||||||
size.height = 30
|
size.height = 30
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomButtonCell: NSButtonCell {
|
class CustomButtonCell: NSButtonCell {
|
||||||
weak var parentItem: CustomButtonTouchBarItem?
|
weak var parentItem: CustomButtonTouchBarItem?
|
||||||
|
|
||||||
init(parentItem: CustomButtonTouchBarItem) {
|
init(parentItem: CustomButtonTouchBarItem) {
|
||||||
super.init(textCell: "")
|
super.init(textCell: "")
|
||||||
self.parentItem = parentItem
|
self.parentItem = parentItem
|
||||||
}
|
}
|
||||||
|
|
||||||
override func highlight(_ flag: Bool, withFrame cellFrame: NSRect, in controlView: NSView) {
|
override func highlight(_ flag: Bool, withFrame cellFrame: NSRect, in controlView: NSView) {
|
||||||
super.highlight(flag, withFrame: cellFrame, in: controlView)
|
super.highlight(flag, withFrame: cellFrame, in: controlView)
|
||||||
if !self.isBordered {
|
if !isBordered {
|
||||||
if flag {
|
if flag {
|
||||||
self.setAttributedTitle(self.attributedTitle, withColor: .lightGray)
|
setAttributedTitle(attributedTitle, withColor: .lightGray)
|
||||||
} else if let parentItem = self.parentItem {
|
} else if let parentItem = self.parentItem {
|
||||||
self.attributedTitle = parentItem.attributedTitle
|
attributedTitle = parentItem.attributedTitle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required init(coder: NSCoder) {
|
required init(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func setAttributedTitle(_ title: NSAttributedString, withColor color: NSColor) {
|
func setAttributedTitle(_ title: NSAttributedString, withColor color: NSColor) {
|
||||||
let attrTitle = NSMutableAttributedString(attributedString: title)
|
let attrTitle = NSMutableAttributedString(attributedString: title)
|
||||||
attrTitle.addAttributes([.foregroundColor: color], range: NSRange(location: 0, length: attrTitle.length))
|
attrTitle.addAttributes([.foregroundColor: color], range: NSRange(location: 0, length: attrTitle.length))
|
||||||
self.attributedTitle = attrTitle
|
attributedTitle = attrTitle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class HapticClickGestureRecognizer: NSClickGestureRecognizer {
|
||||||
|
let hf: HapticFeedback = HapticFeedback()
|
||||||
|
|
||||||
|
override func touchesBegan(with event: NSEvent) {
|
||||||
|
hf.tap(strong: 2)
|
||||||
|
super.touchesBegan(with: event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func touchesEnded(with event: NSEvent) {
|
||||||
|
hf.tap(strong: 1)
|
||||||
|
super.touchesEnded(with: event)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
var defaultTouchbarAttributedString: NSAttributedString {
|
var defaultTouchbarAttributedString: NSAttributedString {
|
||||||
let attrTitle = NSMutableAttributedString(string: self, attributes: [.foregroundColor: NSColor.white, .font: NSFont.systemFont(ofSize: 15, weight: .regular), .baselineOffset: 1])
|
let attrTitle = NSMutableAttributedString(string: self, attributes: [.foregroundColor: NSColor.white, .font: NSFont.systemFont(ofSize: 15, weight: .regular), .baselineOffset: 1])
|
||||||
attrTitle.setAlignment(.center, range: NSRange(location: 0, length: self.count))
|
attrTitle.setAlignment(.center, range: NSRange(location: 0, length: count))
|
||||||
return attrTitle
|
return attrTitle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,34 +9,34 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
class CustomSliderCell: NSSliderCell {
|
class CustomSliderCell: NSSliderCell {
|
||||||
var knobImage:NSImage!
|
var knobImage: NSImage!
|
||||||
private var _currentKnobRect:NSRect!
|
private var _currentKnobRect: NSRect!
|
||||||
private var _barRect:NSRect!
|
private var _barRect: NSRect!
|
||||||
|
|
||||||
required init(coder aDecoder: NSCoder) {
|
required init(coder aDecoder: NSCoder) {
|
||||||
super.init(coder: aDecoder)
|
super.init(coder: aDecoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
init(knob:NSImage?) {
|
init(knob: NSImage?) {
|
||||||
knobImage = knob;
|
knobImage = knob
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func drawKnob(_ knobRect: NSRect) {
|
override func drawKnob(_ knobRect: NSRect) {
|
||||||
if (knobImage == nil) {
|
if knobImage == nil {
|
||||||
super.drawKnob(knobRect)
|
super.drawKnob(knobRect)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentKnobRect = knobRect;
|
_currentKnobRect = knobRect
|
||||||
drawBar(inside: _barRect, flipped: true)
|
drawBar(inside: _barRect, flipped: true)
|
||||||
|
|
||||||
let x = (knobRect.origin.x * (_barRect.size.width - (knobImage.size.width - knobRect.size.width)) / _barRect.size.width)+1;
|
let x = (knobRect.origin.x * (_barRect.size.width - (knobImage.size.width - knobRect.size.width)) / _barRect.size.width) + 1
|
||||||
let y = knobRect.origin.y+3
|
let y = knobRect.origin.y + 3
|
||||||
|
|
||||||
knobImage.draw(
|
knobImage.draw(
|
||||||
at: NSPoint(x: x, y: y),
|
at: NSPoint(x: x, y: y),
|
||||||
@@ -45,63 +45,62 @@ class CustomSliderCell: NSSliderCell {
|
|||||||
fraction: 1
|
fraction: 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func drawBar(inside aRect: NSRect, flipped: Bool) {
|
override func drawBar(inside aRect: NSRect, flipped _: Bool) {
|
||||||
_barRect = aRect
|
_barRect = aRect
|
||||||
|
|
||||||
let barRadius = CGFloat(2)
|
let barRadius = CGFloat(2)
|
||||||
|
|
||||||
var bgRect = aRect
|
var bgRect = aRect
|
||||||
bgRect.size.height = CGFloat(4)
|
bgRect.size.height = CGFloat(4)
|
||||||
|
|
||||||
let bg = NSBezierPath(roundedRect: bgRect, xRadius: barRadius, yRadius: barRadius)
|
let bg = NSBezierPath(roundedRect: bgRect, xRadius: barRadius, yRadius: barRadius)
|
||||||
NSColor.lightGray.setFill()
|
NSColor.lightGray.setFill()
|
||||||
bg.fill()
|
bg.fill()
|
||||||
|
|
||||||
var activeRect = bgRect
|
var activeRect = bgRect
|
||||||
|
|
||||||
activeRect.size.width = CGFloat((Double(bgRect.size.width) / (self.maxValue - self.minValue)) * self.doubleValue)
|
activeRect.size.width = CGFloat((Double(bgRect.size.width) / (maxValue - minValue)) * doubleValue)
|
||||||
let active = NSBezierPath(roundedRect: activeRect, xRadius: barRadius, yRadius: barRadius)
|
let active = NSBezierPath(roundedRect: activeRect, xRadius: barRadius, yRadius: barRadius)
|
||||||
NSColor.darkGray.setFill()
|
NSColor.darkGray.setFill()
|
||||||
active.fill()
|
active.fill()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomSlider:NSSlider {
|
class CustomSlider: NSSlider {
|
||||||
|
var currentValue: CGFloat = 0
|
||||||
var currentValue:CGFloat = 0
|
|
||||||
|
|
||||||
override func setNeedsDisplay(_ invalidRect: NSRect) {
|
override func setNeedsDisplay(_ invalidRect: NSRect) {
|
||||||
super.setNeedsDisplay(invalidRect)
|
super.setNeedsDisplay(invalidRect)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
super.awakeFromNib()
|
super.awakeFromNib()
|
||||||
if ((self.cell?.isKind(of: CustomSliderCell.self)) == false) {
|
if (cell?.isKind(of: CustomSliderCell.self)) == false {
|
||||||
let cell:CustomSliderCell = CustomSliderCell()
|
let cell: CustomSliderCell = CustomSliderCell()
|
||||||
self.cell = cell
|
self.cell = cell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
convenience init(knob:NSImage) {
|
convenience init(knob: NSImage) {
|
||||||
self.init()
|
self.init()
|
||||||
self.cell = CustomSliderCell(knob: knob)
|
cell = CustomSliderCell(knob: knob)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
super.init(coder: coder)
|
super.init(coder: coder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override init(frame frameRect: NSRect) {
|
override init(frame frameRect: NSRect) {
|
||||||
super.init(frame: frameRect)
|
super.init(frame: frameRect)
|
||||||
}
|
}
|
||||||
|
|
||||||
func knobImage() -> NSImage {
|
func knobImage() -> NSImage {
|
||||||
let cell = self.cell as! CustomSliderCell
|
let cell = self.cell as! CustomSliderCell
|
||||||
return cell.knobImage
|
return cell.knobImage
|
||||||
}
|
}
|
||||||
|
|
||||||
func setKnobImage(image:NSImage) {
|
func setKnobImage(image: NSImage) {
|
||||||
let cell = self.cell as! CustomSliderCell
|
let cell = self.cell as! CustomSliderCell
|
||||||
cell.knobImage = image
|
cell.knobImage = image
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ import Foundation
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
|
|
||||||
var ifNotEmpty: String? {
|
var ifNotEmpty: String? {
|
||||||
return self.count > 0 ? self : nil
|
return count > 0 ? self : nil
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,28 @@
|
|||||||
import IOKit
|
import IOKit
|
||||||
|
|
||||||
class HapticFeedback {
|
class HapticFeedback {
|
||||||
private var actuatorRef: CFTypeRef?
|
private var correctDeviceId: UInt64?
|
||||||
private var deviceID: UInt64 = 0x200000001000000
|
|
||||||
private var error: IOReturn = 0
|
// Here we have list of possible IDs for Haptic Generator Device. They are not constant
|
||||||
|
// To find deviceID, you will need IORegistryExplorer app from Additional Tools for Xcode dmg
|
||||||
|
// which you can download from https://developer.apple.com/download/more/?=Additional%20Tools
|
||||||
|
// Open IORegistryExplorer app, search for AppleMultitouchDevice and get "Multitouch ID"
|
||||||
|
// There should be programmatic way to get it but I can't find, no docs for macOS :(
|
||||||
|
private let possibleDeviceIDs: [UInt64] = [
|
||||||
|
0x200_0000_0100_0000, // MacBook Pro 2016/2017
|
||||||
|
0x300000080500000 // MacBook Pro 2019 (possibly 2018 as well)
|
||||||
|
]
|
||||||
|
|
||||||
|
init() {
|
||||||
|
// Let's find our Haptic device
|
||||||
|
possibleDeviceIDs.forEach {(deviceID) in
|
||||||
|
guard correctDeviceId == nil else {return}
|
||||||
|
let actuatorRef: CFTypeRef? = MTActuatorCreateFromDeviceID(deviceID).takeRetainedValue()
|
||||||
|
if actuatorRef != nil {
|
||||||
|
correctDeviceId = deviceID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Don't know how to do strong is enum one of
|
// Don't know how to do strong is enum one of
|
||||||
// 1 like back Click
|
// 1 like back Click
|
||||||
@@ -24,34 +43,37 @@ class HapticFeedback {
|
|||||||
// 16 nothing
|
// 16 nothing
|
||||||
// you can get a plist `otool -s __TEXT __tpad_act_plist /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/Current/MultitouchSupport|tail -n +3|awk -F'\t' '{print $2}'|xxd -r -p`
|
// you can get a plist `otool -s __TEXT __tpad_act_plist /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/Current/MultitouchSupport|tail -n +3|awk -F'\t' '{print $2}'|xxd -r -p`
|
||||||
|
|
||||||
func tap(strong:Int32) -> Void {
|
func tap(strong: Int32) {
|
||||||
actuatorRef = MTActuatorCreateFromDeviceID(deviceID).takeRetainedValue()
|
guard correctDeviceId != nil else {
|
||||||
|
print("guard correctDeviceId == nil (no haptic device found?)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let actuatorRef: CFTypeRef? = MTActuatorCreateFromDeviceID(correctDeviceId!).takeRetainedValue()
|
||||||
|
|
||||||
guard actuatorRef != nil else {
|
guard actuatorRef != nil else {
|
||||||
print("guard actuatorRef == nil")
|
print("guard actuatorRef == nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
error = MTActuatorOpen(actuatorRef!)
|
var result: IOReturn
|
||||||
guard error == kIOReturnSuccess else {
|
|
||||||
|
result = MTActuatorOpen(actuatorRef!)
|
||||||
|
guard result == kIOReturnSuccess else {
|
||||||
print("guard MTActuatorOpen")
|
print("guard MTActuatorOpen")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
error = MTActuatorActuate(actuatorRef!, strong, 0, 0.0, 0.0)
|
result = MTActuatorActuate(actuatorRef!, strong, 0, 0.0, 0.0)
|
||||||
guard error == kIOReturnSuccess else {
|
guard result == kIOReturnSuccess else {
|
||||||
print("guard MTActuatorActuate")
|
print("guard MTActuatorActuate")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
error = MTActuatorClose(actuatorRef!)
|
result = MTActuatorClose(actuatorRef!)
|
||||||
guard error == kIOReturnSuccess else {
|
guard result == kIOReturnSuccess else {
|
||||||
print("guard MTActuatorClose")
|
print("guard MTActuatorClose")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,15 +17,31 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>0.16.2</string>
|
<string>0.21.1</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1</string>
|
<string>254</string>
|
||||||
|
<key>LSApplicationCategoryType</key>
|
||||||
|
<string>public.app-category.utilities</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||||
<key>LSUIElement</key>
|
<key>LSUIElement</key>
|
||||||
<true/>
|
<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>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2018 Anton Palgunov. All rights reserved.</string>
|
<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>
|
<key>NSLocationAlwaysUsageDescription</key>
|
||||||
<string>Weather widget need your location for correct work</string>
|
<string>Weather widget need your location for correct work</string>
|
||||||
<key>NSLocationUsageDescription</key>
|
<key>NSLocationUsageDescription</key>
|
||||||
@@ -34,7 +50,19 @@
|
|||||||
<string>Weather widget need your location for correct work</string>
|
<string>Weather widget need your location for correct work</string>
|
||||||
<key>NSMainStoryboardFile</key>
|
<key>NSMainStoryboardFile</key>
|
||||||
<string>Main</string>
|
<string>Main</string>
|
||||||
|
<key>NSPhotoLibraryUsageDescription</key>
|
||||||
|
<string>MTMR needs access to Photo for work</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
<string>NSApplication</string>
|
<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>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import Foundation
|
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import Foundation
|
||||||
|
|
||||||
extension Data {
|
extension Data {
|
||||||
func barItemDefinitions() -> [BarItemDefinition]? {
|
func barItemDefinitions() -> [BarItemDefinition]? {
|
||||||
return try? JSONDecoder().decode([BarItemDefinition].self, from: self.utf8string!.stripComments().data(using: .utf8)!)
|
return try? JSONDecoder().decode([BarItemDefinition].self, from: utf8string!.stripComments().data(using: .utf8)!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,24 +12,24 @@ struct BarItemDefinition: Decodable {
|
|||||||
let action: ActionType
|
let action: ActionType
|
||||||
let longAction: LongActionType
|
let longAction: LongActionType
|
||||||
let additionalParameters: [GeneralParameters.CodingKeys: GeneralParameter]
|
let additionalParameters: [GeneralParameters.CodingKeys: GeneralParameter]
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case type
|
case type
|
||||||
}
|
}
|
||||||
|
|
||||||
init(type: ItemType, action: ActionType, longAction: LongActionType, additionalParameters: [GeneralParameters.CodingKeys:GeneralParameter]) {
|
init(type: ItemType, action: ActionType, longAction: LongActionType, additionalParameters: [GeneralParameters.CodingKeys: GeneralParameter]) {
|
||||||
self.type = type
|
self.type = type
|
||||||
self.action = action
|
self.action = action
|
||||||
self.longAction = longAction
|
self.longAction = longAction
|
||||||
self.additionalParameters = additionalParameters
|
self.additionalParameters = additionalParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
init(from decoder: Decoder) throws {
|
init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
let type = try container.decode(String.self, forKey: .type)
|
let type = try container.decode(String.self, forKey: .type)
|
||||||
let parametersDecoder = SupportedTypesHolder.sharedInstance.lookup(by: type)
|
let parametersDecoder = SupportedTypesHolder.sharedInstance.lookup(by: type)
|
||||||
var additionalParameters = try GeneralParameters(from: decoder).parameters
|
var additionalParameters = try GeneralParameters(from: decoder).parameters
|
||||||
|
|
||||||
if let result = try? parametersDecoder(decoder),
|
if let result = try? parametersDecoder(decoder),
|
||||||
case let (itemType, action, longAction, parameters) = result {
|
case let (itemType, action, longAction, parameters) = result {
|
||||||
parameters.forEach { additionalParameters[$0] = $1 }
|
parameters.forEach { additionalParameters[$0] = $1 }
|
||||||
@@ -38,58 +38,133 @@ struct BarItemDefinition: Decodable {
|
|||||||
self.init(type: .staticButton(title: "unknown"), action: .none, longAction: .none, additionalParameters: additionalParameters)
|
self.init(type: .staticButton(title: "unknown"), action: .none, longAction: .none, additionalParameters: additionalParameters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typealias ParametersDecoder = (Decoder) throws -> (
|
||||||
|
item: ItemType,
|
||||||
|
action: ActionType,
|
||||||
|
longAction: LongActionType,
|
||||||
|
parameters: [GeneralParameters.CodingKeys: GeneralParameter]
|
||||||
|
)
|
||||||
|
|
||||||
class SupportedTypesHolder {
|
class SupportedTypesHolder {
|
||||||
typealias ParametersDecoder = (Decoder) throws ->(item: ItemType, action: ActionType, longAction: LongActionType, parameters: [GeneralParameters.CodingKeys: GeneralParameter])
|
|
||||||
private var supportedTypes: [String: ParametersDecoder] = [
|
private var supportedTypes: [String: ParametersDecoder] = [
|
||||||
"escape": { _ in return (item: .staticButton(title: "esc"), action: .keyPress(keycode: 53), longAction: .none, parameters: [.align: .align(.left)]) },
|
"escape": { _ in (
|
||||||
|
item: .staticButton(title: "esc"),
|
||||||
"delete": { _ in return (item: .staticButton(title: "del"), action: .keyPress(keycode: 117), longAction: .none, parameters: [:])},
|
action: .keyPress(keycode: 53),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.align: .align(.left)]
|
||||||
|
) },
|
||||||
|
|
||||||
|
"delete": { _ in (
|
||||||
|
item: .staticButton(title: "del"),
|
||||||
|
action: .keyPress(keycode: 117),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [:]
|
||||||
|
) },
|
||||||
|
|
||||||
"brightnessUp": { _ in
|
"brightnessUp": { _ in
|
||||||
let imageParameter = GeneralParameter.image(source: #imageLiteral(resourceName: "brightnessUp"))
|
let imageParameter = GeneralParameter.image(source: #imageLiteral(resourceName: "brightnessUp"))
|
||||||
return (item: .staticButton(title: ""), action: .keyPress(keycode: 144), longAction: .none, parameters: [.image: imageParameter])
|
return (
|
||||||
|
item: .staticButton(title: ""),
|
||||||
|
action: .keyPress(keycode: 144),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.image: imageParameter]
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
"brightnessDown": { _ in
|
"brightnessDown": { _ in
|
||||||
let imageParameter = GeneralParameter.image(source: #imageLiteral(resourceName: "brightnessDown"))
|
let imageParameter = GeneralParameter.image(source: #imageLiteral(resourceName: "brightnessDown"))
|
||||||
return (item: .staticButton(title: ""), action: .keyPress(keycode: 145), longAction: .none, parameters: [.image: imageParameter])
|
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
|
"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])
|
return (
|
||||||
|
item: .staticButton(title: ""),
|
||||||
|
action: .hidKey(keycode: NX_KEYTYPE_SOUND_DOWN),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.image: imageParameter]
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
"volumeUp": { _ in
|
"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])
|
return (
|
||||||
|
item: .staticButton(title: ""),
|
||||||
|
action: .hidKey(keycode: NX_KEYTYPE_SOUND_UP),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.image: imageParameter]
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
"mute": { _ in
|
"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])
|
return (
|
||||||
|
item: .staticButton(title: ""),
|
||||||
|
action: .hidKey(keycode: NX_KEYTYPE_MUTE),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.image: imageParameter]
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
"previous": { _ in
|
"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])
|
return (
|
||||||
|
item: .staticButton(title: ""),
|
||||||
|
action: .hidKey(keycode: NX_KEYTYPE_PREVIOUS),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.image: imageParameter]
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
"play": { _ in
|
"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])
|
return (
|
||||||
|
item: .staticButton(title: ""),
|
||||||
|
action: .hidKey(keycode: NX_KEYTYPE_PLAY),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.image: imageParameter]
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
"next": { _ in
|
"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])
|
return (
|
||||||
|
item: .staticButton(title: ""),
|
||||||
|
action: .hidKey(keycode: NX_KEYTYPE_NEXT),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.image: imageParameter]
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
"weather": { decoder in
|
"weather": { decoder in
|
||||||
enum CodingKeys: String, CodingKey { case refreshInterval; case units; case api_key ; case icon_type }
|
enum CodingKeys: String, CodingKey { case refreshInterval; case units; case api_key; case icon_type }
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval)
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval)
|
||||||
let units = try container.decodeIfPresent(String.self, forKey: .units)
|
let units = try container.decodeIfPresent(String.self, forKey: .units)
|
||||||
@@ -97,65 +172,134 @@ class SupportedTypesHolder {
|
|||||||
let icon_type = try container.decodeIfPresent(String.self, forKey: .icon_type)
|
let icon_type = try container.decodeIfPresent(String.self, forKey: .icon_type)
|
||||||
let action = try ActionType(from: decoder)
|
let action = try ActionType(from: decoder)
|
||||||
let longAction = try LongActionType(from: decoder)
|
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: [:])
|
return (
|
||||||
|
item: .weather(interval: interval ?? 1800.00, units: units ?? "metric", api_key: api_key ?? "32c4256d09a4c52b38aecddba7a078f6", icon_type: icon_type ?? "text"),
|
||||||
|
action,
|
||||||
|
longAction,
|
||||||
|
parameters: [:]
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"yandexWeather": { decoder in
|
||||||
|
enum CodingKeys: String, CodingKey { case refreshInterval }
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval)
|
||||||
|
let action = try ActionType(from: decoder)
|
||||||
|
let longAction = try LongActionType(from: decoder)
|
||||||
|
return (
|
||||||
|
item: .yandexWeather(interval: interval ?? 1800.00),
|
||||||
|
action,
|
||||||
|
longAction,
|
||||||
|
parameters: [:]
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
"currency": { decoder in
|
"currency": { decoder in
|
||||||
enum CodingKeys: String, CodingKey { case refreshInterval; case from; case to }
|
enum CodingKeys: String, CodingKey { case refreshInterval; case from; case to; case full }
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval)
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval)
|
||||||
let from = try container.decodeIfPresent(String.self, forKey: .from)
|
let from = try container.decodeIfPresent(String.self, forKey: .from)
|
||||||
let to = try container.decodeIfPresent(String.self, forKey: .to)
|
let to = try container.decodeIfPresent(String.self, forKey: .to)
|
||||||
|
let full = try container.decodeIfPresent(Bool.self, forKey: .full)
|
||||||
let action = try ActionType(from: decoder)
|
let action = try ActionType(from: decoder)
|
||||||
let longAction = try LongActionType(from: decoder)
|
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)
|
|
||||||
if var img = try container.decodeIfPresent(Source.self, forKey: .image) {
|
|
||||||
return (item: .volume(), action: .none, longAction: .none, parameters: [.image: .image(source: img)])
|
|
||||||
} else {
|
|
||||||
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)
|
|
||||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval)
|
|
||||||
if var img = try container.decodeIfPresent(Source.self, forKey: .image) {
|
|
||||||
return (item: .brightness(refreshInterval: interval ?? 0.5), action: .none, longAction: .none, parameters: [.image: .image(source: img)])
|
|
||||||
} else {
|
|
||||||
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)
|
|
||||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval)
|
|
||||||
return (
|
return (
|
||||||
item: .music(interval: interval ?? 1800.00),
|
item: .currency(interval: interval ?? 600.00, from: from ?? "RUB", to: to ?? "USD", full: full ?? false),
|
||||||
|
action,
|
||||||
|
longAction,
|
||||||
|
parameters: [:]
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
"dock": { decoder in
|
||||||
|
enum CodingKeys: String, CodingKey { case autoResize }
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
let autoResize = try container.decodeIfPresent(Bool.self, forKey: .autoResize) ?? false
|
||||||
|
return (
|
||||||
|
item: .dock(autoResize: autoResize),
|
||||||
action: .none,
|
action: .none,
|
||||||
longAction: .none,
|
longAction: .none,
|
||||||
parameters: [:]
|
parameters: [:]
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"inputsource": { _ in
|
||||||
|
(
|
||||||
|
item: .inputsource(),
|
||||||
|
action: .none,
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [:]
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
"volume": { decoder in
|
||||||
|
enum CodingKeys: String, CodingKey { case image }
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
if var img = try container.decodeIfPresent(Source.self, forKey: .image) {
|
||||||
|
return (
|
||||||
|
item: .volume(),
|
||||||
|
action: .none,
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.image: .image(source: img)]
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
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)
|
||||||
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval)
|
||||||
|
if var img = try container.decodeIfPresent(Source.self, forKey: .image) {
|
||||||
|
return (
|
||||||
|
item: .brightness(refreshInterval: interval ?? 0.5),
|
||||||
|
action: .none,
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [.image: .image(source: img)]
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
item: .brightness(refreshInterval: interval ?? 0.5),
|
||||||
|
action: .none,
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [:]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"sleep": { _ in (
|
||||||
|
item: .staticButton(title: "☕️"),
|
||||||
|
action: .shellScript(executable: "/usr/bin/pmset", parameters: ["sleepnow"]),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [:]
|
||||||
|
) },
|
||||||
|
|
||||||
|
"displaySleep": { _ in (
|
||||||
|
item: .staticButton(title: "☕️"),
|
||||||
|
action: .shellScript(executable: "/usr/bin/pmset", parameters: ["displaysleepnow"]),
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [:]
|
||||||
|
) },
|
||||||
|
|
||||||
|
"music": { decoder in
|
||||||
|
enum CodingKeys: String, CodingKey { case refreshInterval; case disableMarquee }
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval)
|
||||||
|
let disableMarquee = try container.decodeIfPresent(Bool.self, forKey: .disableMarquee)
|
||||||
|
return (
|
||||||
|
item: .music(interval: interval ?? 5.0, disableMarquee: disableMarquee ?? false),
|
||||||
|
action: .none,
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [:]
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
"group": { decoder in
|
"group": { decoder in
|
||||||
enum CodingKeys: CodingKey { case items }
|
enum CodingKeys: CodingKey { case items }
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
@@ -167,23 +311,31 @@ class SupportedTypesHolder {
|
|||||||
parameters: [:]
|
parameters: [:]
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
static let sharedInstance = SupportedTypesHolder()
|
static let sharedInstance = SupportedTypesHolder()
|
||||||
|
|
||||||
func lookup(by type: String) -> ParametersDecoder {
|
func lookup(by type: String) -> ParametersDecoder {
|
||||||
return supportedTypes[type] ?? { decoder in
|
return supportedTypes[type] ?? { decoder in (
|
||||||
return (item: try ItemType(from: decoder), action: try ActionType(from: decoder), longAction: try LongActionType(from: decoder), parameters: [:])
|
item: try ItemType(from: decoder),
|
||||||
}
|
action: try ActionType(from: decoder),
|
||||||
|
longAction: try LongActionType(from: decoder),
|
||||||
|
parameters: [:]
|
||||||
|
) }
|
||||||
}
|
}
|
||||||
|
|
||||||
func register(typename: String, decoder: @escaping ParametersDecoder) {
|
func register(typename: String, decoder: @escaping ParametersDecoder) {
|
||||||
supportedTypes[typename] = decoder
|
supportedTypes[typename] = decoder
|
||||||
}
|
}
|
||||||
|
|
||||||
func register(typename: String, item: ItemType, action: ActionType, longAction: LongActionType) {
|
func register(typename: String, item: ItemType, action: ActionType, longAction: LongActionType) {
|
||||||
register(typename: typename) { _ in
|
register(typename: typename) { _ in
|
||||||
return (item: item, action: action, longAction: longAction, parameters: [:])
|
(
|
||||||
|
item: item,
|
||||||
|
action,
|
||||||
|
longAction,
|
||||||
|
parameters: [:]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,17 +343,23 @@ class SupportedTypesHolder {
|
|||||||
enum ItemType: Decodable {
|
enum ItemType: Decodable {
|
||||||
case staticButton(title: String)
|
case staticButton(title: String)
|
||||||
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
|
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
|
||||||
case timeButton(formatTemplate: String)
|
case timeButton(formatTemplate: String, timeZone: String?)
|
||||||
case battery()
|
case battery()
|
||||||
case dock()
|
case dock(autoResize: Bool)
|
||||||
case volume()
|
case volume()
|
||||||
case brightness(refreshInterval: Double)
|
case brightness(refreshInterval: Double)
|
||||||
case weather(interval: Double, units: String, api_key: String, icon_type: String)
|
case weather(interval: Double, units: String, api_key: String, icon_type: String)
|
||||||
case currency(interval: Double, from: String, to: String)
|
case yandexWeather(interval: Double)
|
||||||
|
case currency(interval: Double, from: String, to: String, full: Bool)
|
||||||
case inputsource()
|
case inputsource()
|
||||||
case music(interval: Double)
|
case music(interval: Double, disableMarquee: Bool)
|
||||||
case groupBar(items: [BarItemDefinition])
|
case groupBar(items: [BarItemDefinition])
|
||||||
|
case nightShift()
|
||||||
|
case dnd()
|
||||||
|
case pomodoro(workTime: Double, restTime: Double)
|
||||||
|
case network(flip: Bool)
|
||||||
|
case darkMode()
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case type
|
case type
|
||||||
case title
|
case title
|
||||||
@@ -209,6 +367,8 @@ enum ItemType: Decodable {
|
|||||||
case refreshInterval
|
case refreshInterval
|
||||||
case from
|
case from
|
||||||
case to
|
case to
|
||||||
|
case full
|
||||||
|
case timeZone
|
||||||
case units
|
case units
|
||||||
case api_key
|
case api_key
|
||||||
case icon_type
|
case icon_type
|
||||||
@@ -217,8 +377,13 @@ enum ItemType: Decodable {
|
|||||||
case url
|
case url
|
||||||
case longUrl
|
case longUrl
|
||||||
case items
|
case items
|
||||||
|
case workTime
|
||||||
|
case restTime
|
||||||
|
case flip
|
||||||
|
case autoResize
|
||||||
|
case disableMarquee
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ItemTypeRaw: String, Decodable {
|
enum ItemTypeRaw: String, Decodable {
|
||||||
case staticButton
|
case staticButton
|
||||||
case appleScriptTitledButton
|
case appleScriptTitledButton
|
||||||
@@ -228,43 +393,50 @@ enum ItemType: Decodable {
|
|||||||
case volume
|
case volume
|
||||||
case brightness
|
case brightness
|
||||||
case weather
|
case weather
|
||||||
|
case yandexWeather
|
||||||
case currency
|
case currency
|
||||||
case inputsource
|
case inputsource
|
||||||
case music
|
case music
|
||||||
case groupBar
|
case groupBar
|
||||||
|
case nightShift
|
||||||
|
case dnd
|
||||||
|
case pomodoro
|
||||||
|
case network
|
||||||
|
case darkMode
|
||||||
}
|
}
|
||||||
|
|
||||||
init(from decoder: Decoder) throws {
|
init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
let type = try container.decode(ItemTypeRaw.self, forKey: .type)
|
let type = try container.decode(ItemTypeRaw.self, forKey: .type)
|
||||||
switch type {
|
switch type {
|
||||||
|
|
||||||
case .appleScriptTitledButton:
|
case .appleScriptTitledButton:
|
||||||
let source = try container.decode(Source.self, forKey: .source)
|
let source = try container.decode(Source.self, forKey: .source)
|
||||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||||
self = .appleScriptTitledButton(source: source, refreshInterval: interval)
|
self = .appleScriptTitledButton(source: source, refreshInterval: interval)
|
||||||
|
|
||||||
case .staticButton:
|
case .staticButton:
|
||||||
let title = try container.decode(String.self, forKey: .title)
|
let title = try container.decode(String.self, forKey: .title)
|
||||||
self = .staticButton(title: title)
|
self = .staticButton(title: title)
|
||||||
|
|
||||||
case .timeButton:
|
case .timeButton:
|
||||||
let template = try container.decodeIfPresent(String.self, forKey: .formatTemplate) ?? "HH:mm"
|
let template = try container.decodeIfPresent(String.self, forKey: .formatTemplate) ?? "HH:mm"
|
||||||
self = .timeButton(formatTemplate: template)
|
let timeZone = try container.decodeIfPresent(String.self, forKey: .timeZone) ?? nil
|
||||||
|
self = .timeButton(formatTemplate: template, timeZone: timeZone)
|
||||||
|
|
||||||
case .battery:
|
case .battery:
|
||||||
self = .battery()
|
self = .battery()
|
||||||
|
|
||||||
case .dock:
|
case .dock:
|
||||||
self = .dock()
|
let autoResize = try container.decodeIfPresent(Bool.self, forKey: .autoResize) ?? false
|
||||||
|
self = .dock(autoResize: autoResize)
|
||||||
|
|
||||||
case .volume:
|
case .volume:
|
||||||
self = .volume()
|
self = .volume()
|
||||||
|
|
||||||
case .brightness:
|
case .brightness:
|
||||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 0.5
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 0.5
|
||||||
self = .brightness(refreshInterval: interval)
|
self = .brightness(refreshInterval: interval)
|
||||||
|
|
||||||
case .weather:
|
case .weather:
|
||||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||||
let units = try container.decodeIfPresent(String.self, forKey: .units) ?? "metric"
|
let units = try container.decodeIfPresent(String.self, forKey: .units) ?? "metric"
|
||||||
@@ -272,22 +444,46 @@ enum ItemType: Decodable {
|
|||||||
let icon_type = try container.decodeIfPresent(String.self, forKey: .icon_type) ?? "text"
|
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)
|
self = .weather(interval: interval, units: units, api_key: api_key, icon_type: icon_type)
|
||||||
|
|
||||||
|
case .yandexWeather:
|
||||||
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||||
|
self = .yandexWeather(interval: interval)
|
||||||
|
|
||||||
case .currency:
|
case .currency:
|
||||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 600.0
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 600.0
|
||||||
let from = try container.decodeIfPresent(String.self, forKey: .from) ?? "RUB"
|
let from = try container.decodeIfPresent(String.self, forKey: .from) ?? "RUB"
|
||||||
let to = try container.decodeIfPresent(String.self, forKey: .to) ?? "USD"
|
let to = try container.decodeIfPresent(String.self, forKey: .to) ?? "USD"
|
||||||
self = .currency(interval: interval, from: from, to: to)
|
let full = try container.decodeIfPresent(Bool.self, forKey: .full) ?? false
|
||||||
|
self = .currency(interval: interval, from: from, to: to, full: full)
|
||||||
|
|
||||||
case .inputsource:
|
case .inputsource:
|
||||||
self = .inputsource()
|
self = .inputsource()
|
||||||
|
|
||||||
case .music:
|
case .music:
|
||||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 5.0
|
||||||
self = .music(interval: interval)
|
let disableMarquee = try container.decodeIfPresent(Bool.self, forKey: .disableMarquee) ?? false
|
||||||
|
self = .music(interval: interval, disableMarquee: disableMarquee)
|
||||||
|
|
||||||
case .groupBar:
|
case .groupBar:
|
||||||
let items = try container.decode([BarItemDefinition].self, forKey: .items)
|
let items = try container.decode([BarItemDefinition].self, forKey: .items)
|
||||||
self = .groupBar(items: items)
|
self = .groupBar(items: items)
|
||||||
|
|
||||||
|
case .nightShift:
|
||||||
|
self = .nightShift()
|
||||||
|
|
||||||
|
case .dnd:
|
||||||
|
self = .dnd()
|
||||||
|
|
||||||
|
case .pomodoro:
|
||||||
|
let workTime = try container.decodeIfPresent(Double.self, forKey: .workTime) ?? 1500.0
|
||||||
|
let restTime = try container.decodeIfPresent(Double.self, forKey: .restTime) ?? 600.0
|
||||||
|
self = .pomodoro(workTime: workTime, restTime: restTime)
|
||||||
|
|
||||||
|
case .network:
|
||||||
|
let flip = try container.decodeIfPresent(Bool.self, forKey: .flip) ?? false
|
||||||
|
self = .network(flip: flip)
|
||||||
|
|
||||||
|
case .darkMode:
|
||||||
|
self = .darkMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,9 +494,9 @@ enum ActionType: Decodable {
|
|||||||
case keyPress(keycode: Int)
|
case keyPress(keycode: Int)
|
||||||
case appleScript(source: SourceProtocol)
|
case appleScript(source: SourceProtocol)
|
||||||
case shellScript(executable: String, parameters: [String])
|
case shellScript(executable: String, parameters: [String])
|
||||||
case custom(closure: ()->())
|
case custom(closure: () -> Void)
|
||||||
case openUrl(url: String)
|
case openUrl(url: String)
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case action
|
case action
|
||||||
case keycode
|
case keycode
|
||||||
@@ -309,7 +505,7 @@ enum ActionType: Decodable {
|
|||||||
case shellArguments
|
case shellArguments
|
||||||
case url
|
case url
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ActionTypeRaw: String, Decodable {
|
private enum ActionTypeRaw: String, Decodable {
|
||||||
case hidKey
|
case hidKey
|
||||||
case keyPress
|
case keyPress
|
||||||
@@ -317,49 +513,48 @@ enum ActionType: Decodable {
|
|||||||
case shellScript
|
case shellScript
|
||||||
case openUrl
|
case openUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
init(from decoder: Decoder) throws {
|
init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
let type = try container.decodeIfPresent(ActionTypeRaw.self, forKey: .action)
|
let type = try container.decodeIfPresent(ActionTypeRaw.self, forKey: .action)
|
||||||
|
|
||||||
switch type {
|
switch type {
|
||||||
case .some(.hidKey):
|
case .some(.hidKey):
|
||||||
let keycode = try container.decode(Int32.self, forKey: .keycode)
|
let keycode = try container.decode(Int32.self, forKey: .keycode)
|
||||||
self = .hidKey(keycode: keycode)
|
self = .hidKey(keycode: keycode)
|
||||||
|
|
||||||
case .some(.keyPress):
|
case .some(.keyPress):
|
||||||
let keycode = try container.decode(Int.self, forKey: .keycode)
|
let keycode = try container.decode(Int.self, forKey: .keycode)
|
||||||
self = .keyPress(keycode: keycode)
|
self = .keyPress(keycode: keycode)
|
||||||
|
|
||||||
case .some(.appleScript):
|
case .some(.appleScript):
|
||||||
let source = try container.decode(Source.self, forKey: .actionAppleScript)
|
let source = try container.decode(Source.self, forKey: .actionAppleScript)
|
||||||
self = .appleScript(source: source)
|
self = .appleScript(source: source)
|
||||||
|
|
||||||
case .some(.shellScript):
|
case .some(.shellScript):
|
||||||
let executable = try container.decode(String.self, forKey: .executablePath)
|
let executable = try container.decode(String.self, forKey: .executablePath)
|
||||||
let parameters = try container.decodeIfPresent([String].self, forKey: .shellArguments) ?? []
|
let parameters = try container.decodeIfPresent([String].self, forKey: .shellArguments) ?? []
|
||||||
self = .shellScript(executable: executable, parameters: parameters)
|
self = .shellScript(executable: executable, parameters: parameters)
|
||||||
|
|
||||||
case .some(.openUrl):
|
case .some(.openUrl):
|
||||||
let url = try container.decode(String.self, forKey: .url)
|
let url = try container.decode(String.self, forKey: .url)
|
||||||
self = .openUrl(url: url)
|
self = .openUrl(url: url)
|
||||||
|
|
||||||
case .none:
|
case .none:
|
||||||
self = .none
|
self = .none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum LongActionType: Decodable {
|
enum LongActionType: Decodable {
|
||||||
case none
|
case none
|
||||||
case hidKey(keycode: Int32)
|
case hidKey(keycode: Int32)
|
||||||
case keyPress(keycode: Int)
|
case keyPress(keycode: Int)
|
||||||
case appleScript(source: SourceProtocol)
|
case appleScript(source: SourceProtocol)
|
||||||
case shellScript(executable: String, parameters: [String])
|
case shellScript(executable: String, parameters: [String])
|
||||||
case custom(closure: ()->())
|
case custom(closure: () -> Void)
|
||||||
case openUrl(url: String)
|
case openUrl(url: String)
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case longAction
|
case longAction
|
||||||
case longKeycode
|
case longKeycode
|
||||||
@@ -368,7 +563,7 @@ enum LongActionType: Decodable {
|
|||||||
case longShellArguments
|
case longShellArguments
|
||||||
case longUrl
|
case longUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum LongActionTypeRaw: String, Decodable {
|
private enum LongActionTypeRaw: String, Decodable {
|
||||||
case hidKey
|
case hidKey
|
||||||
case keyPress
|
case keyPress
|
||||||
@@ -376,52 +571,51 @@ enum LongActionType: Decodable {
|
|||||||
case shellScript
|
case shellScript
|
||||||
case openUrl
|
case openUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
init(from decoder: Decoder) throws {
|
init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
let longType = try container.decodeIfPresent(LongActionTypeRaw.self, forKey: .longAction)
|
let longType = try container.decodeIfPresent(LongActionTypeRaw.self, forKey: .longAction)
|
||||||
|
|
||||||
switch longType {
|
switch longType {
|
||||||
case .some(.hidKey):
|
case .some(.hidKey):
|
||||||
let keycode = try container.decode(Int32.self, forKey: .longKeycode)
|
let keycode = try container.decode(Int32.self, forKey: .longKeycode)
|
||||||
self = .hidKey(keycode: keycode)
|
self = .hidKey(keycode: keycode)
|
||||||
|
|
||||||
case .some(.keyPress):
|
case .some(.keyPress):
|
||||||
let keycode = try container.decode(Int.self, forKey: .longKeycode)
|
let keycode = try container.decode(Int.self, forKey: .longKeycode)
|
||||||
self = .keyPress(keycode: keycode)
|
self = .keyPress(keycode: keycode)
|
||||||
|
|
||||||
case .some(.appleScript):
|
case .some(.appleScript):
|
||||||
let source = try container.decode(Source.self, forKey: .longActionAppleScript)
|
let source = try container.decode(Source.self, forKey: .longActionAppleScript)
|
||||||
self = .appleScript(source: source)
|
self = .appleScript(source: source)
|
||||||
|
|
||||||
case .some(.shellScript):
|
case .some(.shellScript):
|
||||||
let executable = try container.decode(String.self, forKey: .longExecutablePath)
|
let executable = try container.decode(String.self, forKey: .longExecutablePath)
|
||||||
let parameters = try container.decodeIfPresent([String].self, forKey: .longShellArguments) ?? []
|
let parameters = try container.decodeIfPresent([String].self, forKey: .longShellArguments) ?? []
|
||||||
self = .shellScript(executable: executable, parameters: parameters)
|
self = .shellScript(executable: executable, parameters: parameters)
|
||||||
|
|
||||||
case .some(.openUrl):
|
case .some(.openUrl):
|
||||||
let longUrl = try container.decode(String.self, forKey: .longUrl)
|
let longUrl = try container.decode(String.self, forKey: .longUrl)
|
||||||
self = .openUrl(url: longUrl)
|
self = .openUrl(url: longUrl)
|
||||||
|
|
||||||
case .none:
|
case .none:
|
||||||
self = .none
|
self = .none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum GeneralParameter {
|
enum GeneralParameter {
|
||||||
case width(_: CGFloat)
|
case width(_: CGFloat)
|
||||||
case image(source: SourceProtocol)
|
case image(source: SourceProtocol)
|
||||||
case align(_: Align)
|
case align(_: Align)
|
||||||
case bordered(_: Bool)
|
case bordered(_: Bool)
|
||||||
case background(_:NSColor)
|
case background(_: NSColor)
|
||||||
case title(_:String)
|
case title(_: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GeneralParameters: Decodable {
|
struct GeneralParameters: Decodable {
|
||||||
let parameters: [GeneralParameters.CodingKeys: GeneralParameter]
|
let parameters: [GeneralParameters.CodingKeys: GeneralParameter]
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case width
|
case width
|
||||||
case image
|
case image
|
||||||
@@ -430,34 +624,34 @@ struct GeneralParameters: Decodable {
|
|||||||
case background
|
case background
|
||||||
case title
|
case title
|
||||||
}
|
}
|
||||||
|
|
||||||
init(from decoder: Decoder) throws {
|
init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
var result: [GeneralParameters.CodingKeys: GeneralParameter] = [:]
|
var result: [GeneralParameters.CodingKeys: GeneralParameter] = [:]
|
||||||
|
|
||||||
if let value = try container.decodeIfPresent(CGFloat.self, forKey: .width) {
|
if let value = try container.decodeIfPresent(CGFloat.self, forKey: .width) {
|
||||||
result[.width] = .width(value)
|
result[.width] = .width(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let imageSource = try container.decodeIfPresent(Source.self, forKey: .image) {
|
if let imageSource = try container.decodeIfPresent(Source.self, forKey: .image) {
|
||||||
result[.image] = .image(source: imageSource)
|
result[.image] = .image(source: imageSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
let align = try container.decodeIfPresent(Align.self, forKey: .align) ?? .center
|
let align = try container.decodeIfPresent(Align.self, forKey: .align) ?? .center
|
||||||
result[.align] = .align(align)
|
result[.align] = .align(align)
|
||||||
|
|
||||||
if let borderedFlag = try container.decodeIfPresent(Bool.self, forKey: .bordered) {
|
if let borderedFlag = try container.decodeIfPresent(Bool.self, forKey: .bordered) {
|
||||||
result[.bordered] = .bordered(borderedFlag)
|
result[.bordered] = .bordered(borderedFlag)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let backgroundColor = try container.decodeIfPresent(String.self, forKey: .background)?.hexColor {
|
if let backgroundColor = try container.decodeIfPresent(String.self, forKey: .background)?.hexColor {
|
||||||
result[.background] = .background(backgroundColor)
|
result[.background] = .background(backgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let title = try container.decodeIfPresent(String.self, forKey: .title) {
|
if let title = try container.decodeIfPresent(String.self, forKey: .title) {
|
||||||
result[.title] = .title(title)
|
result[.title] = .title(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters = result
|
parameters = result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -473,35 +667,35 @@ struct Source: Decodable, SourceProtocol {
|
|||||||
let filePath: String?
|
let filePath: String?
|
||||||
let base64: String?
|
let base64: String?
|
||||||
let inline: String?
|
let inline: String?
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case filePath
|
case filePath
|
||||||
case base64
|
case base64
|
||||||
case inline
|
case inline
|
||||||
}
|
}
|
||||||
|
|
||||||
var data: Data? {
|
var data: Data? {
|
||||||
return base64?.base64Data ?? inline?.data(using: .utf8) ?? filePath?.fileData
|
return base64?.base64Data ?? inline?.data(using: .utf8) ?? filePath?.fileData
|
||||||
}
|
}
|
||||||
|
|
||||||
var string: String? {
|
var string: String? {
|
||||||
return inline ?? filePath?.fileString
|
return inline ?? filePath?.fileString
|
||||||
}
|
}
|
||||||
|
|
||||||
var image: NSImage? {
|
var image: NSImage? {
|
||||||
return data?.image
|
return data?.image
|
||||||
}
|
}
|
||||||
|
|
||||||
var appleScript: NSAppleScript? {
|
var appleScript: NSAppleScript? {
|
||||||
return filePath?.fileURL.appleScript ?? self.string?.appleScript
|
return filePath?.fileURL.appleScript ?? string?.appleScript
|
||||||
}
|
}
|
||||||
|
|
||||||
private init(filePath: String?, base64: String?, inline: String?) {
|
private init(filePath: String?, base64: String?, inline: String?) {
|
||||||
self.filePath = filePath
|
self.filePath = filePath
|
||||||
self.base64 = base64
|
self.base64 = base64
|
||||||
self.inline = inline
|
self.inline = inline
|
||||||
}
|
}
|
||||||
|
|
||||||
init(filePath: String) {
|
init(filePath: String) {
|
||||||
self.init(filePath: filePath, base64: nil, inline: nil)
|
self.init(filePath: filePath, base64: nil, inline: nil)
|
||||||
}
|
}
|
||||||
@@ -511,15 +705,15 @@ extension NSImage: SourceProtocol {
|
|||||||
var data: Data? {
|
var data: Data? {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var string: String? {
|
var string: String? {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var image: NSImage? {
|
var image: NSImage? {
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
var appleScript: NSAppleScript? {
|
var appleScript: NSAppleScript? {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -529,23 +723,22 @@ extension String {
|
|||||||
var base64Data: Data? {
|
var base64Data: Data? {
|
||||||
return Data(base64Encoded: self)
|
return Data(base64Encoded: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileData: Data? {
|
var fileData: Data? {
|
||||||
return try? Data(contentsOf: URL(fileURLWithPath: self))
|
return try? Data(contentsOf: URL(fileURLWithPath: self))
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileString: String? {
|
var fileString: String? {
|
||||||
var encoding: String.Encoding = .utf8
|
var encoding: String.Encoding = .utf8
|
||||||
return try? String(contentsOfFile: self, usedEncoding: &encoding)
|
return try? String(contentsOfFile: self, usedEncoding: &encoding)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Data {
|
extension Data {
|
||||||
var utf8string: String? {
|
var utf8string: String? {
|
||||||
return String(data: self, encoding: .utf8)
|
return String(data: self, encoding: .utf8)
|
||||||
}
|
}
|
||||||
|
|
||||||
var image: NSImage? {
|
var image: NSImage? {
|
||||||
return NSImage(data: self)?.resize(maxSize: NSSize(width: 24, height: 24))
|
return NSImage(data: self)?.resize(maxSize: NSSize(width: 24, height: 24))
|
||||||
}
|
}
|
||||||
@@ -561,7 +754,7 @@ extension String {
|
|||||||
var fileURL: URL {
|
var fileURL: URL {
|
||||||
return URL(fileURLWithPath: self)
|
return URL(fileURLWithPath: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
var appleScript: NSAppleScript? {
|
var appleScript: NSAppleScript? {
|
||||||
return NSAppleScript(source: self)
|
return NSAppleScript(source: self)
|
||||||
}
|
}
|
||||||
@@ -569,7 +762,7 @@ extension String {
|
|||||||
|
|
||||||
extension URL {
|
extension URL {
|
||||||
var appleScript: NSAppleScript? {
|
var appleScript: NSAppleScript? {
|
||||||
guard FileManager.default.fileExists(atPath: self.path) else { return nil }
|
guard FileManager.default.fileExists(atPath: path) else { return nil }
|
||||||
return NSAppleScript(contentsOf: self, error: nil)
|
return NSAppleScript(contentsOf: self, error: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ struct GenericKeyPress: KeyPress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension KeyPress {
|
extension KeyPress {
|
||||||
func send () {
|
func send() {
|
||||||
let src = CGEventSource(stateID: .hidSystemState)
|
let src = CGEventSource(stateID: .hidSystemState)
|
||||||
let keyDown = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: true)
|
let keyDown = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: true)
|
||||||
let keyUp = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: false)
|
let keyUp = CGEvent(keyboardEventSource: src, virtualKey: keyCode, keyDown: false)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Foundation
|
|||||||
class ScrollViewItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
class ScrollViewItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
||||||
var twofingersPrev: CGFloat = 0.0
|
var twofingersPrev: CGFloat = 0.0
|
||||||
var threefingersPrev: CGFloat = 0.0
|
var threefingersPrev: CGFloat = 0.0
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, items: [NSTouchBarItem]) {
|
init(identifier: NSTouchBarItem.Identifier, items: [NSTouchBarItem]) {
|
||||||
super.init(identifier: identifier)
|
super.init(identifier: identifier)
|
||||||
let views = items.compactMap { $0.view }
|
let views = items.compactMap { $0.view }
|
||||||
@@ -12,31 +12,31 @@ class ScrollViewItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
|||||||
stackView.orientation = .horizontal
|
stackView.orientation = .horizontal
|
||||||
let scrollView = NSScrollView(frame: CGRect(origin: .zero, size: stackView.fittingSize))
|
let scrollView = NSScrollView(frame: CGRect(origin: .zero, size: stackView.fittingSize))
|
||||||
scrollView.documentView = stackView
|
scrollView.documentView = stackView
|
||||||
self.view = scrollView
|
view = scrollView
|
||||||
|
|
||||||
let twofingers = NSPanGestureRecognizer(target: self, action: #selector(twofingersHandler(_:)))
|
let twofingers = NSPanGestureRecognizer(target: self, action: #selector(twofingersHandler(_:)))
|
||||||
twofingers.allowedTouchTypes = .direct
|
twofingers.allowedTouchTypes = .direct
|
||||||
twofingers.numberOfTouchesRequired = 2
|
twofingers.numberOfTouchesRequired = 2
|
||||||
self.view.addGestureRecognizer(twofingers)
|
view.addGestureRecognizer(twofingers)
|
||||||
|
|
||||||
let threefingers = NSPanGestureRecognizer(target: self, action: #selector(threefingersHandler(_:)))
|
let threefingers = NSPanGestureRecognizer(target: self, action: #selector(threefingersHandler(_:)))
|
||||||
threefingers.allowedTouchTypes = .direct
|
threefingers.allowedTouchTypes = .direct
|
||||||
threefingers.numberOfTouchesRequired = 3
|
threefingers.numberOfTouchesRequired = 3
|
||||||
self.view.addGestureRecognizer(threefingers)
|
view.addGestureRecognizer(threefingers)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func twofingersHandler(_ sender: NSGestureRecognizer?) { // Volume
|
@objc func twofingersHandler(_ sender: NSGestureRecognizer?) { // Volume
|
||||||
let position = (sender?.location(in: sender?.view).x)!
|
let position = (sender?.location(in: sender?.view).x)!
|
||||||
|
|
||||||
switch sender!.state {
|
switch sender!.state {
|
||||||
case .began:
|
case .began:
|
||||||
twofingersPrev = position
|
twofingersPrev = position
|
||||||
case .changed:
|
case .changed:
|
||||||
if (((position-twofingersPrev) > 10) || ((twofingersPrev-position) > 10)) {
|
if ((position - twofingersPrev) > 10) || ((twofingersPrev - position) > 10) {
|
||||||
if position > twofingersPrev {
|
if position > twofingersPrev {
|
||||||
HIDPostAuxKey(NX_KEYTYPE_SOUND_UP)
|
HIDPostAuxKey(NX_KEYTYPE_SOUND_UP)
|
||||||
} else if position < twofingersPrev {
|
} else if position < twofingersPrev {
|
||||||
@@ -50,15 +50,15 @@ class ScrollViewItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func threefingersHandler(_ sender: NSGestureRecognizer?) { // Brightness
|
@objc func threefingersHandler(_ sender: NSGestureRecognizer?) { // Brightness
|
||||||
let position = (sender?.location(in: sender?.view).x)!
|
let position = (sender?.location(in: sender?.view).x)!
|
||||||
|
|
||||||
switch sender!.state {
|
switch sender!.state {
|
||||||
case .began:
|
case .began:
|
||||||
threefingersPrev = position
|
threefingersPrev = position
|
||||||
case .changed:
|
case .changed:
|
||||||
if (((position-threefingersPrev) > 15) || ((threefingersPrev-position) > 15)) {
|
if ((position - threefingersPrev) > 15) || ((threefingersPrev - position) > 15) {
|
||||||
if position > threefingersPrev {
|
if position > threefingersPrev {
|
||||||
GenericKeyPress(keyCode: CGKeyCode(144)).send()
|
GenericKeyPress(keyCode: CGKeyCode(144)).send()
|
||||||
} else if position < threefingersPrev {
|
} else if position < threefingersPrev {
|
||||||
|
|||||||
@@ -6,19 +6,19 @@
|
|||||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import Foundation
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
func trim() -> String {
|
func trim() -> String {
|
||||||
return self.trimmingCharacters(in: NSCharacterSet.whitespaces)
|
return trimmingCharacters(in: NSCharacterSet.whitespaces)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stripComments() -> String {
|
func stripComments() -> String {
|
||||||
// ((\s|,)\/\*[\s\S]*?\*\/)|(( |, ")\/\/.*)
|
// ((\s|,)\/\*[\s\S]*?\*\/)|(( |, ")\/\/.*)
|
||||||
return self.replacingOccurrences(of: "((\\s|,)\\/\\*[\\s\\S]*?\\*\\/)|(( |, \\\")\\/\\/.*)", with: "", options: .regularExpression)
|
return replacingOccurrences(of: "((\\s|,)\\/\\*[\\s\\S]*?\\*\\/)|(( |, \\\")\\/\\/.*)", with: "", options: .regularExpression)
|
||||||
}
|
}
|
||||||
|
|
||||||
var hexColor: NSColor? {
|
var hexColor: NSColor? {
|
||||||
let hex = trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
|
let hex = trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
|
||||||
var int = UInt32()
|
var int = UInt32()
|
||||||
@@ -39,69 +39,66 @@ extension String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension NSImage {
|
extension NSImage {
|
||||||
func resize(maxSize:NSSize) -> NSImage {
|
func resize(maxSize: NSSize) -> NSImage {
|
||||||
var ratio:Float = 0.0
|
var ratio: Float = 0.0
|
||||||
let imageWidth = Float(self.size.width)
|
let imageWidth = Float(size.width)
|
||||||
let imageHeight = Float(self.size.height)
|
let imageHeight = Float(size.height)
|
||||||
let maxWidth = Float(maxSize.width)
|
let maxWidth = Float(maxSize.width)
|
||||||
let maxHeight = Float(maxSize.height)
|
let maxHeight = Float(maxSize.height)
|
||||||
|
|
||||||
// Get ratio (landscape or portrait)
|
// Get ratio (landscape or portrait)
|
||||||
if (imageWidth > imageHeight) {
|
if imageWidth > imageHeight {
|
||||||
// Landscape
|
// Landscape
|
||||||
ratio = maxWidth / imageWidth;
|
ratio = maxWidth / imageWidth
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Portrait
|
// Portrait
|
||||||
ratio = maxHeight / imageHeight;
|
ratio = maxHeight / imageHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate new size based on the ratio
|
// Calculate new size based on the ratio
|
||||||
let newWidth = imageWidth * ratio
|
let newWidth = imageWidth * ratio
|
||||||
let newHeight = imageHeight * ratio
|
let newHeight = imageHeight * ratio
|
||||||
|
|
||||||
// Create a new NSSize object with the newly calculated size
|
// Create a new NSSize object with the newly calculated size
|
||||||
let newSize:NSSize = NSSize(width: Int(newWidth), height: Int(newHeight))
|
let newSize: NSSize = NSSize(width: Int(newWidth), height: Int(newHeight))
|
||||||
|
|
||||||
// Cast the NSImage to a CGImage
|
// Cast the NSImage to a CGImage
|
||||||
var imageRect:NSRect = NSMakeRect(0, 0, self.size.width, self.size.height)
|
var imageRect: NSRect = NSMakeRect(0, 0, size.width, size.height)
|
||||||
let imageRef = self.cgImage(forProposedRect: &imageRect, context: nil, hints: nil)
|
let imageRef = cgImage(forProposedRect: &imageRect, context: nil, hints: nil)
|
||||||
|
|
||||||
// Create NSImage from the CGImage using the new size
|
// Create NSImage from the CGImage using the new size
|
||||||
let imageWithNewSize = NSImage(cgImage: imageRef!, size: newSize)
|
let imageWithNewSize = NSImage(cgImage: imageRef!, size: newSize)
|
||||||
|
|
||||||
// Return the new image
|
// Return the new image
|
||||||
return imageWithNewSize
|
return imageWithNewSize
|
||||||
}
|
}
|
||||||
|
|
||||||
func rotateByDegreess(degrees:CGFloat) -> NSImage {
|
func rotateByDegreess(degrees: CGFloat) -> NSImage {
|
||||||
|
var imageBounds = NSZeroRect; imageBounds.size = size
|
||||||
var imageBounds = NSZeroRect ; imageBounds.size = self.size
|
|
||||||
let pathBounds = NSBezierPath(rect: imageBounds)
|
let pathBounds = NSBezierPath(rect: imageBounds)
|
||||||
var transform = NSAffineTransform()
|
var transform = NSAffineTransform()
|
||||||
transform.rotate(byDegrees: degrees)
|
transform.rotate(byDegrees: degrees)
|
||||||
pathBounds.transform(using: transform as AffineTransform)
|
pathBounds.transform(using: transform as AffineTransform)
|
||||||
let rotatedBounds:NSRect = NSMakeRect(NSZeroPoint.x, NSZeroPoint.y , self.size.width, self.size.height )
|
let rotatedBounds: NSRect = NSMakeRect(NSZeroPoint.x, NSZeroPoint.y, size.width, size.height)
|
||||||
let rotatedImage = NSImage(size: rotatedBounds.size)
|
let rotatedImage = NSImage(size: rotatedBounds.size)
|
||||||
|
|
||||||
//Center the image within the rotated bounds
|
// Center the image within the rotated bounds
|
||||||
imageBounds.origin.x = NSMidX(rotatedBounds) - (NSWidth(imageBounds) / 2)
|
imageBounds.origin.x = NSMidX(rotatedBounds) - (NSWidth(imageBounds) / 2)
|
||||||
imageBounds.origin.y = NSMidY(rotatedBounds) - (NSHeight(imageBounds) / 2)
|
imageBounds.origin.y = NSMidY(rotatedBounds) - (NSHeight(imageBounds) / 2)
|
||||||
|
|
||||||
// Start a new transform
|
// Start a new transform
|
||||||
transform = NSAffineTransform()
|
transform = NSAffineTransform()
|
||||||
// Move coordinate system to the center (since we want to rotate around the center)
|
// Move coordinate system to the center (since we want to rotate around the center)
|
||||||
transform.translateX(by: +(NSWidth(rotatedBounds) / 2 ), yBy: +(NSHeight(rotatedBounds) / 2))
|
transform.translateX(by: +(NSWidth(rotatedBounds) / 2), yBy: +(NSHeight(rotatedBounds) / 2))
|
||||||
transform.rotate(byDegrees: degrees)
|
transform.rotate(byDegrees: degrees)
|
||||||
// Move the coordinate system bak to normal
|
// Move the coordinate system bak to normal
|
||||||
transform.translateX(by: -(NSWidth(rotatedBounds) / 2 ), yBy: -(NSHeight(rotatedBounds) / 2))
|
transform.translateX(by: -(NSWidth(rotatedBounds) / 2), yBy: -(NSHeight(rotatedBounds) / 2))
|
||||||
// Draw the original image, rotated, into the new image
|
// Draw the original image, rotated, into the new image
|
||||||
rotatedImage.lockFocus()
|
rotatedImage.lockFocus()
|
||||||
transform.concat()
|
transform.concat()
|
||||||
self.draw(in: imageBounds, from: NSZeroRect, operation: NSCompositingOperation.copy, fraction: 1.0)
|
draw(in: imageBounds, from: NSZeroRect, operation: NSCompositingOperation.copy, fraction: 1.0)
|
||||||
rotatedImage.unlockFocus()
|
rotatedImage.unlockFocus()
|
||||||
|
|
||||||
return rotatedImage
|
return rotatedImage
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
func presentSystemModal(_ touchBar: NSTouchBar!, systemTrayItemIdentifier identifier: NSTouchBarItem.Identifier!) -> Void {
|
func presentSystemModal(_ touchBar: NSTouchBar!, systemTrayItemIdentifier identifier: NSTouchBarItem.Identifier!) {
|
||||||
if #available(OSX 10.14, *) {
|
if #available(OSX 10.14, *) {
|
||||||
NSTouchBar.presentSystemModalTouchBar(touchBar, systemTrayItemIdentifier: identifier)
|
NSTouchBar.presentSystemModalTouchBar(touchBar, systemTrayItemIdentifier: identifier)
|
||||||
} else {
|
} else {
|
||||||
@@ -14,7 +14,7 @@ func presentSystemModal(_ touchBar: NSTouchBar!, systemTrayItemIdentifier identi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func presentSystemModal(_ touchBar: NSTouchBar!, placement: Int64, systemTrayItemIdentifier identifier: NSTouchBarItem.Identifier!) -> Void {
|
func presentSystemModal(_ touchBar: NSTouchBar!, placement: Int64, systemTrayItemIdentifier identifier: NSTouchBarItem.Identifier!) {
|
||||||
if #available(OSX 10.14, *) {
|
if #available(OSX 10.14, *) {
|
||||||
NSTouchBar.presentSystemModalTouchBar(touchBar, placement: placement, systemTrayItemIdentifier: identifier)
|
NSTouchBar.presentSystemModalTouchBar(touchBar, placement: placement, systemTrayItemIdentifier: identifier)
|
||||||
} else {
|
} else {
|
||||||
@@ -22,7 +22,7 @@ func presentSystemModal(_ touchBar: NSTouchBar!, placement: Int64, systemTrayIte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func minimizeSystemModal(_ touchBar: NSTouchBar!) -> Void {
|
func minimizeSystemModal(_ touchBar: NSTouchBar!) {
|
||||||
if #available(OSX 10.14, *) {
|
if #available(OSX 10.14, *) {
|
||||||
NSTouchBar.minimizeSystemModalTouchBar(touchBar)
|
NSTouchBar.minimizeSystemModalTouchBar(touchBar)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -17,18 +17,17 @@ let appSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSuppor
|
|||||||
let standardConfigPath = appSupportDirectory.appending("/items.json")
|
let standardConfigPath = appSupportDirectory.appending("/items.json")
|
||||||
|
|
||||||
extension ItemType {
|
extension ItemType {
|
||||||
|
|
||||||
var identifierBase: String {
|
var identifierBase: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .staticButton(title: _):
|
case .staticButton(title: _):
|
||||||
return "com.toxblh.mtmr.staticButton."
|
return "com.toxblh.mtmr.staticButton."
|
||||||
case .appleScriptTitledButton(source: _):
|
case .appleScriptTitledButton(source: _):
|
||||||
return "com.toxblh.mtmr.appleScriptButton."
|
return "com.toxblh.mtmr.appleScriptButton."
|
||||||
case .timeButton(formatTemplate: _):
|
case .timeButton(formatTemplate: _, timeZone: _):
|
||||||
return "com.toxblh.mtmr.timeButton."
|
return "com.toxblh.mtmr.timeButton."
|
||||||
case .battery():
|
case .battery():
|
||||||
return "com.toxblh.mtmr.battery."
|
return "com.toxblh.mtmr.battery."
|
||||||
case .dock():
|
case .dock(autoResize: _):
|
||||||
return "com.toxblh.mtmr.dock"
|
return "com.toxblh.mtmr.dock"
|
||||||
case .volume():
|
case .volume():
|
||||||
return "com.toxblh.mtmr.volume"
|
return "com.toxblh.mtmr.volume"
|
||||||
@@ -36,7 +35,9 @@ extension ItemType {
|
|||||||
return "com.toxblh.mtmr.brightness"
|
return "com.toxblh.mtmr.brightness"
|
||||||
case .weather(interval: _, units: _, api_key: _, icon_type: _):
|
case .weather(interval: _, units: _, api_key: _, icon_type: _):
|
||||||
return "com.toxblh.mtmr.weather"
|
return "com.toxblh.mtmr.weather"
|
||||||
case .currency(interval: _, from: _, to: _):
|
case .yandexWeather(interval: _):
|
||||||
|
return "com.toxblh.mtmr.yandexWeather"
|
||||||
|
case .currency(interval: _, from: _, to: _, full: _):
|
||||||
return "com.toxblh.mtmr.currency"
|
return "com.toxblh.mtmr.currency"
|
||||||
case .inputsource():
|
case .inputsource():
|
||||||
return "com.toxblh.mtmr.inputsource."
|
return "com.toxblh.mtmr.inputsource."
|
||||||
@@ -44,9 +45,18 @@ extension ItemType {
|
|||||||
return "com.toxblh.mtmr.music."
|
return "com.toxblh.mtmr.music."
|
||||||
case .groupBar(items: _):
|
case .groupBar(items: _):
|
||||||
return "com.toxblh.mtmr.groupBar."
|
return "com.toxblh.mtmr.groupBar."
|
||||||
|
case .nightShift(items: _):
|
||||||
|
return "com.toxblh.mtmr.nightShift."
|
||||||
|
case .dnd(items: _):
|
||||||
|
return "com.toxblh.mtmr.dnd."
|
||||||
|
case .pomodoro(interval: _):
|
||||||
|
return PomodoroBarItem.identifier
|
||||||
|
case .network(flip: _):
|
||||||
|
return NetworkBarItem.identifier
|
||||||
|
case .darkMode(items: _):
|
||||||
|
return DarkModeBarItem.identifier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NSTouchBarItem.Identifier {
|
extension NSTouchBarItem.Identifier {
|
||||||
@@ -54,7 +64,6 @@ extension NSTouchBarItem.Identifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TouchBarController: NSObject, NSTouchBarDelegate {
|
class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||||
|
|
||||||
static let shared = TouchBarController()
|
static let shared = TouchBarController()
|
||||||
|
|
||||||
var touchBar: NSTouchBar!
|
var touchBar: NSTouchBar!
|
||||||
@@ -70,90 +79,84 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
var scrollArea: NSCustomTouchBarItem?
|
var scrollArea: NSCustomTouchBarItem?
|
||||||
var centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
var centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||||
|
|
||||||
var controlStripState: Bool {
|
var showControlStripState: Bool {
|
||||||
get {
|
get {
|
||||||
return UserDefaults.standard.bool(forKey: "com.toxblh.mtmr.settings.showControlStrip")
|
return UserDefaults.standard.bool(forKey: "com.toxblh.mtmr.settings.showControlStrip")
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
UserDefaults.standard.set(!controlStripState, forKey: "com.toxblh.mtmr.settings.showControlStrip")
|
UserDefaults.standard.set(newValue, forKey: "com.toxblh.mtmr.settings.showControlStrip")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var touchbarNeedRefresh: Bool = true
|
|
||||||
|
|
||||||
var blacklistAppIdentifiers: [String] = []
|
var blacklistAppIdentifiers: [String] = []
|
||||||
var frontmostApplicationIdentifier: String? {
|
var frontmostApplicationIdentifier: String? {
|
||||||
get {
|
guard let frontmostId = NSWorkspace.shared.frontmostApplication?.bundleIdentifier else { return nil }
|
||||||
guard let frontmostId = NSWorkspace.shared.frontmostApplication?.bundleIdentifier else { return nil }
|
return frontmostId
|
||||||
return frontmostId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private override init() {
|
private override init() {
|
||||||
super.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: "exitTouchbar", item: .staticButton(title: "exit"), action: .custom(closure: { [weak self] in self?.dismissTouchBar() }), longAction: .none)
|
||||||
|
|
||||||
SupportedTypesHolder.sharedInstance.register(typename: "close") { _ in
|
SupportedTypesHolder.sharedInstance.register(typename: "close") { _ in
|
||||||
return (item: .staticButton(title: ""), action: .custom(closure: { [weak self] in
|
(item: .staticButton(title: ""), action: .custom(closure: { [weak self] in
|
||||||
guard let `self` = self else { return }
|
guard let `self` = self else { return }
|
||||||
self.reloadPreset(path: self.lastPresetPath)
|
self.reloadPreset(path: self.lastPresetPath)
|
||||||
}), longAction: .none, parameters: [.width: .width(30), .image: .image(source: (NSImage(named: .stopProgressFreestandingTemplate))!)])
|
}), longAction: .none, parameters: [.width: .width(30), .image: .image(source: (NSImage(named: NSImage.stopProgressFreestandingTemplateName))!)])
|
||||||
}
|
}
|
||||||
|
|
||||||
if let blackListed = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.blackListedApps") {
|
if let blackListed = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.blackListedApps") {
|
||||||
self.blacklistAppIdentifiers = blackListed
|
blacklistAppIdentifiers = blackListed
|
||||||
}
|
}
|
||||||
|
|
||||||
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didLaunchApplicationNotification, object: nil)
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didLaunchApplicationNotification, object: nil)
|
||||||
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didTerminateApplicationNotification, object: nil)
|
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)
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didActivateApplicationNotification, object: nil)
|
||||||
|
|
||||||
reloadStandardConfig()
|
reloadStandardConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAndUpdatePreset(newJsonItems: [BarItemDefinition]) {
|
func createAndUpdatePreset(newJsonItems: [BarItemDefinition]) {
|
||||||
if let oldBar = self.touchBar {
|
if let oldBar = self.touchBar {
|
||||||
minimizeSystemModal(oldBar)
|
minimizeSystemModal(oldBar)
|
||||||
}
|
}
|
||||||
self.touchBar = NSTouchBar()
|
touchBar = NSTouchBar()
|
||||||
self.jsonItems = newJsonItems
|
jsonItems = newJsonItems
|
||||||
self.itemDefinitions = [:]
|
itemDefinitions = [:]
|
||||||
self.items = [:]
|
items = [:]
|
||||||
self.leftIdentifiers = []
|
leftIdentifiers = []
|
||||||
self.centerItems = []
|
centerItems = []
|
||||||
self.rightIdentifiers = []
|
rightIdentifiers = []
|
||||||
|
|
||||||
loadItemDefinitions(jsonItems: self.jsonItems)
|
loadItemDefinitions(jsonItems: jsonItems)
|
||||||
createItems()
|
createItems()
|
||||||
|
|
||||||
centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
||||||
return items[identifier]
|
items[identifier]
|
||||||
})
|
})
|
||||||
|
|
||||||
self.centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||||
self.scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)
|
scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)
|
||||||
|
|
||||||
touchBar.delegate = self
|
touchBar.delegate = self
|
||||||
touchBar.defaultItemIdentifiers = []
|
touchBar.defaultItemIdentifiers = []
|
||||||
touchBar.defaultItemIdentifiers = self.leftIdentifiers + [centerScrollArea] + self.rightIdentifiers
|
touchBar.defaultItemIdentifiers = leftIdentifiers + [centerScrollArea] + rightIdentifiers
|
||||||
|
|
||||||
self.updateActiveApp()
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func activeApplicationChanged(_ n: Notification) {
|
|
||||||
updateActiveApp()
|
updateActiveApp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func activeApplicationChanged(_: Notification) {
|
||||||
|
updateActiveApp()
|
||||||
|
}
|
||||||
|
|
||||||
func updateActiveApp() {
|
func updateActiveApp() {
|
||||||
if self.blacklistAppIdentifiers.index(of: self.frontmostApplicationIdentifier!) != nil {
|
if frontmostApplicationIdentifier != nil && blacklistAppIdentifiers.index(of: frontmostApplicationIdentifier!) != nil {
|
||||||
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, false)
|
dismissTouchBar()
|
||||||
self.touchbarNeedRefresh = true
|
|
||||||
} else {
|
} else {
|
||||||
presentTouchBar()
|
presentTouchBar()
|
||||||
self.touchbarNeedRefresh = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadStandardConfig() {
|
func reloadStandardConfig() {
|
||||||
let presetPath = standardConfigPath
|
let presetPath = standardConfigPath
|
||||||
if !FileManager.default.fileExists(atPath: presetPath),
|
if !FileManager.default.fileExists(atPath: presetPath),
|
||||||
@@ -161,17 +164,16 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
try? FileManager.default.createDirectory(atPath: appSupportDirectory, withIntermediateDirectories: true, attributes: nil)
|
try? FileManager.default.createDirectory(atPath: appSupportDirectory, withIntermediateDirectories: true, attributes: nil)
|
||||||
try? FileManager.default.copyItem(atPath: defaultPreset, toPath: presetPath)
|
try? FileManager.default.copyItem(atPath: defaultPreset, toPath: presetPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadPreset(path: presetPath)
|
reloadPreset(path: presetPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadPreset(path: String) {
|
func reloadPreset(path: String) {
|
||||||
lastPresetPath = path
|
lastPresetPath = path
|
||||||
let items = path.fileData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
let items = path.fileData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
||||||
touchbarNeedRefresh = true
|
|
||||||
createAndUpdatePreset(newJsonItems: items)
|
createAndUpdatePreset(newJsonItems: items)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadItemDefinitions(jsonItems: [BarItemDefinition]) {
|
func loadItemDefinitions(jsonItems: [BarItemDefinition]) {
|
||||||
let dateFormatter = DateFormatter()
|
let dateFormatter = DateFormatter()
|
||||||
dateFormatter.dateFormat = "HH-mm-ss"
|
dateFormatter.dateFormat = "HH-mm-ss"
|
||||||
@@ -191,19 +193,19 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createItems() {
|
func createItems() {
|
||||||
for (identifier, definition) in self.itemDefinitions {
|
for (identifier, definition) in itemDefinitions {
|
||||||
self.items[identifier] = self.createItem(forIdentifier: identifier, definition: definition)
|
items[identifier] = createItem(forIdentifier: identifier, definition: definition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func setupControlStripPresence() {
|
@objc func setupControlStripPresence() {
|
||||||
DFRSystemModalShowsCloseBoxWhenFrontMost(false)
|
DFRSystemModalShowsCloseBoxWhenFrontMost(false)
|
||||||
let item = NSCustomTouchBarItem(identifier: .controlStripItem)
|
let item = NSCustomTouchBarItem(identifier: .controlStripItem)
|
||||||
item.view = NSButton(image: #imageLiteral(resourceName: "StatusImage"), target: self, action: #selector(presentTouchBar))
|
item.view = NSButton(image: #imageLiteral(resourceName: "StatusImage"), target: self, action: #selector(presentTouchBar))
|
||||||
NSTouchBarItem.addSystemTrayItem(item)
|
NSTouchBarItem.addSystemTrayItem(item)
|
||||||
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, true)
|
updateControlStripPresence()
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateControlStripPresence() {
|
func updateControlStripPresence() {
|
||||||
@@ -211,28 +213,27 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func presentTouchBar() {
|
@objc private func presentTouchBar() {
|
||||||
if touchbarNeedRefresh {
|
if showControlStripState {
|
||||||
if self.controlStripState {
|
updateControlStripPresence()
|
||||||
presentSystemModal(touchBar, systemTrayItemIdentifier: .controlStripItem)
|
presentSystemModal(touchBar, systemTrayItemIdentifier: .controlStripItem)
|
||||||
} else {
|
} else {
|
||||||
presentSystemModal(touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
|
presentSystemModal(touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func dismissTouchBar() {
|
@objc private func dismissTouchBar() {
|
||||||
self.touchbarNeedRefresh = true
|
|
||||||
minimizeSystemModal(touchBar)
|
minimizeSystemModal(touchBar)
|
||||||
|
updateControlStripPresence()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func resetControlStrip() {
|
@objc func resetControlStrip() {
|
||||||
dismissTouchBar()
|
dismissTouchBar()
|
||||||
presentTouchBar()
|
presentTouchBar()
|
||||||
}
|
}
|
||||||
|
|
||||||
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
func touchBar(_: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
||||||
if identifier == centerScrollArea {
|
if identifier == centerScrollArea {
|
||||||
return self.scrollArea
|
return scrollArea
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let item = self.items[identifier],
|
guard let item = self.items[identifier],
|
||||||
@@ -242,64 +243,75 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
func createItem(forIdentifier identifier: NSTouchBarItem.Identifier, definition item: BarItemDefinition) -> NSTouchBarItem? {
|
|
||||||
|
|
||||||
|
func createItem(forIdentifier identifier: NSTouchBarItem.Identifier, definition item: BarItemDefinition) -> NSTouchBarItem? {
|
||||||
var barItem: NSTouchBarItem!
|
var barItem: NSTouchBarItem!
|
||||||
switch item.type {
|
switch item.type {
|
||||||
case .staticButton(title: let title):
|
case let .staticButton(title: title):
|
||||||
barItem = CustomButtonTouchBarItem(identifier: identifier, title: title)
|
barItem = CustomButtonTouchBarItem(identifier: identifier, title: title)
|
||||||
case .appleScriptTitledButton(source: let source, refreshInterval: let interval):
|
case let .appleScriptTitledButton(source: source, refreshInterval: interval):
|
||||||
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval)
|
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval)
|
||||||
case .timeButton(formatTemplate: let template):
|
case let .timeButton(formatTemplate: template, timeZone: timeZone):
|
||||||
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template)
|
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template, timeZone: timeZone)
|
||||||
case .battery():
|
case .battery():
|
||||||
barItem = BatteryBarItem(identifier: identifier)
|
barItem = BatteryBarItem(identifier: identifier)
|
||||||
case .dock:
|
case let .dock(autoResize: autoResize):
|
||||||
barItem = AppScrubberTouchBarItem(identifier: identifier)
|
barItem = AppScrubberTouchBarItem(identifier: identifier, autoResize: autoResize)
|
||||||
case .volume:
|
case .volume:
|
||||||
if case .image(let source)? = item.additionalParameters[.image] {
|
if case let .image(source)? = item.additionalParameters[.image] {
|
||||||
barItem = VolumeViewController(identifier: identifier, image: source.image)
|
barItem = VolumeViewController(identifier: identifier, image: source.image)
|
||||||
} else {
|
} else {
|
||||||
barItem = VolumeViewController(identifier: identifier)
|
barItem = VolumeViewController(identifier: identifier)
|
||||||
}
|
}
|
||||||
case .brightness(refreshInterval: let interval):
|
case let .brightness(refreshInterval: interval):
|
||||||
if case .image(let source)? = item.additionalParameters[.image] {
|
if case let .image(source)? = item.additionalParameters[.image] {
|
||||||
barItem = BrightnessViewController(identifier: identifier, refreshInterval: interval, image: source.image)
|
barItem = BrightnessViewController(identifier: identifier, refreshInterval: interval, image: source.image)
|
||||||
} else {
|
} else {
|
||||||
barItem = BrightnessViewController(identifier: identifier, refreshInterval: interval)
|
barItem = BrightnessViewController(identifier: identifier, refreshInterval: interval)
|
||||||
}
|
}
|
||||||
case .weather(interval: let interval, units: let units, api_key: let api_key, icon_type: let icon_type):
|
case let .weather(interval: interval, units: units, api_key: api_key, icon_type: icon_type):
|
||||||
barItem = WeatherBarItem(identifier: identifier, interval: interval, units: units, api_key: api_key, icon_type: icon_type)
|
barItem = WeatherBarItem(identifier: identifier, interval: interval, units: units, api_key: api_key, icon_type: icon_type)
|
||||||
case .currency(interval: let interval, from: let from, to: let to):
|
case let .yandexWeather(interval: interval):
|
||||||
barItem = CurrencyBarItem(identifier: identifier, interval: interval, from: from, to: to)
|
barItem = YandexWeatherBarItem(identifier: identifier, interval: interval)
|
||||||
|
case let .currency(interval: interval, from: from, to: to, full: full):
|
||||||
|
barItem = CurrencyBarItem(identifier: identifier, interval: interval, from: from, to: to, full: full)
|
||||||
case .inputsource():
|
case .inputsource():
|
||||||
barItem = InputSourceBarItem(identifier: identifier)
|
barItem = InputSourceBarItem(identifier: identifier)
|
||||||
case .music(interval: let interval):
|
case let .music(interval: interval, disableMarquee: disableMarquee):
|
||||||
barItem = MusicBarItem(identifier: identifier, interval: interval)
|
barItem = MusicBarItem(identifier: identifier, interval: interval, disableMarquee: disableMarquee)
|
||||||
case .groupBar(items: let items):
|
case let .groupBar(items: items):
|
||||||
barItem = GroupBarItem(identifier: identifier, items: items)
|
barItem = GroupBarItem(identifier: identifier, items: items)
|
||||||
|
case .nightShift():
|
||||||
|
barItem = NightShiftBarItem(identifier: identifier)
|
||||||
|
case .dnd():
|
||||||
|
barItem = DnDBarItem(identifier: identifier)
|
||||||
|
case let .pomodoro(workTime: workTime, restTime: restTime):
|
||||||
|
barItem = PomodoroBarItem(identifier: identifier, workTime: workTime, restTime: restTime)
|
||||||
|
case let .network(flip: flip):
|
||||||
|
barItem = NetworkBarItem(identifier: identifier, flip: flip)
|
||||||
|
case .darkMode():
|
||||||
|
barItem = DarkModeBarItem(identifier: identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let action = self.action(forItem: item), let item = barItem as? CustomButtonTouchBarItem {
|
if let action = self.action(forItem: item), let item = barItem as? CustomButtonTouchBarItem {
|
||||||
item.tapClosure = action
|
item.tapClosure = action
|
||||||
}
|
}
|
||||||
if let longAction = self.longAction(forItem: item), let item = barItem as? CustomButtonTouchBarItem {
|
if let longAction = self.longAction(forItem: item), let item = barItem as? CustomButtonTouchBarItem {
|
||||||
item.longTapClosure = longAction
|
item.longTapClosure = longAction
|
||||||
}
|
}
|
||||||
if case .bordered(let bordered)? = item.additionalParameters[.bordered], let item = barItem as? CustomButtonTouchBarItem {
|
if case let .bordered(bordered)? = item.additionalParameters[.bordered], let item = barItem as? CustomButtonTouchBarItem {
|
||||||
item.isBordered = bordered
|
item.isBordered = bordered
|
||||||
}
|
}
|
||||||
if case .background(let color)? = item.additionalParameters[.background], let item = barItem as? CustomButtonTouchBarItem {
|
if case let .background(color)? = item.additionalParameters[.background], let item = barItem as? CustomButtonTouchBarItem {
|
||||||
item.backgroundColor = color
|
item.backgroundColor = color
|
||||||
}
|
}
|
||||||
if case .width(let value)? = item.additionalParameters[.width], let widthBarItem = barItem as? CanSetWidth {
|
if case let .width(value)? = item.additionalParameters[.width], let widthBarItem = barItem as? CanSetWidth {
|
||||||
widthBarItem.setWidth(value: value)
|
widthBarItem.setWidth(value: value)
|
||||||
}
|
}
|
||||||
if case .image(let source)? = item.additionalParameters[.image], let item = barItem as? CustomButtonTouchBarItem {
|
if case let .image(source)? = item.additionalParameters[.image], let item = barItem as? CustomButtonTouchBarItem {
|
||||||
item.image = source.image
|
item.image = source.image
|
||||||
}
|
}
|
||||||
if case .title(let value)? = item.additionalParameters[.title] {
|
if case let .title(value)? = item.additionalParameters[.title] {
|
||||||
if let item = barItem as? GroupBarItem {
|
if let item = barItem as? GroupBarItem {
|
||||||
item.collapsedRepresentationLabel = value
|
item.collapsedRepresentationLabel = value
|
||||||
} else if let item = barItem as? CustomButtonTouchBarItem {
|
} else if let item = barItem as? CustomButtonTouchBarItem {
|
||||||
@@ -309,13 +321,13 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
return barItem
|
return barItem
|
||||||
}
|
}
|
||||||
|
|
||||||
func action(forItem item: BarItemDefinition) -> (()->())? {
|
func action(forItem item: BarItemDefinition) -> (() -> Void)? {
|
||||||
switch item.action {
|
switch item.action {
|
||||||
case .hidKey(keycode: let keycode):
|
case let .hidKey(keycode: keycode):
|
||||||
return { HIDPostAuxKey(keycode) }
|
return { HIDPostAuxKey(keycode) }
|
||||||
case .keyPress(keycode: let keycode):
|
case let .keyPress(keycode: keycode):
|
||||||
return { GenericKeyPress(keyCode: CGKeyCode(keycode)).send() }
|
return { GenericKeyPress(keyCode: CGKeyCode(keycode)).send() }
|
||||||
case .appleScript(source: let source):
|
case let .appleScript(source: source):
|
||||||
guard let appleScript = source.appleScript else {
|
guard let appleScript = source.appleScript else {
|
||||||
print("cannot create apple script for item \(item)")
|
print("cannot create apple script for item \(item)")
|
||||||
return {}
|
return {}
|
||||||
@@ -329,38 +341,37 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .shellScript(executable: let executable, parameters: let parameters):
|
case let .shellScript(executable: executable, parameters: parameters):
|
||||||
return {
|
return {
|
||||||
let task = Process()
|
let task = Process()
|
||||||
task.launchPath = executable
|
task.launchPath = executable
|
||||||
task.arguments = parameters
|
task.arguments = parameters
|
||||||
task.launch()
|
task.launch()
|
||||||
}
|
}
|
||||||
case .openUrl(url: let url):
|
case let .openUrl(url: url):
|
||||||
return {
|
return {
|
||||||
if let url = URL(string: url), NSWorkspace.shared.open(url) {
|
if let url = URL(string: url), NSWorkspace.shared.open(url) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
print("URL was successfully opened")
|
print("URL was successfully opened")
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
print("error", url)
|
print("error", url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .custom(closure: let closure):
|
case let .custom(closure: closure):
|
||||||
return closure
|
return closure
|
||||||
case .none:
|
case .none:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func longAction(forItem item: BarItemDefinition) -> (() -> Void)? {
|
||||||
func longAction(forItem item: BarItemDefinition) -> (()->())? {
|
|
||||||
switch item.longAction {
|
switch item.longAction {
|
||||||
case .hidKey(keycode: let keycode):
|
case let .hidKey(keycode: keycode):
|
||||||
return { HIDPostAuxKey(keycode) }
|
return { HIDPostAuxKey(keycode) }
|
||||||
case .keyPress(keycode: let keycode):
|
case let .keyPress(keycode: keycode):
|
||||||
return { GenericKeyPress(keyCode: CGKeyCode(keycode)).send() }
|
return { GenericKeyPress(keyCode: CGKeyCode(keycode)).send() }
|
||||||
case .appleScript(source: let source):
|
case let .appleScript(source: source):
|
||||||
guard let appleScript = source.appleScript else {
|
guard let appleScript = source.appleScript else {
|
||||||
print("cannot create apple script for item \(item)")
|
print("cannot create apple script for item \(item)")
|
||||||
return {}
|
return {}
|
||||||
@@ -372,24 +383,24 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
print("error \(error) when handling \(item) ")
|
print("error \(error) when handling \(item) ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .shellScript(executable: let executable, parameters: let parameters):
|
case let .shellScript(executable: executable, parameters: parameters):
|
||||||
return {
|
return {
|
||||||
let task = Process()
|
let task = Process()
|
||||||
task.launchPath = executable
|
task.launchPath = executable
|
||||||
task.arguments = parameters
|
task.arguments = parameters
|
||||||
task.launch()
|
task.launch()
|
||||||
}
|
}
|
||||||
case .openUrl(url: let url):
|
case let .openUrl(url: url):
|
||||||
return {
|
return {
|
||||||
if let url = URL(string: url), NSWorkspace.shared.open(url) {
|
if let url = URL(string: url), NSWorkspace.shared.open(url) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
print("URL was successfully opened")
|
print("URL was successfully opened")
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
print("error", url)
|
print("error", url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .custom(closure: let closure):
|
case let .custom(closure: closure):
|
||||||
return closure
|
return closure
|
||||||
case .none:
|
case .none:
|
||||||
return nil
|
return nil
|
||||||
@@ -403,13 +414,13 @@ protocol CanSetWidth {
|
|||||||
|
|
||||||
extension NSCustomTouchBarItem: CanSetWidth {
|
extension NSCustomTouchBarItem: CanSetWidth {
|
||||||
func setWidth(value: CGFloat) {
|
func setWidth(value: CGFloat) {
|
||||||
self.view.widthAnchor.constraint(equalToConstant: value).isActive = true
|
view.widthAnchor.constraint(equalToConstant: value).isActive = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension BarItemDefinition {
|
extension BarItemDefinition {
|
||||||
var align: Align {
|
var align: Align {
|
||||||
if case .align(let result)? = self.additionalParameters[.align] {
|
if case let .align(result)? = additionalParameters[.align] {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
return .center
|
return .center
|
||||||
|
|||||||
@@ -8,73 +8,80 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrubberDataSource {
|
class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrubberDataSource {
|
||||||
|
|
||||||
private var scrubber: NSScrubber!
|
private var scrubber: NSScrubber!
|
||||||
|
|
||||||
private let hf: HapticFeedback = HapticFeedback()
|
private let hf: HapticFeedback = HapticFeedback()
|
||||||
|
|
||||||
private var timer: Timer!
|
private var timer: Timer!
|
||||||
private var ticks: Int = 0
|
private var ticks: Int = 0
|
||||||
private let minTicks: Int = 5
|
private let minTicks: Int = 5
|
||||||
private let maxTicks: Int = 20
|
private let maxTicks: Int = 20
|
||||||
private var lastSelected: Int = 0
|
private var lastSelected: Int = 0
|
||||||
|
private var autoResize: Bool = false
|
||||||
|
private var widthConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
private var persistentAppIdentifiers: [String] = []
|
private var persistentAppIdentifiers: [String] = []
|
||||||
private var runningAppsIdentifiers: [String] = []
|
private var runningAppsIdentifiers: [String] = []
|
||||||
|
|
||||||
private var frontmostApplicationIdentifier: String? {
|
private var frontmostApplicationIdentifier: String? {
|
||||||
get {
|
guard let frontmostId = NSWorkspace.shared.frontmostApplication?.bundleIdentifier else { return nil }
|
||||||
guard let frontmostId = NSWorkspace.shared.frontmostApplication?.bundleIdentifier else { return nil }
|
return frontmostId
|
||||||
return frontmostId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var applications: [DockItem] = []
|
private var applications: [DockItem] = []
|
||||||
|
|
||||||
override init(identifier: NSTouchBarItem.Identifier) {
|
convenience override init(identifier: NSTouchBarItem.Identifier) {
|
||||||
|
self.init(identifier: identifier, autoResize: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
static var iconWidth = 36
|
||||||
|
static var spacingWidth = 2
|
||||||
|
|
||||||
|
init(identifier: NSTouchBarItem.Identifier, autoResize: Bool) {
|
||||||
super.init(identifier: identifier)
|
super.init(identifier: identifier)
|
||||||
|
self.autoResize = autoResize
|
||||||
|
|
||||||
scrubber = NSScrubber();
|
scrubber = NSScrubber()
|
||||||
scrubber.delegate = self
|
scrubber.delegate = self
|
||||||
scrubber.dataSource = self
|
scrubber.dataSource = self
|
||||||
scrubber.mode = .free // .fixed
|
scrubber.mode = .free // .fixed
|
||||||
let layout = NSScrubberFlowLayout();
|
let layout = NSScrubberFlowLayout()
|
||||||
layout.itemSize = NSSize(width: 36, height: 32)
|
layout.itemSize = NSSize(width: AppScrubberTouchBarItem.iconWidth, height: 32)
|
||||||
layout.itemSpacing = 2
|
layout.itemSpacing = CGFloat(AppScrubberTouchBarItem.spacingWidth)
|
||||||
scrubber.scrubberLayout = layout
|
scrubber.scrubberLayout = layout
|
||||||
scrubber.selectionBackgroundStyle = .roundedBackground
|
scrubber.selectionBackgroundStyle = .roundedBackground
|
||||||
scrubber.showsAdditionalContentIndicators = true
|
scrubber.showsAdditionalContentIndicators = true
|
||||||
|
|
||||||
view = scrubber
|
view = scrubber
|
||||||
|
|
||||||
scrubber.register(NSScrubberImageItemView.self, forItemIdentifier: NSUserInterfaceItemIdentifier(rawValue: "ScrubberApplicationsItemReuseIdentifier"))
|
scrubber.register(NSScrubberImageItemView.self, forItemIdentifier: NSUserInterfaceItemIdentifier(rawValue: "ScrubberApplicationsItemReuseIdentifier"))
|
||||||
|
|
||||||
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didLaunchApplicationNotification, object: nil)
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didLaunchApplicationNotification, object: nil)
|
||||||
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didTerminateApplicationNotification, object: nil)
|
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)
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didActivateApplicationNotification, object: nil)
|
||||||
|
|
||||||
if let persistent = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.dock.persistent") {
|
if let persistent = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.dock.persistent") {
|
||||||
self.persistentAppIdentifiers = persistent
|
persistentAppIdentifiers = persistent
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRunningApplication()
|
updateRunningApplication()
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func activeApplicationChanged(n: Notification) {
|
@objc func activeApplicationChanged(n _: Notification) {
|
||||||
updateRunningApplication()
|
updateRunningApplication()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
|
override func observeValue(forKeyPath _: String?, of _: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
|
||||||
updateRunningApplication()
|
updateRunningApplication()
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateRunningApplication() {
|
func updateRunningApplication() {
|
||||||
let newApplications = launchedApplications()
|
let newApplications = launchedApplications()
|
||||||
|
|
||||||
let index = newApplications.index {
|
let index = newApplications.index {
|
||||||
$0.bundleIdentifier == frontmostApplicationIdentifier
|
$0.bundleIdentifier == frontmostApplicationIdentifier
|
||||||
}
|
}
|
||||||
@@ -82,30 +89,43 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
|
|||||||
applications = newApplications
|
applications = newApplications
|
||||||
applications += getDockPersistentAppsList()
|
applications += getDockPersistentAppsList()
|
||||||
scrubber.reloadData()
|
scrubber.reloadData()
|
||||||
|
updateSize()
|
||||||
|
|
||||||
scrubber.selectedIndex = index ?? 0
|
scrubber.selectedIndex = index ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
public func numberOfItems(for scrubber: NSScrubber) -> Int {
|
func updateSize() {
|
||||||
|
if self.autoResize {
|
||||||
|
if let constraint: NSLayoutConstraint = self.widthConstraint {
|
||||||
|
constraint.isActive = false
|
||||||
|
self.scrubber.removeConstraint(constraint)
|
||||||
|
}
|
||||||
|
let width = (AppScrubberTouchBarItem.iconWidth + AppScrubberTouchBarItem.spacingWidth) * self.applications.count - AppScrubberTouchBarItem.spacingWidth
|
||||||
|
self.widthConstraint = self.scrubber.widthAnchor.constraint(equalToConstant: CGFloat(width))
|
||||||
|
self.widthConstraint!.isActive = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func numberOfItems(for _: NSScrubber) -> Int {
|
||||||
return applications.count
|
return applications.count
|
||||||
}
|
}
|
||||||
|
|
||||||
public func scrubber(_ scrubber: NSScrubber, viewForItemAt index: Int) -> NSScrubberItemView {
|
public func scrubber(_ scrubber: NSScrubber, viewForItemAt index: Int) -> NSScrubberItemView {
|
||||||
let item = scrubber.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "ScrubberApplicationsItemReuseIdentifier"), owner: self) as? NSScrubberImageItemView ?? NSScrubberImageItemView()
|
let item = scrubber.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "ScrubberApplicationsItemReuseIdentifier"), owner: self) as? NSScrubberImageItemView ?? NSScrubberImageItemView()
|
||||||
item.imageView.imageScaling = .scaleProportionallyDown
|
item.imageView.imageScaling = .scaleProportionallyDown
|
||||||
|
|
||||||
let app = applications[index]
|
let app = applications[index]
|
||||||
|
|
||||||
if let icon = app.icon {
|
if let icon = app.icon {
|
||||||
item.image = icon
|
item.image = icon
|
||||||
item.image.size = NSSize(width: 26, height: 26)
|
item.image.size = NSSize(width: 26, height: 26)
|
||||||
}
|
}
|
||||||
|
|
||||||
item.removeFromSuperview()
|
item.removeFromSuperview()
|
||||||
|
|
||||||
let dotView = NSView(frame: .zero)
|
let dotView = NSView(frame: .zero)
|
||||||
dotView.wantsLayer = true
|
dotView.wantsLayer = true
|
||||||
if self.runningAppsIdentifiers.contains(app.bundleIdentifier!) {
|
if runningAppsIdentifiers.contains(app.bundleIdentifier!) {
|
||||||
dotView.layer?.backgroundColor = NSColor.white.cgColor
|
dotView.layer?.backgroundColor = NSColor.white.cgColor
|
||||||
} else {
|
} else {
|
||||||
dotView.layer?.backgroundColor = NSColor.black.cgColor
|
dotView.layer?.backgroundColor = NSColor.black.cgColor
|
||||||
@@ -117,48 +137,48 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
|
|||||||
|
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
public func didBeginInteracting(with scrubber: NSScrubber) {
|
public func didBeginInteracting(with _: NSScrubber) {
|
||||||
stopTimer()
|
stopTimer()
|
||||||
self.ticks = 0
|
ticks = 0
|
||||||
self.timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(checkTimer), userInfo: nil, repeats: true)
|
timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(checkTimer), userInfo: nil, repeats: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func checkTimer() {
|
@objc private func checkTimer() {
|
||||||
self.ticks += 1
|
ticks += 1
|
||||||
|
|
||||||
if (self.ticks == minTicks) {
|
if ticks == minTicks {
|
||||||
hf.tap(strong: 2)
|
hf.tap(strong: 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.ticks > maxTicks) {
|
if ticks > maxTicks {
|
||||||
stopTimer()
|
stopTimer()
|
||||||
hf.tap(strong: 6)
|
hf.tap(strong: 6)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func stopTimer() {
|
private func stopTimer() {
|
||||||
self.timer?.invalidate()
|
timer?.invalidate()
|
||||||
self.timer = nil
|
timer = nil
|
||||||
self.lastSelected = 0
|
lastSelected = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
public func didCancelInteracting(with scrubber: NSScrubber) {
|
public func didCancelInteracting(with _: NSScrubber) {
|
||||||
stopTimer()
|
stopTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func didFinishInteracting(with scrubber: NSScrubber) {
|
public func didFinishInteracting(with scrubber: NSScrubber) {
|
||||||
stopTimer()
|
stopTimer()
|
||||||
|
|
||||||
if (ticks == 0) {
|
if ticks == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.ticks >= minTicks && scrubber.selectedIndex > 0) {
|
if ticks >= minTicks && scrubber.selectedIndex > 0 {
|
||||||
self.longPress(selected: scrubber.selectedIndex)
|
longPress(selected: scrubber.selectedIndex)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let bundleIdentifier = applications[scrubber.selectedIndex].bundleIdentifier
|
let bundleIdentifier = applications[scrubber.selectedIndex].bundleIdentifier
|
||||||
if bundleIdentifier!.contains("file://") {
|
if bundleIdentifier!.contains("file://") {
|
||||||
NSWorkspace.shared.openFile(bundleIdentifier!.replacingOccurrences(of: "file://", with: ""))
|
NSWorkspace.shared.openFile(bundleIdentifier!.replacingOccurrences(of: "file://", with: ""))
|
||||||
@@ -167,16 +187,16 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
|
|||||||
hf.tap(strong: 6)
|
hf.tap(strong: 6)
|
||||||
}
|
}
|
||||||
updateRunningApplication()
|
updateRunningApplication()
|
||||||
|
|
||||||
// NB: if you can't open app which on another space, try to check mark
|
// NB: if you can't open app which on another space, try to check mark
|
||||||
// "When switching to an application, switch to a Space with open windows for the application"
|
// "When switching to an application, switch to a Space with open windows for the application"
|
||||||
// in Mission control settings
|
// in Mission control settings
|
||||||
}
|
}
|
||||||
|
|
||||||
private func longPress(selected: Int) {
|
private func longPress(selected: Int) {
|
||||||
let bundleIdentifier = applications[selected].bundleIdentifier
|
let bundleIdentifier = applications[selected].bundleIdentifier
|
||||||
|
|
||||||
if (self.ticks > maxTicks) {
|
if ticks > maxTicks {
|
||||||
if let processIdentifier = applications[selected].pid {
|
if let processIdentifier = applications[selected].pid {
|
||||||
if !(NSRunningApplication(processIdentifier: processIdentifier)?.terminate())! {
|
if !(NSRunningApplication(processIdentifier: processIdentifier)?.terminate())! {
|
||||||
NSRunningApplication(processIdentifier: processIdentifier)?.forceTerminate()
|
NSRunningApplication(processIdentifier: processIdentifier)?.forceTerminate()
|
||||||
@@ -185,34 +205,34 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
|
|||||||
} else {
|
} else {
|
||||||
hf.tap(strong: 6)
|
hf.tap(strong: 6)
|
||||||
if let index = self.persistentAppIdentifiers.index(of: bundleIdentifier!) {
|
if let index = self.persistentAppIdentifiers.index(of: bundleIdentifier!) {
|
||||||
self.persistentAppIdentifiers.remove(at: index)
|
persistentAppIdentifiers.remove(at: index)
|
||||||
} else {
|
} else {
|
||||||
self.persistentAppIdentifiers.append(bundleIdentifier!)
|
persistentAppIdentifiers.append(bundleIdentifier!)
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDefaults.standard.set(self.persistentAppIdentifiers, forKey: "com.toxblh.mtmr.dock.persistent")
|
UserDefaults.standard.set(persistentAppIdentifiers, forKey: "com.toxblh.mtmr.dock.persistent")
|
||||||
UserDefaults.standard.synchronize()
|
UserDefaults.standard.synchronize()
|
||||||
}
|
}
|
||||||
self.ticks = 0
|
ticks = 0
|
||||||
updateRunningApplication()
|
updateRunningApplication()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func launchedApplications() -> [DockItem] {
|
private func launchedApplications() -> [DockItem] {
|
||||||
self.runningAppsIdentifiers = []
|
runningAppsIdentifiers = []
|
||||||
var returnable: [DockItem] = []
|
var returnable: [DockItem] = []
|
||||||
for app in NSWorkspace.shared.runningApplications {
|
for app in NSWorkspace.shared.runningApplications {
|
||||||
guard app.activationPolicy == NSApplication.ActivationPolicy.regular else { continue }
|
guard app.activationPolicy == NSApplication.ActivationPolicy.regular else { continue }
|
||||||
guard let bundleIdentifier = app.bundleIdentifier else { continue }
|
guard let bundleIdentifier = app.bundleIdentifier else { continue }
|
||||||
|
|
||||||
self.runningAppsIdentifiers.append(bundleIdentifier)
|
runningAppsIdentifiers.append(bundleIdentifier)
|
||||||
|
|
||||||
let dockItem = DockItem(bundleIdentifier: bundleIdentifier, icon: getIcon(forBundleIdentifier: bundleIdentifier), pid: app.processIdentifier)
|
let dockItem = DockItem(bundleIdentifier: bundleIdentifier, icon: getIcon(forBundleIdentifier: bundleIdentifier), pid: app.processIdentifier)
|
||||||
returnable.append(dockItem)
|
returnable.append(dockItem)
|
||||||
}
|
}
|
||||||
return returnable
|
return returnable
|
||||||
}
|
}
|
||||||
|
|
||||||
public func getIcon(forBundleIdentifier bundleIdentifier: String? = nil, orPath path: String? = nil, orType type: String? = nil) -> NSImage {
|
public func getIcon(forBundleIdentifier bundleIdentifier: String? = nil, orPath path: String? = nil, orType _: String? = nil) -> NSImage {
|
||||||
if bundleIdentifier != nil {
|
if bundleIdentifier != nil {
|
||||||
if let appPath = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: bundleIdentifier!) {
|
if let appPath = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: bundleIdentifier!) {
|
||||||
return NSWorkspace.shared.icon(forFile: appPath)
|
return NSWorkspace.shared.icon(forFile: appPath)
|
||||||
@@ -226,13 +246,12 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
|
|||||||
let genericIcon = NSImage(contentsOfFile: "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericDocumentIcon.icns")
|
let genericIcon = NSImage(contentsOfFile: "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericDocumentIcon.icns")
|
||||||
return genericIcon ?? NSImage(size: .zero)
|
return genericIcon ?? NSImage(size: .zero)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public func getDockPersistentAppsList() -> [DockItem] {
|
public func getDockPersistentAppsList() -> [DockItem] {
|
||||||
var returnable: [DockItem] = []
|
var returnable: [DockItem] = []
|
||||||
|
|
||||||
for bundleIdentifier in persistentAppIdentifiers {
|
for bundleIdentifier in persistentAppIdentifiers {
|
||||||
if !self.runningAppsIdentifiers.contains(bundleIdentifier) {
|
if !runningAppsIdentifiers.contains(bundleIdentifier) {
|
||||||
let dockItem = DockItem(bundleIdentifier: bundleIdentifier, icon: getIcon(forBundleIdentifier: bundleIdentifier))
|
let dockItem = DockItem(bundleIdentifier: bundleIdentifier, icon: getIcon(forBundleIdentifier: bundleIdentifier))
|
||||||
returnable.append(dockItem)
|
returnable.append(dockItem)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,29 +6,29 @@
|
|||||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import IOKit.ps
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import IOKit.ps
|
||||||
|
|
||||||
class BatteryBarItem: CustomButtonTouchBarItem {
|
class BatteryBarItem: CustomButtonTouchBarItem {
|
||||||
private let batteryInfo = BatteryInfo()
|
private let batteryInfo = BatteryInfo()
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier) {
|
init(identifier: NSTouchBarItem.Identifier) {
|
||||||
super.init(identifier: identifier, title: " ")
|
super.init(identifier: identifier, title: " ")
|
||||||
|
|
||||||
batteryInfo.start { [weak self] in
|
batteryInfo.start { [weak self] in
|
||||||
self?.refresh()
|
self?.refresh()
|
||||||
}
|
}
|
||||||
self.refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func refresh() {
|
func refresh() {
|
||||||
self.attributedTitle = self.batteryInfo.formattedInfo()
|
attributedTitle = batteryInfo.formattedInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
batteryInfo.stop()
|
batteryInfo.stop()
|
||||||
}
|
}
|
||||||
@@ -42,85 +42,79 @@ class BatteryInfo: NSObject {
|
|||||||
var isCharging: Bool = false
|
var isCharging: Bool = false
|
||||||
var ACPower: String = ""
|
var ACPower: String = ""
|
||||||
var timeRemaining: String = ""
|
var timeRemaining: String = ""
|
||||||
var notifyBlock: ()->() = {}
|
var notifyBlock: () -> Void = {}
|
||||||
var loop:CFRunLoopSource?
|
var loop: CFRunLoopSource?
|
||||||
|
|
||||||
func start(notifyBlock: @escaping ()->()) {
|
func start(notifyBlock: @escaping () -> Void) {
|
||||||
self.notifyBlock = notifyBlock
|
self.notifyBlock = notifyBlock
|
||||||
let opaque = Unmanaged.passRetained(self).toOpaque()
|
let opaque = Unmanaged.passRetained(self).toOpaque()
|
||||||
let context = UnsafeMutableRawPointer(opaque)
|
let context = UnsafeMutableRawPointer(opaque)
|
||||||
loop = IOPSNotificationCreateRunLoopSource({ (context) in
|
loop = IOPSNotificationCreateRunLoopSource({ context in
|
||||||
guard let ctx = context else {
|
guard let ctx = context else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let watcher = Unmanaged<BatteryInfo>.fromOpaque(ctx).takeUnretainedValue()
|
let watcher = Unmanaged<BatteryInfo>.fromOpaque(ctx).takeUnretainedValue()
|
||||||
watcher.notifyBlock()
|
watcher.notifyBlock()
|
||||||
}, context).takeRetainedValue() as CFRunLoopSource
|
}, context).takeRetainedValue() as CFRunLoopSource
|
||||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), loop, CFRunLoopMode.defaultMode)
|
CFRunLoopAddSource(CFRunLoopGetCurrent(), loop, CFRunLoopMode.defaultMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stop() {
|
func stop() {
|
||||||
self.notifyBlock = {}
|
notifyBlock = {}
|
||||||
guard let loop = self.loop else {
|
guard let loop = self.loop else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), loop, CFRunLoopMode.defaultMode)
|
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), loop, CFRunLoopMode.defaultMode)
|
||||||
self.loop = nil
|
self.loop = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPSInfo() {
|
func getPSInfo() {
|
||||||
let psInfo = IOPSCopyPowerSourcesInfo().takeRetainedValue()
|
let psInfo = IOPSCopyPowerSourcesInfo().takeRetainedValue()
|
||||||
let psList = IOPSCopyPowerSourcesList(psInfo).takeRetainedValue() as [CFTypeRef]
|
let psList = IOPSCopyPowerSourcesList(psInfo).takeRetainedValue() as [CFTypeRef]
|
||||||
|
|
||||||
for ps in psList {
|
for ps in psList {
|
||||||
if let psDesc = IOPSGetPowerSourceDescription(psInfo, ps).takeUnretainedValue() as? [String: Any] {
|
if let psDesc = IOPSGetPowerSourceDescription(psInfo, ps).takeUnretainedValue() as? [String: Any] {
|
||||||
let current = psDesc[kIOPSCurrentCapacityKey]
|
if let current = psDesc[kIOPSCurrentCapacityKey] as? Int {
|
||||||
if (current != nil) {
|
self.current = current
|
||||||
self.current = current as! Int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let timeToEmpty = psDesc[kIOPSTimeToEmptyKey]
|
if let timeToEmpty = psDesc[kIOPSTimeToEmptyKey] as? Int {
|
||||||
if (timeToEmpty != nil) {
|
self.timeToEmpty = timeToEmpty
|
||||||
self.timeToEmpty = timeToEmpty as! Int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let timeToFull = psDesc[kIOPSTimeToFullChargeKey]
|
if let timeToFull = psDesc[kIOPSTimeToFullChargeKey] as? Int {
|
||||||
if (timeToFull != nil) {
|
self.timeToFull = timeToFull
|
||||||
self.timeToFull = timeToFull as! Int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let isCharged = psDesc[kIOPSIsChargedKey]
|
if let isCharged = psDesc[kIOPSIsChargedKey] as? Bool {
|
||||||
if (isCharged != nil) {
|
self.isCharged = isCharged
|
||||||
self.isCharged = isCharged as! Bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let isCharging = psDesc[kIOPSIsChargingKey]
|
if let isCharging = psDesc[kIOPSIsChargingKey] as? Bool {
|
||||||
if (isCharging != nil) {
|
self.isCharging = isCharging
|
||||||
self.isCharging = isCharging as! Bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let ACPower = psDesc[kIOPSPowerSourceStateKey]
|
if let ACPower = psDesc[kIOPSPowerSourceStateKey] as? String {
|
||||||
if (ACPower != nil) {
|
self.ACPower = ACPower
|
||||||
self.ACPower = ACPower as! String
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFormattedTime(time: Int) -> String {
|
func getFormattedTime(time: Int) -> String {
|
||||||
if (time > 0) {
|
if time > 0 {
|
||||||
let timeFormatted = NSString(format: " %d:%02d", time / 60, time % 60) as String
|
let timeFormatted = NSString(format: " %d:%02d", time / 60, time % 60) as String
|
||||||
return timeFormatted
|
return timeFormatted
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
public func formattedInfo() -> NSAttributedString {
|
public func formattedInfo() -> NSAttributedString {
|
||||||
var title = ""
|
var title = ""
|
||||||
self.getPSInfo()
|
getPSInfo()
|
||||||
|
|
||||||
if ACPower == "AC Power" {
|
if ACPower == "AC Power" {
|
||||||
if current < 100 {
|
if current < 100 {
|
||||||
title += "⚡️"
|
title += "⚡️"
|
||||||
@@ -129,19 +123,18 @@ class BatteryInfo: NSObject {
|
|||||||
} else {
|
} else {
|
||||||
timeRemaining = getFormattedTime(time: timeToEmpty)
|
timeRemaining = getFormattedTime(time: timeToEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
title += String(current) + "%"
|
title += String(current) + "%"
|
||||||
|
|
||||||
var color = NSColor.white
|
var color = NSColor.white
|
||||||
if current <= 10 && ACPower != "AC Power" {
|
if current <= 10 && ACPower != "AC Power" {
|
||||||
color = NSColor.red
|
color = NSColor.red
|
||||||
}
|
}
|
||||||
|
|
||||||
let newTitle = NSMutableAttributedString(string: title as String, attributes: [.foregroundColor: color, .font: NSFont.systemFont(ofSize: 15), .baselineOffset: 1])
|
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.append(newTitleSecond)
|
||||||
newTitle.setAlignment(.center, range: NSRange(location: 0, length: title.count))
|
newTitle.setAlignment(.center, range: NSRange(location: 0, length: title.count))
|
||||||
return newTitle
|
return newTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,63 +1,71 @@
|
|||||||
import Cocoa
|
|
||||||
import AppKit
|
import AppKit
|
||||||
import AVFoundation
|
import AVFoundation
|
||||||
|
import Cocoa
|
||||||
import CoreAudio
|
import CoreAudio
|
||||||
|
|
||||||
class BrightnessViewController: NSCustomTouchBarItem {
|
class BrightnessViewController: NSCustomTouchBarItem {
|
||||||
private(set) var sliderItem: CustomSlider!
|
private(set) var sliderItem: CustomSlider!
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, refreshInterval: Double, image: NSImage? = nil) {
|
init(identifier: NSTouchBarItem.Identifier, refreshInterval: Double, image: NSImage? = nil) {
|
||||||
super.init(identifier: identifier)
|
super.init(identifier: identifier)
|
||||||
|
|
||||||
if (image == nil) {
|
if image == nil {
|
||||||
sliderItem = CustomSlider()
|
sliderItem = CustomSlider()
|
||||||
} else {
|
} else {
|
||||||
sliderItem = CustomSlider(knob: image!)
|
sliderItem = CustomSlider(knob: image!)
|
||||||
}
|
}
|
||||||
sliderItem.target = self
|
sliderItem.target = self
|
||||||
sliderItem.action = #selector(BrightnessViewController.sliderValueChanged(_:))
|
sliderItem.action = #selector(BrightnessViewController.sliderValueChanged(_:))
|
||||||
sliderItem.minValue = 0.0
|
sliderItem.minValue = 0.0
|
||||||
sliderItem.maxValue = 100.0
|
sliderItem.maxValue = 100.0
|
||||||
sliderItem.floatValue = getBrightness()*100
|
sliderItem.floatValue = getBrightness() * 100
|
||||||
|
|
||||||
self.view = sliderItem
|
view = sliderItem
|
||||||
|
|
||||||
let timer = Timer.scheduledTimer(timeInterval: refreshInterval, target: self, selector: #selector(BrightnessViewController.updateBrightnessSlider), userInfo: nil, repeats: true)
|
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) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
sliderItem.unbind(NSBindingName.value)
|
sliderItem.unbind(NSBindingName.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func updateBrightnessSlider() {
|
@objc func updateBrightnessSlider() {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.sliderItem.floatValue = self.getBrightness() * 100
|
self.sliderItem.floatValue = self.getBrightness() * 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func sliderValueChanged(_ sender: Any) {
|
@objc func sliderValueChanged(_ sender: Any) {
|
||||||
if let sliderItem = sender as? NSSlider {
|
if let sliderItem = sender as? NSSlider {
|
||||||
setBrightness(level: Float32(sliderItem.intValue)/100.0)
|
setBrightness(level: Float32(sliderItem.intValue) / 100.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getBrightness() -> Float32 {
|
private func getBrightness() -> Float32 {
|
||||||
var level: Float32 = 0.5
|
if #available(OSX 10.13, *) {
|
||||||
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"))
|
return Float32(CoreDisplay_Display_GetUserBrightness(0))
|
||||||
|
} else {
|
||||||
IODisplayGetFloatParameter(service, 0, kIODisplayBrightnessKey as CFString, &level)
|
var level: Float32 = 0.5
|
||||||
return level
|
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"))
|
||||||
|
|
||||||
|
IODisplayGetFloatParameter(service, 0, kIODisplayBrightnessKey as CFString, &level)
|
||||||
|
return level
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setBrightness(level: Float) {
|
private func setBrightness(level: Float) {
|
||||||
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"))
|
if #available(OSX 10.13, *) {
|
||||||
|
CoreDisplay_Display_SetUserBrightness(0, Double(level))
|
||||||
IODisplaySetFloatParameter(service, 0, kIODisplayBrightnessKey as CFString, level)
|
} else {
|
||||||
IOObjectRelease(service)
|
let service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"))
|
||||||
|
|
||||||
|
IODisplaySetFloatParameter(service, 1, kIODisplayBrightnessKey as CFString, level)
|
||||||
|
IOObjectRelease(service)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ import CoreLocation
|
|||||||
class CurrencyBarItem: CustomButtonTouchBarItem {
|
class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||||
private let activity: NSBackgroundActivityScheduler
|
private let activity: NSBackgroundActivityScheduler
|
||||||
private var prefix: String
|
private var prefix: String
|
||||||
|
private var postfix: String
|
||||||
private var from: String
|
private var from: String
|
||||||
private var to: String
|
private var to: String
|
||||||
private var oldValue: Float32!
|
private var oldValue: Float32!
|
||||||
|
private var full: Bool = false
|
||||||
|
|
||||||
private let currencies = [
|
private let currencies = [
|
||||||
"USD": "$",
|
"USD": "$",
|
||||||
@@ -36,16 +38,23 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
|||||||
"ETH": "Ξ",
|
"ETH": "Ξ",
|
||||||
]
|
]
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: String, to: String) {
|
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: String, to: String, full: Bool) {
|
||||||
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
||||||
activity.interval = interval
|
activity.interval = interval
|
||||||
self.from = from
|
self.from = from
|
||||||
self.to = to
|
self.to = to
|
||||||
|
self.full = full
|
||||||
|
|
||||||
if let prefix = currencies[from] {
|
if let prefix = currencies[from] {
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
} else {
|
} else {
|
||||||
self.prefix = from
|
prefix = from
|
||||||
|
}
|
||||||
|
|
||||||
|
if let postfix = currencies[to] {
|
||||||
|
self.postfix = postfix
|
||||||
|
} else {
|
||||||
|
postfix = to
|
||||||
}
|
}
|
||||||
|
|
||||||
super.init(identifier: identifier, title: "⏳")
|
super.init(identifier: identifier, title: "⏳")
|
||||||
@@ -59,21 +68,21 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
|||||||
updateCurrency()
|
updateCurrency()
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func updateCurrency() {
|
@objc func updateCurrency() {
|
||||||
let urlRequest = URLRequest(url: URL(string: "https://api.coinbase.com/v2/exchange-rates?currency=\(from)")!)
|
let urlRequest = URLRequest(url: URL(string: "https://api.coinbase.com/v2/exchange-rates?currency=\(from)")!)
|
||||||
|
|
||||||
let task = URLSession.shared.dataTask(with: urlRequest) { (data, response, error) in
|
let task = URLSession.shared.dataTask(with: urlRequest) { data, _, error in
|
||||||
if error == nil {
|
if error == nil {
|
||||||
do {
|
do {
|
||||||
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! [String : AnyObject]
|
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! [String: AnyObject]
|
||||||
var value: Float32!
|
var value: Float32!
|
||||||
|
|
||||||
if let data_array = json["data"] as? [String : AnyObject] {
|
if let data_array = json["data"] as? [String: AnyObject] {
|
||||||
if let rates = data_array["rates"] as? [String : AnyObject] {
|
if let rates = data_array["rates"] as? [String: AnyObject] {
|
||||||
if let item = rates["\(self.to)"] as? String {
|
if let item = rates["\(self.to)"] as? String {
|
||||||
value = Float32(item)
|
value = Float32(item)
|
||||||
}
|
}
|
||||||
@@ -103,13 +112,19 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
|||||||
color = NSColor.red
|
color = NSColor.red
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.oldValue = value
|
|
||||||
|
|
||||||
let title = String(format: "%@%.2f", self.prefix, value)
|
oldValue = value
|
||||||
|
|
||||||
let regularFont = self.attributedTitle.attribute(.font, at: 0, effectiveRange: nil) as? NSFont ?? NSFont.systemFont(ofSize: 15)
|
var title = ""
|
||||||
|
if full {
|
||||||
|
title = String(format: "%@‣%.2f%@", prefix, value, postfix)
|
||||||
|
} else {
|
||||||
|
title = String(format: "%@%.2f", prefix, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
let regularFont = attributedTitle.attribute(.font, at: 0, effectiveRange: nil) as? NSFont ?? NSFont.systemFont(ofSize: 15)
|
||||||
let newTitle = NSMutableAttributedString(string: title as String, attributes: [.foregroundColor: color, .font: regularFont])
|
let newTitle = NSMutableAttributedString(string: title as String, attributes: [.foregroundColor: color, .font: regularFont])
|
||||||
newTitle.setAlignment(.center, range: NSRange(location: 0, length: title.count))
|
newTitle.setAlignment(.center, range: NSRange(location: 0, length: title.count))
|
||||||
self.attributedTitle = newTitle
|
attributedTitle = newTitle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
class DarkModeBarItem: CustomButtonTouchBarItem, Widget {
|
||||||
|
static var name: String = "darkmode"
|
||||||
|
static var identifier: String = "com.toxblh.mtmr.darkmode"
|
||||||
|
|
||||||
|
private var timer: Timer!
|
||||||
|
|
||||||
|
init(identifier: NSTouchBarItem.Identifier) {
|
||||||
|
super.init(identifier: identifier, title: "")
|
||||||
|
isBordered = false
|
||||||
|
setWidth(value: 24)
|
||||||
|
|
||||||
|
tapClosure = { [weak self] in self?.DarkModeToggle() }
|
||||||
|
|
||||||
|
timer = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(refresh), userInfo: nil, repeats: true)
|
||||||
|
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder _: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func DarkModeToggle() {
|
||||||
|
DarkMode.isEnabled = !DarkMode.isEnabled
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func refresh() {
|
||||||
|
image = DarkMode.isEnabled ? #imageLiteral(resourceName: "dark-mode-on") : #imageLiteral(resourceName: "dark-mode-off")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct DarkMode {
|
||||||
|
private static let prefix = "tell application \"System Events\" to tell appearance preferences to"
|
||||||
|
|
||||||
|
static var isEnabled: Bool {
|
||||||
|
get {
|
||||||
|
return UserDefaults.standard.string(forKey: "AppleInterfaceStyle") == "Dark"
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
toggle(force: newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func toggle(force: Bool? = nil) {
|
||||||
|
let value = force.map(String.init) ?? "not dark mode"
|
||||||
|
runAppleScript("\(prefix) set dark mode to \(value)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func runAppleScript(_ source: String) -> String? {
|
||||||
|
return NSAppleScript(source: source)?.executeAndReturnError(nil).stringValue
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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: "")
|
||||||
|
isBordered = false
|
||||||
|
setWidth(value: 32)
|
||||||
|
|
||||||
|
tapClosure = { [weak self] in self?.DnDToggle() }
|
||||||
|
|
||||||
|
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(refresh), userInfo: nil, repeats: true)
|
||||||
|
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder _: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func DnDToggle() {
|
||||||
|
DoNotDisturb.isEnabled = !DoNotDisturb.isEnabled
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func refresh() {
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,9 +8,8 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class GroupBarItem: NSPopoverTouchBarItem, NSTouchBarDelegate {
|
class GroupBarItem: NSPopoverTouchBarItem, NSTouchBarDelegate {
|
||||||
|
|
||||||
var jsonItems: [BarItemDefinition]
|
var jsonItems: [BarItemDefinition]
|
||||||
|
|
||||||
var itemDefinitions: [NSTouchBarItem.Identifier: BarItemDefinition] = [:]
|
var itemDefinitions: [NSTouchBarItem.Identifier: BarItemDefinition] = [:]
|
||||||
var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:]
|
var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:]
|
||||||
var leftIdentifiers: [NSTouchBarItem.Identifier] = []
|
var leftIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||||
@@ -19,62 +18,60 @@ class GroupBarItem: NSPopoverTouchBarItem, NSTouchBarDelegate {
|
|||||||
var rightIdentifiers: [NSTouchBarItem.Identifier] = []
|
var rightIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||||
var scrollArea: NSCustomTouchBarItem?
|
var scrollArea: NSCustomTouchBarItem?
|
||||||
var centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
var centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, items: [BarItemDefinition]) {
|
init(identifier: NSTouchBarItem.Identifier, items: [BarItemDefinition]) {
|
||||||
jsonItems = items
|
jsonItems = items
|
||||||
super.init(identifier: identifier)
|
super.init(identifier: identifier)
|
||||||
self.popoverTouchBar.delegate = self
|
popoverTouchBar.delegate = self
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {}
|
||||||
|
|
||||||
}
|
@objc override func showPopover(_: Any?) {
|
||||||
|
itemDefinitions = [:]
|
||||||
@objc override func showPopover(_ sender: Any?) {
|
items = [:]
|
||||||
self.itemDefinitions = [:]
|
leftIdentifiers = []
|
||||||
self.items = [:]
|
centerItems = []
|
||||||
self.leftIdentifiers = []
|
rightIdentifiers = []
|
||||||
self.centerItems = []
|
|
||||||
self.rightIdentifiers = []
|
loadItemDefinitions(jsonItems: jsonItems)
|
||||||
|
createItems()
|
||||||
self.loadItemDefinitions(jsonItems: jsonItems)
|
|
||||||
self.createItems()
|
|
||||||
|
|
||||||
centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
||||||
return items[identifier]
|
items[identifier]
|
||||||
})
|
})
|
||||||
|
|
||||||
self.centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||||
self.scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)
|
scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)
|
||||||
|
|
||||||
TouchBarController.shared.touchBar.delegate = self
|
TouchBarController.shared.touchBar.delegate = self
|
||||||
TouchBarController.shared.touchBar.defaultItemIdentifiers = []
|
TouchBarController.shared.touchBar.defaultItemIdentifiers = []
|
||||||
TouchBarController.shared.touchBar.defaultItemIdentifiers = self.leftIdentifiers + [centerScrollArea] + self.rightIdentifiers
|
TouchBarController.shared.touchBar.defaultItemIdentifiers = leftIdentifiers + [centerScrollArea] + rightIdentifiers
|
||||||
|
|
||||||
if TouchBarController.shared.controlStripState {
|
if TouchBarController.shared.showControlStripState {
|
||||||
presentSystemModal(TouchBarController.shared.touchBar, systemTrayItemIdentifier: .controlStripItem)
|
presentSystemModal(TouchBarController.shared.touchBar, systemTrayItemIdentifier: .controlStripItem)
|
||||||
} else {
|
} else {
|
||||||
presentSystemModal(TouchBarController.shared.touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
|
presentSystemModal(TouchBarController.shared.touchBar, placement: 1, systemTrayItemIdentifier: .controlStripItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
func touchBar(_: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
||||||
if identifier == centerScrollArea {
|
if identifier == centerScrollArea {
|
||||||
return self.scrollArea
|
return scrollArea
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let item = self.items[identifier],
|
guard let item = self.items[identifier],
|
||||||
let definition = self.itemDefinitions[identifier],
|
let definition = self.itemDefinitions[identifier],
|
||||||
definition.align != .center else {
|
definition.align != .center else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadItemDefinitions(jsonItems: [BarItemDefinition]) {
|
func loadItemDefinitions(jsonItems: [BarItemDefinition]) {
|
||||||
let dateFormatter = DateFormatter()
|
let dateFormatter = DateFormatter()
|
||||||
dateFormatter.dateFormat = "HH-mm-ss"
|
dateFormatter.dateFormat = "HH-mm-ss"
|
||||||
@@ -94,10 +91,10 @@ class GroupBarItem: NSPopoverTouchBarItem, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createItems() {
|
func createItems() {
|
||||||
for (identifier, definition) in self.itemDefinitions {
|
for (identifier, definition) in itemDefinitions {
|
||||||
self.items[identifier] = TouchBarController.shared.createItem(forIdentifier: identifier, definition: definition)
|
items[identifier] = TouchBarController.shared.createItem(forIdentifier: identifier, definition: definition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,33 +9,32 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class InputSourceBarItem: CustomButtonTouchBarItem {
|
class InputSourceBarItem: CustomButtonTouchBarItem {
|
||||||
|
|
||||||
fileprivate var notificationCenter: CFNotificationCenter
|
fileprivate var notificationCenter: CFNotificationCenter
|
||||||
let buttonSize = NSSize(width: 21, height: 21)
|
let buttonSize = NSSize(width: 21, height: 21)
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier) {
|
init(identifier: NSTouchBarItem.Identifier) {
|
||||||
notificationCenter = CFNotificationCenterGetDistributedCenter();
|
notificationCenter = CFNotificationCenterGetDistributedCenter()
|
||||||
super.init(identifier: identifier, title: "⏳")
|
super.init(identifier: identifier, title: "⏳")
|
||||||
|
|
||||||
observeIputSourceChangedNotification();
|
observeIputSourceChangedNotification()
|
||||||
textInputSourceDidChange()
|
textInputSourceDidChange()
|
||||||
self.tapClosure = { [weak self] in
|
tapClosure = { [weak self] in
|
||||||
self?.switchInputSource()
|
self?.switchInputSource()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
CFNotificationCenterRemoveEveryObserver(notificationCenter, UnsafeRawPointer(Unmanaged.passUnretained(self).toOpaque()));
|
CFNotificationCenterRemoveEveryObserver(notificationCenter, UnsafeRawPointer(Unmanaged.passUnretained(self).toOpaque()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func textInputSourceDidChange() {
|
@objc public func textInputSourceDidChange() {
|
||||||
let currentSource = TISCopyCurrentKeyboardInputSource().takeUnretainedValue()
|
let currentSource = TISCopyCurrentKeyboardInputSource().takeUnretainedValue()
|
||||||
|
|
||||||
var iconImage: NSImage? = nil
|
var iconImage: NSImage?
|
||||||
|
|
||||||
if let imageURL = currentSource.iconImageURL,
|
if let imageURL = currentSource.iconImageURL,
|
||||||
let image = NSImage(contentsOf: imageURL) {
|
let image = NSImage(contentsOf: imageURL) {
|
||||||
@@ -46,10 +45,10 @@ class InputSourceBarItem: CustomButtonTouchBarItem {
|
|||||||
|
|
||||||
if let iconImage = iconImage {
|
if let iconImage = iconImage {
|
||||||
iconImage.size = buttonSize
|
iconImage.size = buttonSize
|
||||||
self.image = iconImage
|
image = iconImage
|
||||||
self.title = ""
|
title = ""
|
||||||
} else {
|
} else {
|
||||||
self.title = currentSource.name
|
title = currentSource.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,15 +64,15 @@ class InputSourceBarItem: CustomButtonTouchBarItem {
|
|||||||
})
|
})
|
||||||
|
|
||||||
for item in inputSources {
|
for item in inputSources {
|
||||||
if (item.id != currentSource.id) {
|
if item.id != currentSource.id {
|
||||||
TISSelectInputSource(item)
|
TISSelectInputSource(item)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func observeIputSourceChangedNotification(){
|
@objc public func observeIputSourceChangedNotification() {
|
||||||
let callback: CFNotificationCallback = { center, observer, name, object, info in
|
let callback: CFNotificationCallback = { _, observer, _, _, _ in
|
||||||
let mySelf = Unmanaged<InputSourceBarItem>.fromOpaque(observer!).takeUnretainedValue()
|
let mySelf = Unmanaged<InputSourceBarItem>.fromOpaque(observer!).takeUnretainedValue()
|
||||||
mySelf.textInputSourceDidChange()
|
mySelf.textInputSourceDidChange()
|
||||||
}
|
}
|
||||||
@@ -96,7 +95,7 @@ extension TISInputSource {
|
|||||||
|
|
||||||
private func getProperty(_ key: CFString) -> AnyObject? {
|
private func getProperty(_ key: CFString) -> AnyObject? {
|
||||||
let cfType = TISGetInputSourceProperty(self, key)
|
let cfType = TISGetInputSourceProperty(self, key)
|
||||||
if (cfType != nil) {
|
if cfType != nil {
|
||||||
return Unmanaged<AnyObject>.fromOpaque(cfType!).takeUnretainedValue()
|
return Unmanaged<AnyObject>.fromOpaque(cfType!).takeUnretainedValue()
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
@@ -131,4 +130,3 @@ extension TISInputSource {
|
|||||||
return OpaquePointer(TISGetInputSourceProperty(self, kTISPropertyIconRef)) as IconRef?
|
return OpaquePointer(TISGetInputSourceProperty(self, kTISPropertyIconRef)) as IconRef?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,61 +10,72 @@ import Cocoa
|
|||||||
import ScriptingBridge
|
import ScriptingBridge
|
||||||
|
|
||||||
class MusicBarItem: CustomButtonTouchBarItem {
|
class MusicBarItem: CustomButtonTouchBarItem {
|
||||||
private let interval: TimeInterval
|
private enum Player: String {
|
||||||
private var songTitle: String?
|
case iTunes = "com.apple.iTunes"
|
||||||
private var timer: Timer?
|
case Spotify = "com.spotify.client"
|
||||||
let buttonSize = NSSize(width: 21, height: 21)
|
case VOX = "com.coppertino.Vox"
|
||||||
|
case Chrome = "com.google.Chrome"
|
||||||
|
case Safari = "com.apple.Safari"
|
||||||
|
}
|
||||||
|
|
||||||
let playerBundleIdentifiers = [
|
private let playerBundleIdentifiers = [
|
||||||
"com.apple.iTunes",
|
Player.iTunes,
|
||||||
"com.spotify.client",
|
Player.Spotify,
|
||||||
"com.coppertino.Vox",
|
Player.VOX,
|
||||||
"com.google.Chrome",
|
Player.Chrome,
|
||||||
"com.apple.Safari"
|
Player.Safari,
|
||||||
]
|
]
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval) {
|
private let interval: TimeInterval
|
||||||
self.interval = interval
|
private let disableMarquee: Bool
|
||||||
|
private var songTitle: String?
|
||||||
super.init(identifier: identifier, title: "⏳")
|
private var timer: Timer?
|
||||||
self.isBordered = false
|
private let iconSize = NSSize(width: 21, height: 21)
|
||||||
|
|
||||||
self.tapClosure = { [weak self] in self?.playPause() }
|
|
||||||
self.longTapClosure = { [weak self] in self?.nextTrack() }
|
|
||||||
|
|
||||||
self.refreshAndSchedule()
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func marquee(){
|
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, disableMarquee: Bool) {
|
||||||
let str = self.title
|
self.interval = interval
|
||||||
if (str.count > 10) {
|
self.disableMarquee = disableMarquee
|
||||||
|
|
||||||
|
super.init(identifier: identifier, title: "⏳")
|
||||||
|
isBordered = false
|
||||||
|
|
||||||
|
tapClosure = { [weak self] in self?.playPause() }
|
||||||
|
longTapClosure = { [weak self] in self?.nextTrack() }
|
||||||
|
|
||||||
|
refreshAndSchedule()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func marquee() {
|
||||||
|
let str = title
|
||||||
|
if str.count > 10 {
|
||||||
let indexFirst = str.index(str.startIndex, offsetBy: 0)
|
let indexFirst = str.index(str.startIndex, offsetBy: 0)
|
||||||
let indexSecond = str.index(str.startIndex, offsetBy: 1)
|
let indexSecond = str.index(str.startIndex, offsetBy: 1)
|
||||||
self.title = String(str.suffix(from: indexSecond)) + String(str[indexFirst])
|
title = String(str.suffix(from: indexSecond)) + String(str[indexFirst])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func playPause() {
|
@objc func playPause() {
|
||||||
for ident in playerBundleIdentifiers {
|
for ident in playerBundleIdentifiers {
|
||||||
if let musicPlayer = SBApplication(bundleIdentifier: ident) {
|
if let musicPlayer = SBApplication(bundleIdentifier: ident.rawValue) {
|
||||||
if (musicPlayer.isRunning) {
|
if musicPlayer.isRunning {
|
||||||
if (musicPlayer.className == "SpotifyApplication") {
|
if ident == .Spotify {
|
||||||
let mp = (musicPlayer as SpotifyApplication)
|
let mp = (musicPlayer as SpotifyApplication)
|
||||||
mp.playpause!()
|
mp.playpause!()
|
||||||
return
|
return
|
||||||
} else if (musicPlayer.className == "ITunesApplication") {
|
} else if ident == .iTunes {
|
||||||
let mp = (musicPlayer as iTunesApplication)
|
let mp = (musicPlayer as iTunesApplication)
|
||||||
mp.playpause!()
|
mp.playpause!()
|
||||||
return
|
return
|
||||||
} else if (musicPlayer.className == "VOXApplication") {
|
} else if ident == .VOX {
|
||||||
let mp = (musicPlayer as VoxApplication)
|
let mp = (musicPlayer as VoxApplication)
|
||||||
mp.playpause!()
|
mp.playpause!()
|
||||||
return
|
return
|
||||||
} else if (musicPlayer.className == "SafariApplication") {
|
} else if ident == .Safari {
|
||||||
// You must enable the 'Allow JavaScript from Apple Events' option in Safari's Develop menu to use 'do JavaScript'.
|
// You must enable the 'Allow JavaScript from Apple Events' option in Safari's Develop menu to use 'do JavaScript'.
|
||||||
let safariApplication = musicPlayer as SafariApplication
|
let safariApplication = musicPlayer as SafariApplication
|
||||||
let safariWindows = safariApplication.windows?().compactMap({ $0 as? SafariWindow })
|
let safariWindows = safariApplication.windows?().compactMap({ $0 as? SafariWindow })
|
||||||
@@ -74,7 +85,7 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
if (tab.URL?.starts(with: "https://music.yandex.ru"))! {
|
if (tab.URL?.starts(with: "https://music.yandex.ru"))! {
|
||||||
_ = safariApplication.doJavaScript!("document.getElementsByClassName('player-controls__btn_play')[0].click()", in: tab)
|
_ = safariApplication.doJavaScript!("document.getElementsByClassName('player-controls__btn_play')[0].click()", in: tab)
|
||||||
return
|
return
|
||||||
} else if ((tab.URL?.starts(with: "https://vk.com/audios"))! || (tab.URL?.starts(with: "https://vk.com/music"))!) {
|
} 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_play')[0].click()", in: tab)
|
_ = safariApplication.doJavaScript!("document.getElementsByClassName('audio_page_player_play')[0].click()", in: tab)
|
||||||
return
|
return
|
||||||
} else if (tab.URL?.starts(with: "https://www.youtube.com/watch"))! {
|
} else if (tab.URL?.starts(with: "https://www.youtube.com/watch"))! {
|
||||||
@@ -84,7 +95,7 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else if (musicPlayer.className == "GoogleChromeApplication") {
|
// else if (ident == .Chrome) {
|
||||||
// let chromeApplication = musicPlayer as GoogleChromeApplication
|
// let chromeApplication = musicPlayer as GoogleChromeApplication
|
||||||
// let chromeWindows = chromeApplication.windows?().compactMap({ $0 as? GoogleChromeWindow })
|
// let chromeWindows = chromeApplication.windows?().compactMap({ $0 as? GoogleChromeWindow })
|
||||||
// for window in chromeWindows! {
|
// for window in chromeWindows! {
|
||||||
@@ -108,27 +119,27 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func nextTrack() {
|
@objc func nextTrack() {
|
||||||
for ident in playerBundleIdentifiers {
|
for ident in playerBundleIdentifiers {
|
||||||
if let musicPlayer = SBApplication(bundleIdentifier: ident) {
|
if let musicPlayer = SBApplication(bundleIdentifier: ident.rawValue) {
|
||||||
if (musicPlayer.isRunning) {
|
if musicPlayer.isRunning {
|
||||||
if (musicPlayer.className == "SpotifyApplication") {
|
if ident == .Spotify {
|
||||||
let mp = (musicPlayer as SpotifyApplication)
|
let mp = (musicPlayer as SpotifyApplication)
|
||||||
mp.nextTrack!()
|
mp.nextTrack!()
|
||||||
updatePlayer()
|
updatePlayer()
|
||||||
return
|
return
|
||||||
} else if (musicPlayer.className == "ITunesApplication") {
|
} else if ident == .iTunes {
|
||||||
let mp = (musicPlayer as iTunesApplication)
|
let mp = (musicPlayer as iTunesApplication)
|
||||||
mp.nextTrack!()
|
mp.nextTrack!()
|
||||||
updatePlayer()
|
updatePlayer()
|
||||||
return
|
return
|
||||||
} else if (musicPlayer.className == "VOXApplication") {
|
} else if ident == .VOX {
|
||||||
let mp = (musicPlayer as VoxApplication)
|
let mp = (musicPlayer as VoxApplication)
|
||||||
mp.next!()
|
mp.next!()
|
||||||
updatePlayer()
|
updatePlayer()
|
||||||
return
|
return
|
||||||
} else if (musicPlayer.className == "SafariApplication") {
|
} else if ident == .Safari {
|
||||||
// You must enable the 'Allow JavaScript from Apple Events' option in Safari's Develop menu to use 'do JavaScript'.
|
// You must enable the 'Allow JavaScript from Apple Events' option in Safari's Develop menu to use 'do JavaScript'.
|
||||||
let safariApplication = musicPlayer as SafariApplication
|
let safariApplication = musicPlayer as SafariApplication
|
||||||
let safariWindows = safariApplication.windows?().compactMap({ $0 as? SafariWindow })
|
let safariWindows = safariApplication.windows?().compactMap({ $0 as? SafariWindow })
|
||||||
@@ -139,7 +150,7 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
_ = safariApplication.doJavaScript!("document.getElementsByClassName('player-controls__btn_next')[0].click()", in: tab)
|
_ = safariApplication.doJavaScript!("document.getElementsByClassName('player-controls__btn_next')[0].click()", in: tab)
|
||||||
updatePlayer()
|
updatePlayer()
|
||||||
return
|
return
|
||||||
} else if ((tab.URL?.starts(with: "https://vk.com/audios"))! || (tab.URL?.starts(with: "https://vk.com/music"))!) {
|
} 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)
|
_ = safariApplication.doJavaScript!("document.getElementsByClassName('audio_page_player_next')[0].click()", in: tab)
|
||||||
updatePlayer()
|
updatePlayer()
|
||||||
return
|
return
|
||||||
@@ -155,7 +166,7 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshAndSchedule() {
|
func refreshAndSchedule() {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.updatePlayer()
|
self.updatePlayer()
|
||||||
@@ -164,22 +175,22 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updatePlayer() {
|
func updatePlayer() {
|
||||||
var iconUpdated = false
|
var iconUpdated = false
|
||||||
var titleUpdated = false
|
var titleUpdated = false
|
||||||
|
|
||||||
for var ident in playerBundleIdentifiers {
|
for var ident in playerBundleIdentifiers {
|
||||||
if let musicPlayer = SBApplication(bundleIdentifier: ident) {
|
if let musicPlayer = SBApplication(bundleIdentifier: ident.rawValue) {
|
||||||
if (musicPlayer.isRunning) {
|
if musicPlayer.isRunning {
|
||||||
var tempTitle = ""
|
var tempTitle = ""
|
||||||
if (musicPlayer.className == "SpotifyApplication") {
|
if ident == .Spotify {
|
||||||
tempTitle = (musicPlayer as SpotifyApplication).title
|
tempTitle = (musicPlayer as SpotifyApplication).title
|
||||||
} else if (musicPlayer.className == "ITunesApplication") {
|
} else if ident == .iTunes {
|
||||||
tempTitle = (musicPlayer as iTunesApplication).title
|
tempTitle = (musicPlayer as iTunesApplication).title
|
||||||
} else if (musicPlayer.className == "VOXApplication") {
|
} else if ident == .VOX {
|
||||||
tempTitle = (musicPlayer as VoxApplication).title
|
tempTitle = (musicPlayer as VoxApplication).title
|
||||||
} else if (musicPlayer.className == "SafariApplication") {
|
} else if ident == .Safari {
|
||||||
let safariApplication = musicPlayer as SafariApplication
|
let safariApplication = musicPlayer as SafariApplication
|
||||||
let safariWindows = safariApplication.windows?().compactMap({ $0 as? SafariWindow })
|
let safariWindows = safariApplication.windows?().compactMap({ $0 as? SafariWindow })
|
||||||
for window in safariWindows! {
|
for window in safariWindows! {
|
||||||
@@ -190,7 +201,7 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
tempTitle = (tab.name)!
|
tempTitle = (tab.name)!
|
||||||
break
|
break
|
||||||
// }
|
// }
|
||||||
} else if ((tab.URL?.starts(with: "https://vk.com/audios"))! || (tab.URL?.starts(with: "https://vk.com/music"))!) {
|
} else if (tab.URL?.starts(with: "https://vk.com/audios"))! || (tab.URL?.starts(with: "https://vk.com/music"))! {
|
||||||
tempTitle = (tab.name)!
|
tempTitle = (tab.name)!
|
||||||
break
|
break
|
||||||
} else if (tab.URL?.starts(with: "https://www.youtube.com/watch"))! {
|
} else if (tab.URL?.starts(with: "https://www.youtube.com/watch"))! {
|
||||||
@@ -199,21 +210,18 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if tempTitle == "" {
|
} else if ident == .Chrome {
|
||||||
ident = ""
|
|
||||||
}
|
|
||||||
} else if (musicPlayer.className == "GoogleChromeApplication") {
|
|
||||||
let chromeApplication = musicPlayer as GoogleChromeApplication
|
let chromeApplication = musicPlayer as GoogleChromeApplication
|
||||||
let chromeWindows = chromeApplication.windows?().compactMap({ $0 as? GoogleChromeWindow })
|
let chromeWindows = chromeApplication.windows?().compactMap({ $0 as? GoogleChromeWindow })
|
||||||
for window in chromeWindows! {
|
for window in chromeWindows! {
|
||||||
for tab in window.tabs!() {
|
for tab in window.tabs!() {
|
||||||
let tab = tab as! GoogleChromeTab
|
let tab = tab as! GoogleChromeTab
|
||||||
if (tab.URL?.starts(with: "https://music.yandex.ru"))! {
|
if (tab.URL?.starts(with: "https://music.yandex.ru"))! {
|
||||||
if (!(tab.title?.hasSuffix("на Яндекс.Музыке"))!) {
|
if !(tab.title?.hasSuffix("на Яндекс.Музыке"))! {
|
||||||
tempTitle = tab.title!
|
tempTitle = tab.title!
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if ((tab.URL?.starts(with: "https://vk.com/audios"))! || (tab.URL?.starts(with: "https://vk.com/music"))!) {
|
} else if (tab.URL?.starts(with: "https://vk.com/audios"))! || (tab.URL?.starts(with: "https://vk.com/music"))! {
|
||||||
tempTitle = tab.title!
|
tempTitle = tab.title!
|
||||||
break
|
break
|
||||||
} else if (tab.URL?.starts(with: "https://www.youtube.com/watch"))! {
|
} else if (tab.URL?.starts(with: "https://www.youtube.com/watch"))! {
|
||||||
@@ -222,28 +230,31 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if tempTitle == "" {
|
|
||||||
ident = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempTitle == self.songTitle) {
|
if tempTitle == self.songTitle {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
self.songTitle = tempTitle
|
self.songTitle = tempTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
if let songTitle = self.songTitle?.ifNotEmpty {
|
if let songTitle = self.songTitle?.ifNotEmpty {
|
||||||
self.title = " " + songTitle + " "
|
|
||||||
titleUpdated = true
|
|
||||||
self.timer?.invalidate()
|
self.timer?.invalidate()
|
||||||
self.timer = nil
|
self.timer = nil
|
||||||
self.timer = Timer.scheduledTimer(timeInterval: 0.25, target: self, selector: #selector(self.marquee), userInfo: nil, repeats: true)
|
|
||||||
|
if (disableMarquee) {
|
||||||
|
self.title = " " + songTitle
|
||||||
|
} else {
|
||||||
|
self.title = " " + songTitle + " "
|
||||||
|
self.timer = Timer.scheduledTimer(timeInterval: 0.25, target: self, selector: #selector(self.marquee), userInfo: nil, repeats: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
titleUpdated = true
|
||||||
}
|
}
|
||||||
if let ident = ident.ifNotEmpty,
|
if let _ = tempTitle.ifNotEmpty,
|
||||||
let appPath = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: ident) {
|
let appPath = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: ident.rawValue) {
|
||||||
let image = NSWorkspace.shared.icon(forFile: appPath)
|
let image = NSWorkspace.shared.icon(forFile: appPath)
|
||||||
image.size = self.buttonSize
|
image.size = self.iconSize
|
||||||
self.image = image
|
self.image = image
|
||||||
iconUpdated = true
|
iconUpdated = true
|
||||||
}
|
}
|
||||||
@@ -251,12 +262,12 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if !iconUpdated {
|
if !iconUpdated {
|
||||||
self.image = nil
|
self.image = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !titleUpdated {
|
if !titleUpdated {
|
||||||
self.title = ""
|
self.title = ""
|
||||||
}
|
}
|
||||||
@@ -265,18 +276,20 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc protocol SpotifyApplication {
|
@objc protocol SpotifyApplication {
|
||||||
@objc optional var currentTrack: SpotifyTrack {get}
|
@objc optional var currentTrack: SpotifyTrack { get }
|
||||||
@objc optional func nextTrack()
|
@objc optional func nextTrack()
|
||||||
@objc optional func previousTrack()
|
@objc optional func previousTrack()
|
||||||
@objc optional func playpause()
|
@objc optional func playpause()
|
||||||
}
|
}
|
||||||
extension SBApplication: SpotifyApplication{}
|
|
||||||
|
extension SBApplication: SpotifyApplication {}
|
||||||
|
|
||||||
@objc protocol SpotifyTrack {
|
@objc protocol SpotifyTrack {
|
||||||
@objc optional var artist: String {get}
|
@objc optional var artist: String { get }
|
||||||
@objc optional var name: String {get}
|
@objc optional var name: String { get }
|
||||||
}
|
}
|
||||||
extension SBObject: SpotifyTrack{}
|
|
||||||
|
extension SBObject: SpotifyTrack {}
|
||||||
|
|
||||||
extension SpotifyApplication {
|
extension SpotifyApplication {
|
||||||
var title: String {
|
var title: String {
|
||||||
@@ -285,20 +298,21 @@ extension SpotifyApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@objc protocol iTunesApplication {
|
@objc protocol iTunesApplication {
|
||||||
@objc optional var currentTrack: iTunesTrack {get}
|
@objc optional var currentTrack: iTunesTrack { get }
|
||||||
@objc optional func playpause()
|
@objc optional func playpause()
|
||||||
@objc optional func nextTrack()
|
@objc optional func nextTrack()
|
||||||
@objc optional func previousTrack()
|
@objc optional func previousTrack()
|
||||||
}
|
}
|
||||||
extension SBApplication: iTunesApplication{}
|
|
||||||
|
extension SBApplication: iTunesApplication {}
|
||||||
|
|
||||||
@objc protocol iTunesTrack {
|
@objc protocol iTunesTrack {
|
||||||
@objc optional var artist: String {get}
|
@objc optional var artist: String { get }
|
||||||
@objc optional var name: String {get}
|
@objc optional var name: String { get }
|
||||||
}
|
}
|
||||||
extension SBObject: iTunesTrack{}
|
|
||||||
|
extension SBObject: iTunesTrack {}
|
||||||
|
|
||||||
extension iTunesApplication {
|
extension iTunesApplication {
|
||||||
var title: String {
|
var title: String {
|
||||||
@@ -307,16 +321,15 @@ extension iTunesApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@objc protocol VoxApplication {
|
@objc protocol VoxApplication {
|
||||||
@objc optional func playpause()
|
@objc optional func playpause()
|
||||||
@objc optional func next()
|
@objc optional func next()
|
||||||
@objc optional func previous()
|
@objc optional func previous()
|
||||||
@objc optional var track: String {get}
|
@objc optional var track: String { get }
|
||||||
@objc optional var artist: String {get}
|
@objc optional var artist: String { get }
|
||||||
}
|
}
|
||||||
extension SBApplication: VoxApplication{}
|
|
||||||
|
extension SBApplication: VoxApplication {}
|
||||||
|
|
||||||
extension VoxApplication {
|
extension VoxApplication {
|
||||||
var title: String {
|
var title: String {
|
||||||
@@ -324,7 +337,6 @@ extension VoxApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@objc public protocol SBObjectProtocol: NSObjectProtocol {
|
@objc public protocol SBObjectProtocol: NSObjectProtocol {
|
||||||
func get() -> Any!
|
func get() -> Any!
|
||||||
}
|
}
|
||||||
@@ -338,6 +350,7 @@ extension VoxApplication {
|
|||||||
@objc optional func windows() -> SBElementArray
|
@objc optional func windows() -> SBElementArray
|
||||||
@objc optional func doJavaScript(_ x: String!, in in_: Any!) -> Any // Applies a string of JavaScript code to a document.
|
@objc optional func doJavaScript(_ x: String!, in in_: Any!) -> Any // Applies a string of JavaScript code to a document.
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SBApplication: SafariApplication {}
|
extension SBApplication: SafariApplication {}
|
||||||
|
|
||||||
@objc public protocol SafariWindow: SBObjectProtocol {
|
@objc public protocol SafariWindow: SBObjectProtocol {
|
||||||
@@ -346,36 +359,39 @@ extension SBApplication: SafariApplication {}
|
|||||||
// @objc optional var document: SafariDocument { get } // The document whose contents are displayed in the window.
|
// @objc optional var document: SafariDocument { get } // The document whose contents are displayed in the window.
|
||||||
// @objc optional func setCurrentTab(_ currentTab: SafariTab!) // The current tab.
|
// @objc optional func setCurrentTab(_ currentTab: SafariTab!) // The current tab.
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SBObject: SafariWindow {}
|
extension SBObject: SafariWindow {}
|
||||||
|
|
||||||
//@objc public protocol SafariDocument: SBObjectProtocol {
|
// @objc public protocol SafariDocument: SBObjectProtocol {
|
||||||
// @objc optional var name: String { get } // Its name.
|
// @objc optional var name: String { get } // Its name.
|
||||||
// @objc optional var URL: String { get } // The current URL of the document.
|
// @objc optional var URL: String { get } // The current URL of the document.
|
||||||
//}
|
// }
|
||||||
//extension SBObject: SafariDocument {}
|
// extension SBObject: SafariDocument {}
|
||||||
|
|
||||||
@objc public protocol SafariTab: SBObjectProtocol {
|
@objc public protocol SafariTab: SBObjectProtocol {
|
||||||
@objc optional var URL: String { get } // The current URL of the tab.
|
@objc optional var URL: String { get } // The current URL of the tab.
|
||||||
@objc optional var name: String { get } // The name of the tab.
|
@objc optional var name: String { get } // The name of the tab.
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SBObject: SafariTab {}
|
extension SBObject: SafariTab {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@objc public protocol GoogleChromeApplication: SBApplicationProtocol {
|
@objc public protocol GoogleChromeApplication: SBApplicationProtocol {
|
||||||
@objc optional func windows() -> SBElementArray
|
@objc optional func windows() -> SBElementArray
|
||||||
@objc optional func executeJavaScript(javascript: String!) -> Any // Applies a string of JavaScript code to a document. //, id: Any!
|
@objc optional func executeJavaScript(javascript: String!) -> Any // Applies a string of JavaScript code to a document. //, id: Any!
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SBApplication: GoogleChromeApplication {}
|
extension SBApplication: GoogleChromeApplication {}
|
||||||
|
|
||||||
@objc public protocol GoogleChromeWindow: SBObjectProtocol {
|
@objc public protocol GoogleChromeWindow: SBObjectProtocol {
|
||||||
@objc optional var name: String { get } // The title of the window.
|
@objc optional var name: String { get } // The title of the window.
|
||||||
@objc optional func tabs() -> SBElementArray
|
@objc optional func tabs() -> SBElementArray
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SBObject: GoogleChromeWindow {}
|
extension SBObject: GoogleChromeWindow {}
|
||||||
|
|
||||||
@objc public protocol GoogleChromeTab: SBObjectProtocol {
|
@objc public protocol GoogleChromeTab: SBObjectProtocol {
|
||||||
@objc optional var URL: String { get } // The current URL of the tab.
|
@objc optional var URL: String { get } // The current URL of the tab.
|
||||||
@objc optional var title: String { get } // The name of the tab.
|
@objc optional var title: String { get } // The name of the tab.
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SBObject: GoogleChromeTab {}
|
extension SBObject: GoogleChromeTab {}
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
//
|
||||||
|
// NetworkBarItem.swift
|
||||||
|
// MTMR
|
||||||
|
//
|
||||||
|
// Created by Anton Palgunov on 23/02/2019.
|
||||||
|
// Copyright © 2019 Anton Palgunov. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class NetworkBarItem: CustomButtonTouchBarItem, Widget {
|
||||||
|
static var name: String = "network"
|
||||||
|
static var identifier: String = "com.toxblh.mtmr.network"
|
||||||
|
|
||||||
|
private let flip: Bool
|
||||||
|
|
||||||
|
init(identifier: NSTouchBarItem.Identifier, flip: Bool = false) {
|
||||||
|
self.flip = flip
|
||||||
|
super.init(identifier: identifier, title: " ")
|
||||||
|
startMonitoringProcess()
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder _: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func startMonitoringProcess() {
|
||||||
|
var pipe: Pipe
|
||||||
|
var outputHandle: FileHandle
|
||||||
|
var bandwidthProcess: Process?
|
||||||
|
var dSpeed: UInt64?
|
||||||
|
var uSpeed: UInt64?
|
||||||
|
var curr: Array<Substring>?
|
||||||
|
var dataAvailable: NSObjectProtocol!
|
||||||
|
|
||||||
|
pipe = Pipe()
|
||||||
|
bandwidthProcess = Process()
|
||||||
|
bandwidthProcess?.launchPath = "/usr/bin/env"
|
||||||
|
bandwidthProcess?.arguments = ["netstat", "-w1", "-l", "en0"]
|
||||||
|
bandwidthProcess?.standardOutput = pipe
|
||||||
|
|
||||||
|
outputHandle = pipe.fileHandleForReading
|
||||||
|
outputHandle.waitForDataInBackgroundAndNotify(forModes: [RunLoop.Mode.common])
|
||||||
|
|
||||||
|
dataAvailable = NotificationCenter.default.addObserver(
|
||||||
|
forName: NSNotification.Name.NSFileHandleDataAvailable,
|
||||||
|
object: outputHandle,
|
||||||
|
queue: nil
|
||||||
|
) { _ -> Void in
|
||||||
|
let data = pipe.fileHandleForReading.availableData
|
||||||
|
if data.count > 0 {
|
||||||
|
if let str = NSString(data: data, encoding: String.Encoding.utf8.rawValue) {
|
||||||
|
curr = [""]
|
||||||
|
curr = str
|
||||||
|
.replacingOccurrences(of: " ", with: " ")
|
||||||
|
.split(separator: " ")
|
||||||
|
if curr == nil || (curr?.count)! < 6 {} else {
|
||||||
|
if Int64(curr![2]) == nil {} else {
|
||||||
|
dSpeed = UInt64(curr![2])
|
||||||
|
uSpeed = UInt64(curr![5])
|
||||||
|
|
||||||
|
self.setTitle(up: self.getHumanizeSize(speed: uSpeed!), down: self.getHumanizeSize(speed: dSpeed!))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outputHandle.waitForDataInBackgroundAndNotify()
|
||||||
|
} else {
|
||||||
|
NotificationCenter.default.removeObserver(dataAvailable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataReady: NSObjectProtocol!
|
||||||
|
dataReady = NotificationCenter.default.addObserver(
|
||||||
|
forName: Process.didTerminateNotification,
|
||||||
|
object: outputHandle,
|
||||||
|
queue: nil
|
||||||
|
) { _ -> Void in
|
||||||
|
print("Task terminated!")
|
||||||
|
NotificationCenter.default.removeObserver(dataReady)
|
||||||
|
}
|
||||||
|
|
||||||
|
bandwidthProcess?.launch()
|
||||||
|
}
|
||||||
|
|
||||||
|
func getHumanizeSize(speed: UInt64) -> String {
|
||||||
|
let humanText: String
|
||||||
|
|
||||||
|
if speed < 1024 {
|
||||||
|
humanText = String(format: "%.0f", Double(speed)) + " B/s"
|
||||||
|
} else if speed < (1024 * 1024) {
|
||||||
|
humanText = String(format: "%.1f", Double(speed) / 1024) + " KB/s"
|
||||||
|
} else if speed < (1024 * 1024 * 1024) {
|
||||||
|
humanText = String(format: "%.1f", Double(speed) / (1024 * 1024)) + " MB/s"
|
||||||
|
} else {
|
||||||
|
humanText = String(format: "%.2f", Double(speed) / (1024 * 1024 * 1024)) + " GB/s"
|
||||||
|
}
|
||||||
|
|
||||||
|
return humanText
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendUpSpeed(appendString: NSMutableAttributedString, up: String, titleFont: NSFont, newStr: Bool = false) {
|
||||||
|
appendString.append(NSMutableAttributedString(
|
||||||
|
string: newStr ? "\n↑" : "↑",
|
||||||
|
attributes: [
|
||||||
|
NSAttributedString.Key.foregroundColor: NSColor.blue,
|
||||||
|
NSAttributedString.Key.font: titleFont,
|
||||||
|
]))
|
||||||
|
|
||||||
|
appendString.append(NSMutableAttributedString(
|
||||||
|
string: up,
|
||||||
|
attributes: [
|
||||||
|
NSAttributedString.Key.font: titleFont,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendDownSpeed(appendString: NSMutableAttributedString, down: String, titleFont: NSFont, newStr: Bool = false) {
|
||||||
|
appendString.append(NSMutableAttributedString(
|
||||||
|
string: newStr ? "\n↓" : "↓",
|
||||||
|
attributes: [
|
||||||
|
NSAttributedString.Key.foregroundColor: NSColor.red,
|
||||||
|
NSAttributedString.Key.font: titleFont,
|
||||||
|
]))
|
||||||
|
|
||||||
|
appendString.append(NSMutableAttributedString(
|
||||||
|
string: down,
|
||||||
|
attributes: [
|
||||||
|
NSAttributedString.Key.font: titleFont
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTitle(up: String, down: String) {
|
||||||
|
let titleFont = NSFont.monospacedDigitSystemFont(ofSize: 12, weight: NSFont.Weight.light)
|
||||||
|
|
||||||
|
let newTitle: NSMutableAttributedString = NSMutableAttributedString(string: "")
|
||||||
|
|
||||||
|
if (self.flip) {
|
||||||
|
appendUpSpeed(appendString: newTitle, up: up, titleFont: titleFont)
|
||||||
|
appendDownSpeed(appendString: newTitle, down: down, titleFont: titleFont, newStr: true)
|
||||||
|
} else {
|
||||||
|
appendDownSpeed(appendString: newTitle, down: down, titleFont: titleFont)
|
||||||
|
appendUpSpeed(appendString: newTitle, up: up, titleFont: titleFont, newStr: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
self.attributedTitle = newTitle
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 blueLightStatus.enabled.boolValue
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setNightShift(state: Bool) {
|
||||||
|
nsclient.setEnabled(state)
|
||||||
|
}
|
||||||
|
|
||||||
|
init(identifier: NSTouchBarItem.Identifier) {
|
||||||
|
super.init(identifier: identifier, title: "")
|
||||||
|
isBordered = false
|
||||||
|
setWidth(value: 28)
|
||||||
|
|
||||||
|
tapClosure = { [weak self] in self?.nightShiftAction() }
|
||||||
|
|
||||||
|
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(refresh), userInfo: nil, repeats: true)
|
||||||
|
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder _: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func nightShiftAction() {
|
||||||
|
setNightShift(state: !isNightShiftEnabled)
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func refresh() {
|
||||||
|
image = isNightShiftEnabled ? #imageLiteral(resourceName: "nightShiftOn") : #imageLiteral(resourceName: "nightShiftOff")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
//
|
||||||
|
// PomodoroBarItem.swift
|
||||||
|
// MTMR
|
||||||
|
//
|
||||||
|
// Created by Daniel Apatin on 10.05.2018.
|
||||||
|
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Cocoa
|
||||||
|
|
||||||
|
class PomodoroBarItem: CustomButtonTouchBarItem, Widget {
|
||||||
|
static let identifier = "com.toxblh.mtmr.pomodoro."
|
||||||
|
static let name = "pomodoro"
|
||||||
|
static let decoder: ParametersDecoder = { decoder in
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case workTime
|
||||||
|
case restTime
|
||||||
|
}
|
||||||
|
|
||||||
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
let workTime = try container.decodeIfPresent(Double.self, forKey: .workTime)
|
||||||
|
let restTime = try container.decodeIfPresent(Double.self, forKey: .restTime)
|
||||||
|
|
||||||
|
return (
|
||||||
|
item: .pomodoro(workTime: workTime ?? 1500.00, restTime: restTime ?? 300),
|
||||||
|
action: .none,
|
||||||
|
longAction: .none,
|
||||||
|
parameters: [:]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum TimeTypes {
|
||||||
|
case work
|
||||||
|
case rest
|
||||||
|
case none
|
||||||
|
}
|
||||||
|
|
||||||
|
private let defaultTitle = "🍅"
|
||||||
|
private let workTime: TimeInterval
|
||||||
|
private let restTime: TimeInterval
|
||||||
|
private var typeTime: TimeTypes = .none
|
||||||
|
private var timer: DispatchSourceTimer?
|
||||||
|
|
||||||
|
private var timeLeft: Int = 0
|
||||||
|
private var timeLeftString: String {
|
||||||
|
return String(format: "%.2i:%.2i", timeLeft / 60, timeLeft % 60)
|
||||||
|
}
|
||||||
|
|
||||||
|
init(identifier: NSTouchBarItem.Identifier, workTime: TimeInterval, restTime: TimeInterval) {
|
||||||
|
self.workTime = workTime
|
||||||
|
self.restTime = restTime
|
||||||
|
super.init(identifier: identifier, title: defaultTitle)
|
||||||
|
tapClosure = { [weak self] in self?.startStopWork() }
|
||||||
|
longTapClosure = { [weak self] in self?.startStopRest() }
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder _: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
timer?.cancel()
|
||||||
|
timer = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func startStopWork() {
|
||||||
|
typeTime = .work
|
||||||
|
startStopTimer()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func startStopRest() {
|
||||||
|
typeTime = .rest
|
||||||
|
startStopTimer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func startStopTimer() {
|
||||||
|
timer == nil ? start() : reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func start() {
|
||||||
|
timeLeft = Int(typeTime == .work ? workTime : restTime)
|
||||||
|
let queue: DispatchQueue = DispatchQueue(label: "Timer")
|
||||||
|
timer = DispatchSource.makeTimerSource(flags: .strict, queue: queue)
|
||||||
|
timer?.schedule(deadline: .now(), repeating: .seconds(1), leeway: .never)
|
||||||
|
timer?.setEventHandler(handler: tick)
|
||||||
|
timer?.resume()
|
||||||
|
|
||||||
|
NSSound.beep()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func finish() {
|
||||||
|
if typeTime != .none {
|
||||||
|
sendNotification()
|
||||||
|
}
|
||||||
|
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func reset() {
|
||||||
|
typeTime = .none
|
||||||
|
timer?.cancel()
|
||||||
|
timer = nil
|
||||||
|
title = defaultTitle
|
||||||
|
}
|
||||||
|
|
||||||
|
private func tick() {
|
||||||
|
timeLeft -= 1
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
if self.timeLeft >= 0 {
|
||||||
|
self.title = self.defaultTitle + " " + self.timeLeftString
|
||||||
|
} else {
|
||||||
|
self.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func sendNotification() {
|
||||||
|
let notification: NSUserNotification = NSUserNotification()
|
||||||
|
notification.title = "Pomodoro"
|
||||||
|
notification.informativeText = typeTime == .work ? "it's time to rest your mind!" : "It's time to work!"
|
||||||
|
notification.soundName = "Submarine"
|
||||||
|
NSUserNotificationCenter.default.deliver(notification)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,21 +3,23 @@ import Cocoa
|
|||||||
class TimeTouchBarItem: CustomButtonTouchBarItem {
|
class TimeTouchBarItem: CustomButtonTouchBarItem {
|
||||||
private let dateFormatter = DateFormatter()
|
private let dateFormatter = DateFormatter()
|
||||||
private var timer: Timer!
|
private var timer: Timer!
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, formatTemplate: String) {
|
init(identifier: NSTouchBarItem.Identifier, formatTemplate: String, timeZone: String? = nil) {
|
||||||
dateFormatter.setLocalizedDateFormatFromTemplate(formatTemplate)
|
dateFormatter.dateFormat = formatTemplate
|
||||||
|
if let abbr = timeZone {
|
||||||
|
dateFormatter.timeZone = TimeZone(abbreviation: abbr)
|
||||||
|
}
|
||||||
super.init(identifier: identifier, title: " ")
|
super.init(identifier: identifier, title: " ")
|
||||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTime), userInfo: nil, repeats: true)
|
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTime), userInfo: nil, repeats: true)
|
||||||
self.isBordered = false
|
isBordered = false
|
||||||
updateTime()
|
updateTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func updateTime() {
|
@objc func updateTime() {
|
||||||
self.title = self.dateFormatter.string(from: Date())
|
title = dateFormatter.string(from: Date())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +1,56 @@
|
|||||||
import Cocoa
|
|
||||||
import AppKit
|
import AppKit
|
||||||
import AVFoundation
|
import AVFoundation
|
||||||
|
import Cocoa
|
||||||
import CoreAudio
|
import CoreAudio
|
||||||
|
|
||||||
class VolumeViewController: NSCustomTouchBarItem {
|
class VolumeViewController: NSCustomTouchBarItem {
|
||||||
private(set) var sliderItem: CustomSlider!
|
private(set) var sliderItem: CustomSlider!
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, image: NSImage? = nil) {
|
init(identifier: NSTouchBarItem.Identifier, image: NSImage? = nil) {
|
||||||
super.init(identifier: identifier)
|
super.init(identifier: identifier)
|
||||||
|
|
||||||
var forPropertyAddress = AudioObjectPropertyAddress(
|
var forPropertyAddress = AudioObjectPropertyAddress(
|
||||||
mSelector: kAudioHardwareServiceDeviceProperty_VirtualMasterVolume,
|
mSelector: kAudioHardwareServiceDeviceProperty_VirtualMasterVolume,
|
||||||
mScope: kAudioDevicePropertyScopeOutput,
|
mScope: kAudioDevicePropertyScopeOutput,
|
||||||
mElement: kAudioObjectPropertyElementMaster)
|
mElement: kAudioObjectPropertyElementMaster
|
||||||
|
)
|
||||||
|
|
||||||
AudioObjectAddPropertyListenerBlock(defaultDeviceID, &forPropertyAddress, nil, audioObjectPropertyListenerBlock)
|
AudioObjectAddPropertyListenerBlock(defaultDeviceID, &forPropertyAddress, nil, audioObjectPropertyListenerBlock)
|
||||||
|
|
||||||
if (image == nil) {
|
if image == nil {
|
||||||
sliderItem = CustomSlider()
|
sliderItem = CustomSlider()
|
||||||
} else {
|
} else {
|
||||||
sliderItem = CustomSlider(knob: image!)
|
sliderItem = CustomSlider(knob: image!)
|
||||||
}
|
}
|
||||||
sliderItem.target = self
|
sliderItem.target = self
|
||||||
sliderItem.action = #selector(VolumeViewController.sliderValueChanged(_:))
|
sliderItem.action = #selector(VolumeViewController.sliderValueChanged(_:))
|
||||||
sliderItem.minValue = 0.0
|
sliderItem.minValue = 0.0
|
||||||
sliderItem.maxValue = 100.0
|
sliderItem.maxValue = 100.0
|
||||||
sliderItem.floatValue = getInputGain()*100
|
sliderItem.floatValue = getInputGain() * 100
|
||||||
|
|
||||||
self.view = sliderItem
|
view = sliderItem
|
||||||
}
|
}
|
||||||
|
|
||||||
func audioObjectPropertyListenerBlock (numberAddresses: UInt32, addresses: UnsafePointer<AudioObjectPropertyAddress>) {
|
func audioObjectPropertyListenerBlock(numberAddresses _: UInt32, addresses _: UnsafePointer<AudioObjectPropertyAddress>) {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.sliderItem.floatValue = self.getInputGain() * 100
|
self.sliderItem.floatValue = self.getInputGain() * 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
sliderItem.unbind(NSBindingName.value)
|
sliderItem.unbind(NSBindingName.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func sliderValueChanged(_ sender: Any) {
|
@objc func sliderValueChanged(_ sender: Any) {
|
||||||
if let sliderItem = sender as? NSSlider {
|
if let sliderItem = sender as? NSSlider {
|
||||||
_ = setInputGain(Float32(sliderItem.intValue)/100.0)
|
_ = setInputGain(Float32(sliderItem.intValue) / 100.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var defaultDeviceID: AudioObjectID {
|
private var defaultDeviceID: AudioObjectID {
|
||||||
var deviceID: AudioObjectID = AudioObjectID(0)
|
var deviceID: AudioObjectID = AudioObjectID(0)
|
||||||
var size: UInt32 = UInt32(MemoryLayout<AudioObjectID>.size)
|
var size: UInt32 = UInt32(MemoryLayout<AudioObjectID>.size)
|
||||||
@@ -60,7 +61,7 @@ class VolumeViewController: NSCustomTouchBarItem {
|
|||||||
AudioObjectGetPropertyData(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, &size, &deviceID)
|
AudioObjectGetPropertyData(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, &size, &deviceID)
|
||||||
return deviceID
|
return deviceID
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getInputGain() -> Float32 {
|
private func getInputGain() -> Float32 {
|
||||||
var volume: Float32 = 0.5
|
var volume: Float32 = 0.5
|
||||||
var size: UInt32 = UInt32(MemoryLayout.size(ofValue: volume))
|
var size: UInt32 = UInt32(MemoryLayout.size(ofValue: volume))
|
||||||
@@ -71,16 +72,16 @@ class VolumeViewController: NSCustomTouchBarItem {
|
|||||||
AudioObjectGetPropertyData(defaultDeviceID, &address, 0, nil, &size, &volume)
|
AudioObjectGetPropertyData(defaultDeviceID, &address, 0, nil, &size, &volume)
|
||||||
return volume
|
return volume
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setInputGain(_ volume: Float32) -> OSStatus {
|
private func setInputGain(_ volume: Float32) -> OSStatus {
|
||||||
var inputVolume: Float32 = volume
|
var inputVolume: Float32 = volume
|
||||||
|
|
||||||
if inputVolume == 0.0 {
|
if inputVolume == 0.0 {
|
||||||
_ = setMute( mute: 1)
|
_ = setMute(mute: 1)
|
||||||
} else {
|
} else {
|
||||||
_ = setMute( mute: 0)
|
_ = setMute(mute: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
let size: UInt32 = UInt32(MemoryLayout.size(ofValue: inputVolume))
|
let size: UInt32 = UInt32(MemoryLayout.size(ofValue: inputVolume))
|
||||||
var address: AudioObjectPropertyAddress = AudioObjectPropertyAddress()
|
var address: AudioObjectPropertyAddress = AudioObjectPropertyAddress()
|
||||||
address.mScope = AudioObjectPropertyScope(kAudioDevicePropertyScopeOutput)
|
address.mScope = AudioObjectPropertyScope(kAudioDevicePropertyScopeOutput)
|
||||||
@@ -88,8 +89,8 @@ class VolumeViewController: NSCustomTouchBarItem {
|
|||||||
address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMasterVolume)
|
address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMasterVolume)
|
||||||
return AudioObjectSetPropertyData(defaultDeviceID, &address, 0, nil, size, &inputVolume)
|
return AudioObjectSetPropertyData(defaultDeviceID, &address, 0, nil, size, &inputVolume)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setMute( mute: Int) -> OSStatus {
|
private func setMute(mute: Int) -> OSStatus {
|
||||||
var muteVal: Int = mute
|
var muteVal: Int = mute
|
||||||
var address: AudioObjectPropertyAddress = AudioObjectPropertyAddress()
|
var address: AudioObjectPropertyAddress = AudioObjectPropertyAddress()
|
||||||
address.mSelector = AudioObjectPropertySelector(kAudioDevicePropertyMute)
|
address.mSelector = AudioObjectPropertySelector(kAudioDevicePropertyMute)
|
||||||
@@ -99,4 +100,3 @@ class VolumeViewController: NSCustomTouchBarItem {
|
|||||||
return AudioObjectSetPropertyData(defaultDeviceID, &address, 0, nil, size, &muteVal)
|
return AudioObjectSetPropertyData(defaultDeviceID, &address, 0, nil, size, &muteVal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,42 +16,42 @@ class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
|||||||
private var units_str = "°F"
|
private var units_str = "°F"
|
||||||
private var prev_location: CLLocation!
|
private var prev_location: CLLocation!
|
||||||
private var location: CLLocation!
|
private var location: CLLocation!
|
||||||
private let iconsImages = ["01d": "☀️", "01n": "☀️", "02d": "⛅️", "02n": "⛅️", "03d": "☁️", "03n": "☁️", "04d": "☁️", "04n": "☁️", "09d": "⛅️", "09n": "⛅️", "10d": "🌦", "10n": "🌦", "11d": "🌩", "11n": "🌩", "13d": "❄️", "13n": "❄️", "50d": "🌫", "50n": "🌫"]
|
private let iconsImages = ["01d": "☀️", "01n": "☀️", "02d": "⛅️", "02n": "⛅️", "03d": "☁️", "03n": "☁️", "04d": "☁️", "04n": "☁️", "09d": "⛅️", "09n": "⛅️", "10d": "🌦", "10n": "🌦", "11d": "🌩", "11n": "🌩", "13d": "❄️", "13n": "❄️", "50d": "🌫", "50n": "🌫"]
|
||||||
private let iconsText = ["01d": "☀", "01n": "☀", "02d": "☁", "02n": "☁", "03d": "☁", "03n": "☁", "04d": "☁", "04n": "☁", "09d": "☂", "09n": "☂", "10d": "☂", "10n": "☂", "11d": "☈", "11n": "☈", "13d": "☃", "13n": "☃", "50d": "♨", "50n": "♨"]
|
private let iconsText = ["01d": "☀", "01n": "☀", "02d": "☁", "02n": "☁", "03d": "☁", "03n": "☁", "04d": "☁", "04n": "☁", "09d": "☂", "09n": "☂", "10d": "☂", "10n": "☂", "11d": "☈", "11n": "☈", "13d": "☃", "13n": "☃", "50d": "♨", "50n": "♨"]
|
||||||
private var iconsSource: Dictionary<String, String>
|
private var iconsSource: Dictionary<String, String>
|
||||||
|
|
||||||
private var manager:CLLocationManager!
|
private var manager: CLLocationManager!
|
||||||
|
|
||||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, units: String, api_key: String, icon_type: String? = "text") {
|
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, units: String, api_key: String, icon_type: String? = "text") {
|
||||||
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
||||||
activity.interval = interval
|
activity.interval = interval
|
||||||
self.units = units
|
self.units = units
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
|
|
||||||
if self.units == "metric" {
|
if self.units == "metric" {
|
||||||
units_str = "°C"
|
units_str = "°C"
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.units == "imperial" {
|
if self.units == "imperial" {
|
||||||
units_str = "°F"
|
units_str = "°F"
|
||||||
}
|
}
|
||||||
|
|
||||||
if icon_type == "images" {
|
if icon_type == "images" {
|
||||||
iconsSource = iconsImages
|
iconsSource = iconsImages
|
||||||
} else {
|
} else {
|
||||||
iconsSource = iconsText
|
iconsSource = iconsText
|
||||||
}
|
}
|
||||||
|
|
||||||
super.init(identifier: identifier, title: "⏳")
|
super.init(identifier: identifier, title: "⏳")
|
||||||
|
|
||||||
let status = CLLocationManager.authorizationStatus()
|
let status = CLLocationManager.authorizationStatus()
|
||||||
if status == .restricted || status == .denied {
|
if status == .restricted || status == .denied {
|
||||||
print("User permission not given")
|
print("User permission not given")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !CLLocationManager.locationServicesEnabled() {
|
if !CLLocationManager.locationServicesEnabled() {
|
||||||
print("Location services not enabled");
|
print("Location services not enabled")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,43 +62,43 @@ class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
|||||||
completion(NSBackgroundActivityScheduler.Result.finished)
|
completion(NSBackgroundActivityScheduler.Result.finished)
|
||||||
}
|
}
|
||||||
updateWeather()
|
updateWeather()
|
||||||
|
|
||||||
manager = CLLocationManager()
|
manager = CLLocationManager()
|
||||||
manager.delegate = self
|
manager.delegate = self
|
||||||
manager.desiredAccuracy = kCLLocationAccuracyHundredMeters
|
manager.desiredAccuracy = kCLLocationAccuracyHundredMeters
|
||||||
manager.startUpdatingLocation()
|
manager.startUpdatingLocation()
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func updateWeather() {
|
@objc func updateWeather() {
|
||||||
if self.location != nil {
|
if location != nil {
|
||||||
let urlRequest = URLRequest(url: URL(string: "https://api.openweathermap.org/data/2.5/weather?lat=\(location.coordinate.latitude)&lon=\(location.coordinate.longitude)&units=\(self.units)&appid=\(self.api_key)")!)
|
let urlRequest = URLRequest(url: URL(string: "https://api.openweathermap.org/data/2.5/weather?lat=\(location.coordinate.latitude)&lon=\(location.coordinate.longitude)&units=\(units)&appid=\(api_key)")!)
|
||||||
|
|
||||||
let task = URLSession.shared.dataTask(with: urlRequest) { (data, response, error) in
|
let task = URLSession.shared.dataTask(with: urlRequest) { data, _, error in
|
||||||
|
|
||||||
if error == nil {
|
if error == nil {
|
||||||
do {
|
do {
|
||||||
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! [String : AnyObject]
|
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! [String: AnyObject]
|
||||||
// print(json)
|
// print(json)
|
||||||
var temperature: Int!
|
var temperature: Int!
|
||||||
var condition_icon = ""
|
var condition_icon = ""
|
||||||
|
|
||||||
if let main = json["main"] as? [String : AnyObject] {
|
if let main = json["main"] as? [String: AnyObject] {
|
||||||
if let temp = main["temp"] as? Double {
|
if let temp = main["temp"] as? Double {
|
||||||
temperature = Int(temp)
|
temperature = Int(temp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let weather = json["weather"] as? NSArray, let item = weather[0] as? NSDictionary {
|
if let weather = json["weather"] as? NSArray, let item = weather[0] as? NSDictionary {
|
||||||
let icon = item["icon"] as! String
|
let icon = item["icon"] as! String
|
||||||
if let test = self.iconsSource[icon] {
|
if let test = self.iconsSource[icon] {
|
||||||
condition_icon = test
|
condition_icon = test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if temperature != nil {
|
if temperature != nil {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.setWeather(text: "\(condition_icon) \(temperature!)\(self.units_str)")
|
self.setWeather(text: "\(condition_icon) \(temperature!)\(self.units_str)")
|
||||||
@@ -109,31 +109,30 @@ class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task.resume()
|
task.resume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setWeather(text: String) {
|
func setWeather(text: String) {
|
||||||
self.title = text
|
title = text
|
||||||
}
|
}
|
||||||
|
|
||||||
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
func locationManager(_: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
||||||
let lastLocation = locations.last!
|
let lastLocation = locations.last!
|
||||||
self.location = lastLocation
|
location = lastLocation
|
||||||
if prev_location == nil {
|
if prev_location == nil {
|
||||||
updateWeather()
|
updateWeather()
|
||||||
}
|
}
|
||||||
prev_location = lastLocation
|
prev_location = lastLocation
|
||||||
}
|
}
|
||||||
|
|
||||||
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
|
func locationManager(_: CLLocationManager, didFailWithError error: Error) {
|
||||||
print(error);
|
print(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
|
func locationManager(_: CLLocationManager, didChangeAuthorization _: CLAuthorizationStatus) {
|
||||||
// print("inside didChangeAuthorization ");
|
// print("inside didChangeAuthorization ");
|
||||||
updateWeather()
|
updateWeather()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
//
|
||||||
|
// WidgetProtocol.swift
|
||||||
|
// MTMR
|
||||||
|
//
|
||||||
|
// Created by Anton Palgunov on 20/10/2018.
|
||||||
|
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
protocol Widget {
|
||||||
|
static var name: String { get }
|
||||||
|
static var identifier: String { get }
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
//
|
||||||
|
// YandexWeatherBarItem.swift
|
||||||
|
// MTMR
|
||||||
|
//
|
||||||
|
// Created by bobrosoft on 22/07/2019.
|
||||||
|
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Cocoa
|
||||||
|
import CoreLocation
|
||||||
|
|
||||||
|
class YandexWeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
||||||
|
private let activity: NSBackgroundActivityScheduler
|
||||||
|
private let unitsStr = "°C"
|
||||||
|
private let iconsSource = ["Ясно": "☀️", "Малооблачно": "🌤", "Облачно с прояснениями": "⛅️", "Пасмурно": "☁️", "Небольшой дождь": "🌦", "Дождь": "🌧", "Ливень": "⛈", "Гроза": "🌩", "Небольшой снег": "❄️", "Снег": "🌨", "Туман": "🌫"]
|
||||||
|
private var location: CLLocation!
|
||||||
|
private var prevLocation: CLLocation!
|
||||||
|
private var manager: CLLocationManager!
|
||||||
|
|
||||||
|
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval) {
|
||||||
|
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
||||||
|
activity.interval = interval
|
||||||
|
|
||||||
|
super.init(identifier: identifier, title: "⏳")
|
||||||
|
|
||||||
|
let status = CLLocationManager.authorizationStatus()
|
||||||
|
if status == .restricted || status == .denied {
|
||||||
|
print("User permission not given")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !CLLocationManager.locationServicesEnabled() {
|
||||||
|
print("Location services not enabled")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
activity.repeats = true
|
||||||
|
activity.qualityOfService = .utility
|
||||||
|
activity.schedule { (completion: NSBackgroundActivityScheduler.CompletionHandler) in
|
||||||
|
self.updateWeather()
|
||||||
|
completion(NSBackgroundActivityScheduler.Result.finished)
|
||||||
|
}
|
||||||
|
updateWeather()
|
||||||
|
|
||||||
|
manager = CLLocationManager()
|
||||||
|
manager.delegate = self
|
||||||
|
manager.desiredAccuracy = kCLLocationAccuracyHundredMeters
|
||||||
|
manager.startUpdatingLocation()
|
||||||
|
|
||||||
|
tapClosure = tapClosure ?? defaultTapAction
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder _: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func updateWeather() {
|
||||||
|
var urlRequest = URLRequest(url: URL(string: getWeatherUrl())!)
|
||||||
|
urlRequest.addValue("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36", forHTTPHeaderField: "user-agent") // important for the right format
|
||||||
|
|
||||||
|
let task = URLSession.shared.dataTask(with: urlRequest) { data, _, error in
|
||||||
|
guard error == nil, let response = data?.utf8string else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// print(response)
|
||||||
|
|
||||||
|
var matches: [[String]]
|
||||||
|
var temperature: String?
|
||||||
|
matches = response.matchingStrings(regex: "fact__temp.*?temp__value.*?>(.*?)<")
|
||||||
|
temperature = matches.first?.item(at: 1)
|
||||||
|
|
||||||
|
var icon: String?
|
||||||
|
matches = response.matchingStrings(regex: "link__condition.*?>(.*?)<")
|
||||||
|
icon = matches.first?.item(at: 1)
|
||||||
|
if let _ = icon, let test = self.iconsSource[icon!] {
|
||||||
|
icon = test
|
||||||
|
}
|
||||||
|
|
||||||
|
if temperature != nil {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.setWeather(text: "\(icon ?? "?") \(temperature!)\(self.unitsStr)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task.resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
func getWeatherUrl() -> String {
|
||||||
|
if location != nil {
|
||||||
|
return "https://yandex.ru/pogoda/?lat=\(location.coordinate.latitude)&lon=\(location.coordinate.longitude)"
|
||||||
|
} else {
|
||||||
|
return "https://yandex.ru/pogoda/" // Yandex will try to determine your location by default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setWeather(text: String) {
|
||||||
|
title = text
|
||||||
|
}
|
||||||
|
|
||||||
|
func defaultTapAction() {
|
||||||
|
print(getWeatherUrl())
|
||||||
|
if let url = URL(string: getWeatherUrl()) {
|
||||||
|
NSWorkspace.shared.open(url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func locationManager(_: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
||||||
|
let lastLocation = locations.last!
|
||||||
|
location = lastLocation
|
||||||
|
if prevLocation == nil {
|
||||||
|
updateWeather()
|
||||||
|
}
|
||||||
|
prevLocation = lastLocation
|
||||||
|
}
|
||||||
|
|
||||||
|
func locationManager(_: CLLocationManager, didFailWithError error: Error) {
|
||||||
|
print(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func locationManager(_: CLLocationManager, didChangeAuthorization _: CLAuthorizationStatus) {
|
||||||
|
updateWeather()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension String {
|
||||||
|
func matchingStrings(regex: String) -> [[String]] {
|
||||||
|
guard let regex = try? NSRegularExpression(pattern: regex, options: []) else { return [] }
|
||||||
|
let nsString = self as NSString
|
||||||
|
let results = regex.matches(in: self, options: [], range: NSMakeRange(0, nsString.length))
|
||||||
|
return results.map { result in
|
||||||
|
(0..<result.numberOfRanges).map {
|
||||||
|
result.range(at: $0).location != NSNotFound
|
||||||
|
? nsString.substring(with: result.range(at: $0))
|
||||||
|
: ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Array {
|
||||||
|
func item(at index: Int) -> Element? {
|
||||||
|
return indices.contains(index) ? self[index] : nil
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,79 +1,89 @@
|
|||||||
[
|
[
|
||||||
{ "type": "escape", "align": "left" },
|
|
||||||
{ "type": "exitTouchbar", "width": 44, "align": "left" },
|
|
||||||
{ "type": "brightnessDown", "width": 44, "align": "left" },
|
|
||||||
{
|
{
|
||||||
"type": "brightness",
|
"type": "escape",
|
||||||
"width": 60,
|
"width": 64,
|
||||||
|
"align": "left"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "dnd",
|
||||||
"align": "left",
|
"align": "left",
|
||||||
"image": {
|
"width": 38
|
||||||
"base64":
|
|
||||||
"iVBORw0KGgoAAAANSUhEUgAAAIAAAACAAQMAAAD58POIAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAGUExURffLOPfLNyaSVzUAAAACdFJOU/kBxOqnWgAAAbJJREFUSMfVljtyhDAQBVulQCFH4CgcDR1NR9ERFBKoeA5GfGddtkNvwFINFKP5tED22+Zxwviv6QVKfIEc/iNoF5gkpLIeYI8SUp4PsAUJiekADQntF6isQjvxCTrhAJlFqMMBeIH9BMsD7DAb2BhvYbIyNAOCZIWqYKGTpDZJFQu9EKVd44RxQRq3IrULWD62C8wSssWUZEsR0k6wcDOrJZmoBpMKI+s5qkBQCQOUJADVOECdOsDS0gDbsgHMfT4rVwHSrZQFIN5ABka8BgDgAeZ+BztBgvUEnSgVlhNsTFJjvoF5HAZorBpdYKAiSRbqNyBIUr6AjZMdPwO72R40MElS+wZUWA+wQ6LAYkFvdIhkmA+wQSDDdIAGAZ6A34H0x0fca11gBZZsIHSIfnE/5+NjCn/OuiuUB+/aunZwDeNayjXdTpDN0wlY+r1PfWu75nfj8RogN2JuCN2Y5qgMwTI0wGPUnQw6Qarx0sVNKA5Mn6VUL22lIbZoYitDbPmlvocc9Umfl2D7adz1reC3pF8av4m+DCenp/ndZuG3E7fhuC3pH2+vnz8V3MfE+bnxBTXuuIMTrLWHAAAAAElFTkSuQmCC"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{ "type": "brightnessUp", "width": 44, "align": "left" },
|
{ "type": "brightnessDown", "width": 32, "bordered": false, "align": "left" },
|
||||||
|
{ "type": "brightnessUp", "width": 32, "bordered": false, "align": "left" },
|
||||||
|
|
||||||
|
// Spotify
|
||||||
{
|
{
|
||||||
"type": "appleScriptTitledButton",
|
"type": "appleScriptTitledButton",
|
||||||
"source": {
|
"source": {
|
||||||
"inline":
|
"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"
|
||||||
"if application \"iTunes\" is running then\rtell application \"iTunes\"\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",
|
"action": "appleScript",
|
||||||
"actionAppleScript": {
|
"actionAppleScript": {
|
||||||
"inline":
|
"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"
|
||||||
"if application \"iTunes\" is running then\rtell application \"iTunes\"\rif player state is playing then\rnext track\rend if\rend tell\rend if\r"
|
|
||||||
},
|
},
|
||||||
"refreshInterval": 1,
|
"refreshInterval": 1,
|
||||||
"image": {
|
"image": {
|
||||||
"base64":
|
"base64": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAYUExURUdwTB3WXx3UXh3VXx7XYBkXFRpVLRyURmIaeAQAAAAEdFJOUwDDO3fSqUUkAAABbklEQVRIx61VbW6DMAztoAeYNA7ApB6gkzhAWS24wIAL0HABaK6/pHFNEhy8TXu/kPzkPD/8cTj8K7KPAqB+K5NhQPCUrABCXe7HOUYYZxgVRLiG8RfY4DUgFFtC7cffAfZTFBwBdhWEKfgEq4ocEjgj4ZQifO6/QG9kkETp1dDeVWfRKx3XYSW0LoqY5kCElXDrQkyeCCuh6WL0M4nIWQIyzqixdfKU1koFDKvyCA8NJMzU4xiD+b4kfHRpsIyKc6hBwjVptFHVY51EMAINNDFGJITKDNQcdpX74Hz0CQ3rY5qwMp4EIxrlafzrsYZ2Veb0DkRgfNCUok4Y1fqEijfyi2b8RE9beWqa48Y/uvCNMcH9btfUi+/CGLR1vhL6Zz9N/vBlaCU+7lwY/cmJ67Ryen/2tj23PLqJBodZH8vgj544vOL4pxfI5acrSFxi8hrkU9TSKr78ZpnL50A8KPJJEo+afBblwyqf5j/iGys5j6ScrST2AAAAAElFTkSuQmCC"
|
||||||
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAADAUExURUdwTOVVZCzB+3qc0gkDBgEBAgcKEwAAAA4EBP5aVU2V95iJv7V3rtBOvH5W6jaOyclScKZGX3wuQCMuUqZN7+NQYXtDvFd9/sxYni2z6UhBhyhvnIp7sf38/PXz9ePm69/k6fHv8/j29+3q7/v6+ufq7uvu8fTw8+1egOFki/dbboVj/HNy/T+j/dNtnEul81vC8Vmf3OeRqOBVofK4xZfF7sDb7PLe6LxU1KKK79PL6vrW3fh4g5Zi4bi16daa0A3Qc90AAAAddFJOUwD3/v0uOlYNG/z+/v7998OYYztt/Le2/eDqi5jEo2rNTwAABMtJREFUWMPdl1tjqjoQhauC0Hqvta26JVxUQBQFRPBS/f//as8kISBqd/twXs5KjBDyrZkEFfP09D+WoigqFxz+mlbVXncweEZVBoNuD1x+E1vtMVZoURn01J/mob52KRNuj4k5mZjJcRueFotFpfv6EwdVRfy0tSdXSranheN0/zkRSB7x42Q6udExdBy3972Fog4o/kBg4X6bhPJaeX7eTqeT6b0MJtPpdOu6n49XQgX+dOQ8vpWEvYn/2AHiL052PpoROcsOtND17ztQ3rwTuCQz9O/moKiMf6BkG/puKBzurKQ64PmbU2bDzUxk3Uql4lZcl3Vpvt9VbxLoLZwjY7E1WcNZoB0XpbELie/3Sg6KVHG2jGPs1LTCE2UXFfgIgtBgyq8d/E/pehJq1zmZGc7kAPsMX4Ec932T25uX5vUklFcHJlDU1OT4wllkvOtn9lrSbF7dCUggNEtaMOXhQZq4WkpBcksJQBCOnyjvM4P8KqQgFW9BFJka2NMKB1gw+VMxvN9smnwI1EuzpxS+g9FWYySjsTpOtnq+H162iW01m/wyXLUPzT/5HKQoSjQmU8vE6TAElvWggbhuNRpScQa002bVtJmBCz9qNusWBkJmoyHmoHajC4yybVujhR26mJVha7lDo2FrhnA4N0aq+BpE24zjgsMoEsfU0AADaKCwemiIRZA+o6N9oygyMi/EAWk0DMNgFvCmN/5IwqCV3PCGzzIwbINrzgwykVq2iorUalm2UTZotXKWqVYz5uBjzDUoxrxWyzKQWy061LZsNIJ3PAMDIcbVauwdGmxrNblgYNnCgStN54ylBSsYoAxerwwgJsCWTS0sepym0Mdp1gYBw5lmwgDXIDEoaeHLYE36BafzuQWFQ9RASM/XQPpMD5YQ2gA/AwPArQJyZWDsgo64C+/pBRkDG4s31hdmwFNAGz1mBjPukBs8qdSgLDBA1LJm1lw/14IgWAdAQ5nhax4HY/FR7qfpHQMPUChzS0c6eFmv17MZo7HZBP3MQJHTNCnzxPMgOFUteAGtMwMmfRPIijBgc+AmNK6+9zw+9Iw05YsG8aaT/7Kro7eUcoSWw3n/1W57SxgGOZCYxl+VDDabcf6LpNTf3g6IQ4XY7TbiyyUBmhqsViswWK02cE7ITIdmtxnWlcJz6f1tPyMsha+2R4UGyJPdywotwGSHOKHdm+IMYA40BRhtkXOb42DAh8crppjw8CyB4nMBlvFtD/0WSfZebkDHguLNar2JdyTXptqRrx6OmMKZkISQc4Yv9yyDXHiiEx1qXL1OAFdhBJPAAQeRQDEiRZEm+kwnu2p1XHo64yQ8j47bL1kCZ87pDKWxuW4mQJ9O9ba31xE5Y/rnA4VoTCJQwvnyBNgk+pkDi8sSJjlKRPxhX7r3Lytz0LPMi1H1Qv7VuzwuAzh4h1ukKFi/YV9+9E8THZbne2Ezxd/xsNGQ6u+wgoeH4SH9Tl367t+2Ko/acA8Oj/DhWP7X/30Zkvj4WMYlj10MOISXf7DlkPvvH6g43u0oCzDS1U5f/sHWC3d7cn3UAQf4HeHfwxXQY4yu/HTDKNXro3Gngw4vw2FnPKrXJfUXu0fqIdeFZOnXm08FTRSxcf391pW7oNGT8vRf6i9jqljwYzAm6AAAAABJRU5ErkJggg=="
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// iTunes
|
||||||
{
|
{
|
||||||
"type": "appleScriptTitledButton",
|
"type": "appleScriptTitledButton",
|
||||||
"source": {
|
"source": {
|
||||||
"inline":
|
"inline": "if application \"iTunes\" is running then\rtell application \"iTunes\"\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"
|
||||||
"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",
|
"action": "appleScript",
|
||||||
"actionAppleScript": {
|
"actionAppleScript": {
|
||||||
"inline":
|
"inline": "if application \"iTunes\" is running then\rtell application \"iTunes\"\rif player state is playing then\rnext track\rend if\rend tell\rend if\r"
|
||||||
"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,
|
"longAction": "appleScript",
|
||||||
|
"longActionAppleScript": {
|
||||||
|
"inline": "if application \"iTunes\" is running then\rtell application \"iTunes\"\rif player state is playing then\rprev track\rend if\rend tell\rend if\r"
|
||||||
|
},
|
||||||
|
"refreshInterval": 2,
|
||||||
"image": {
|
"image": {
|
||||||
"base64":
|
"base64": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAADAUExURUdwTOVVZCzB+3qc0gkDBgEBAgcKEwAAAA4EBP5aVU2V95iJv7V3rtBOvH5W6jaOyclScKZGX3wuQCMuUqZN7+NQYXtDvFd9/sxYni2z6UhBhyhvnIp7sf38/PXz9ePm69/k6fHv8/j29+3q7/v6+ufq7uvu8fTw8+1egOFki/dbboVj/HNy/T+j/dNtnEul81vC8Vmf3OeRqOBVofK4xZfF7sDb7PLe6LxU1KKK79PL6vrW3fh4g5Zi4bi16daa0A3Qc90AAAAddFJOUwD3/v0uOlYNG/z+/v7998OYYztt/Le2/eDqi5jEo2rNTwAABMtJREFUWMPdl1tjqjoQhauC0Hqvta26JVxUQBQFRPBS/f//as8kISBqd/twXs5KjBDyrZkEFfP09D+WoigqFxz+mlbVXncweEZVBoNuD1x+E1vtMVZoURn01J/mob52KRNuj4k5mZjJcRueFotFpfv6EwdVRfy0tSdXSranheN0/zkRSB7x42Q6udExdBy3972Fog4o/kBg4X6bhPJaeX7eTqeT6b0MJtPpdOu6n49XQgX+dOQ8vpWEvYn/2AHiL052PpoROcsOtND17ztQ3rwTuCQz9O/moKiMf6BkG/puKBzurKQ64PmbU2bDzUxk3Uql4lZcl3Vpvt9VbxLoLZwjY7E1WcNZoB0XpbELie/3Sg6KVHG2jGPs1LTCE2UXFfgIgtBgyq8d/E/pehJq1zmZGc7kAPsMX4Ec932T25uX5vUklFcHJlDU1OT4wllkvOtn9lrSbF7dCUggNEtaMOXhQZq4WkpBcksJQBCOnyjvM4P8KqQgFW9BFJka2NMKB1gw+VMxvN9smnwI1EuzpxS+g9FWYySjsTpOtnq+H162iW01m/wyXLUPzT/5HKQoSjQmU8vE6TAElvWggbhuNRpScQa002bVtJmBCz9qNusWBkJmoyHmoHajC4yybVujhR26mJVha7lDo2FrhnA4N0aq+BpE24zjgsMoEsfU0AADaKCwemiIRZA+o6N9oygyMi/EAWk0DMNgFvCmN/5IwqCV3PCGzzIwbINrzgwykVq2iorUalm2UTZotXKWqVYz5uBjzDUoxrxWyzKQWy061LZsNIJ3PAMDIcbVauwdGmxrNblgYNnCgStN54ylBSsYoAxerwwgJsCWTS0sepym0Mdp1gYBw5lmwgDXIDEoaeHLYE36BafzuQWFQ9RASM/XQPpMD5YQ2gA/AwPArQJyZWDsgo64C+/pBRkDG4s31hdmwFNAGz1mBjPukBs8qdSgLDBA1LJm1lw/14IgWAdAQ5nhax4HY/FR7qfpHQMPUChzS0c6eFmv17MZo7HZBP3MQJHTNCnzxPMgOFUteAGtMwMmfRPIijBgc+AmNK6+9zw+9Iw05YsG8aaT/7Kro7eUcoSWw3n/1W57SxgGOZCYxl+VDDabcf6LpNTf3g6IQ4XY7TbiyyUBmhqsViswWK02cE7ITIdmtxnWlcJz6f1tPyMsha+2R4UGyJPdywotwGSHOKHdm+IMYA40BRhtkXOb42DAh8crppjw8CyB4nMBlvFtD/0WSfZebkDHguLNar2JdyTXptqRrx6OmMKZkISQc4Yv9yyDXHiiEx1qXL1OAFdhBJPAAQeRQDEiRZEm+kwnu2p1XHo64yQ8j47bL1kCZ87pDKWxuW4mQJ9O9ba31xE5Y/rnA4VoTCJQwvnyBNgk+pkDi8sSJjlKRPxhX7r3Lytz0LPMi1H1Qv7VuzwuAzh4h1ukKFi/YV9+9E8THZbne2Ezxd/xsNGQ6u+wgoeH4SH9Tl367t+2Ko/acA8Oj/DhWP7X/30Zkvj4WMYlj10MOISXf7DlkPvvH6g43u0oCzDS1U5f/sHWC3d7cn3UAQf4HeHfwxXQY4yu/HTDKNXro3Gngw4vw2FnPKrXJfUXu0fqIdeFZOnXm08FTRSxcf391pW7oNGT8vRf6i9jqljwYzAm6AAAAABJRU5ErkJggg=="
|
||||||
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAYUExURUdwTB3WXx3UXh3VXx7XYBkXFRpVLRyURmIaeAQAAAAEdFJOUwDDO3fSqUUkAAABbklEQVRIx61VbW6DMAztoAeYNA7ApB6gkzhAWS24wIAL0HABaK6/pHFNEhy8TXu/kPzkPD/8cTj8K7KPAqB+K5NhQPCUrABCXe7HOUYYZxgVRLiG8RfY4DUgFFtC7cffAfZTFBwBdhWEKfgEq4ocEjgj4ZQifO6/QG9kkETp1dDeVWfRKx3XYSW0LoqY5kCElXDrQkyeCCuh6WL0M4nIWQIyzqixdfKU1koFDKvyCA8NJMzU4xiD+b4kfHRpsIyKc6hBwjVptFHVY51EMAINNDFGJITKDNQcdpX74Hz0CQ3rY5qwMp4EIxrlafzrsYZ2Veb0DkRgfNCUok4Y1fqEijfyi2b8RE9beWqa48Y/uvCNMcH9btfUi+/CGLR1vhL6Zz9N/vBlaCU+7lwY/cmJ67Ryen/2tj23PLqJBodZH8vgj544vOL4pxfI5acrSFxi8hrkU9TSKr78ZpnL50A8KPJJEo+afBblwyqf5j/iGys5j6ScrST2AAAAAElFTkSuQmCC"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{ "type": "displaySleep", "width": 40, "align": "right", "bordered": false },
|
||||||
|
{
|
||||||
|
"type": "weather",
|
||||||
|
"align": "right",
|
||||||
|
"icon_type": "images",
|
||||||
|
"api_key": "ca93a0bb8cdb428552660d83249e4bc9",
|
||||||
|
"bordered": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "appleScriptTitledButton",
|
"type": "volumeDown",
|
||||||
"source": {
|
"bordered": false,
|
||||||
"inline":
|
"align": "right",
|
||||||
"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"
|
"width": 28
|
||||||
},
|
|
||||||
"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": "volumeUp",
|
||||||
{ "type": "next", "width": 44 },
|
"bordered": false,
|
||||||
{ "type": "weather", "icon_type": "images", "units": "metric" },
|
"align": "right",
|
||||||
{ "type": "currency", "from": "BTC", "to": "USD" },
|
"width": 28
|
||||||
{ "type": "sleep", "width": 44 },
|
},
|
||||||
{ "type": "mute", "width": 40, "align": "right" },
|
{
|
||||||
{ "type": "volumeDown", "width": 34, "align": "right" },
|
"type": "play",
|
||||||
{ "type": "volume", "width": 60, "align": "right" },
|
"align": "right",
|
||||||
{ "type": "volumeUp", "width": 34, "align": "right" },
|
"width": 38
|
||||||
{ "type": "inputsource", "align": "right" },
|
},
|
||||||
{ "type": "battery", "align": "right" },
|
{
|
||||||
{ "type": "timeButton", "align": "right" }
|
"type": "battery",
|
||||||
|
"align": "right",
|
||||||
|
"bordered": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "timeButton",
|
||||||
|
"formatTemplate": "HH:mm",
|
||||||
|
"align": "right",
|
||||||
|
"bordered": false,
|
||||||
|
"longAction": "shellScript",
|
||||||
|
"longExecutablePath": "/usr/bin/pmset",
|
||||||
|
"longShellArguments": ["sleepnow"]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
MIIGRzCCBDkGByqGSM44BAEwggQsAoICAQDYdwbPwVzbYmnGvpiuwcMuHbpwBymv
|
||||||
|
X+yc6OmFgZNRX39k9T3KyPNwRA8izqsdLsGQe66WxU+HYcVymUt6AWyFYQy4izUN
|
||||||
|
LNO90jqrcpQgES/5n0losdU/uYsATIo098RrGKB8pX5aPU/LavuQQCwyUcqSyRxs
|
||||||
|
p1SSyfj8gkyyFA8wnVmK/xe+O9xVbFzmcxPecwAVW9NIhCjSxTWZJyo5ocg/rf6G
|
||||||
|
dK+MmlrkgSEinXsUs8bR0FqW/3abQXDeAzKrvOTImyvdHb78usLPOopM05j9w3Dq
|
||||||
|
jHj6LdVFf3lAdg7pP0EJYkpuCyJnMQP3BDrewTkIVgmg8nrjR9ZCMSTdNIFTQwqp
|
||||||
|
jfTNh6vUdhPWt4bqMNRT3GbjMBaUNNVt7h0tsrND1nNFUS+PifoJCogqUAcQII//
|
||||||
|
U5lvfC01KxfyOYL1yzNCrq5tZFWqcgm9ko0fOf7c/vFrAQAX7+g5CkDB0DZIdwiq
|
||||||
|
66FDWewudzp3fe9EZB1/NrNX0Dh03uAGc/zCZjLODSqDyrmsG8p9x1uC0fyoFkfm
|
||||||
|
Itjm7nQtcPNdC782QJnDF9c/T1gbaJVMOFvRFiiWbP8U9w9dd5aJZpm3LtDEwT+X
|
||||||
|
ehLmi5n41L0fnh71kSQ63hmu26vLhfbFC+pTMelWnej7d1bNVujdsyqmuKqiv2qC
|
||||||
|
l9izOglpi5G16wIhAIuuCaGHwNtZPE8kw5TIxamUQaBR6ypUgc23Bmq3w6sNAoIC
|
||||||
|
ABaip4l8PU8nlvbA0PshCTTxTokiG8e7qnZRcp3nS/3Fm8QEQlZ15qgsuAym82F/
|
||||||
|
pBYN7ACR+KnePmHLJyIdBYDceW3FS2UcDvA1OZuNbnJwor8RggYfusKSM5AmULwQ
|
||||||
|
qZh42wVQ3NXaJMfGVr8sLH9M6GKgygj7D0Fv7bkDuntIo/Lh9n1q/Y9h8JU0O38r
|
||||||
|
JAiUrJ+q/rNo+8OeNGPadP3W9Slq81JjgSLfMpLDBOEpCEG4Lk6nmbhc45VhUG4+
|
||||||
|
uREm50/ow4PqnW4rr1WDRgjeSGptvxXh8OsLehQcl9ochYyS2PFywfmDCzA81fsg
|
||||||
|
hFAy8BICWB6/rC61+H8+8m0exUfTnzIC6RFderrymq7kbfRwYkh5etRjvEWEdgeI
|
||||||
|
WrJxLiHktDs72bAX9ujwJdXvqJy9SYVy+yWr8fY8vfXtLtZ7KI7gZu4q5tHxCA3s
|
||||||
|
zNK67yjxb6Zpjap/UP4iKyHnTy8DZ26120Jy4oN80xzQzNHfEzOxidQ54pVRH8uA
|
||||||
|
9B5MqySrNOuViAkJCa7LaPu2EEs8tLmiCa4gksaQj3Kdi+j5Icl2A/gkgIcqwyvW
|
||||||
|
VX/8ulRyrRRwVjxuJPNV3UwMANdNmRKWouVO1YLmS5XiBiYj25Tyo1IXH9c+AREB
|
||||||
|
4/gByGkWS9+x0JBAPZ8k4F7wsP73td/zckLaxwDB+7woA4ICBgACggIBAM5ntyMa
|
||||||
|
GTSdchuDYXIwH4iC72tXYgDIXBdLuVWGiOHeo25FFoXyrFVTm31sinzingQiAvXL
|
||||||
|
nlzTT8cdN2oWpOPNG14BzPPxSmRUzXJvgope4/Xp38eELi6DJvpMaAgSIBo+EAP+
|
||||||
|
b6vZO4Bcy3ExW+hMKGnbaRn90tQM7NIEbk+2/j75Z5ihNNQ6y+5JzcDqgacnP3fC
|
||||||
|
mwDkcOQtQyZrR3VByd6ZoV0dpqHapLU/mQwD34Qo34u9TwY0NFJRuz21aJ10EPNf
|
||||||
|
hnlsWtKGhijY79RplZRHdFtR5Y0e3Y3N9s5B5KM6qmyGJP7UyCfG70vrDGrBAei5
|
||||||
|
VupQIiDGw9UVP55wtuJridjTWTCKAhP+UUXaZhu1STYnQmfejU90bkRyggnd9g0E
|
||||||
|
bBixfxa+whskGWHG4pHzfpZVpkbceTdXnF5ieWG4jHzob82OwyTJ9yffWDr0eNlj
|
||||||
|
6vhral8ANHCqbx2vI8foU4XbKURSQxe93eLc+o1+sNlEexH+wg645BeVjI5Zaumg
|
||||||
|
GMcdiwbFdId3cCBOOwvo2KIlSI/DdwSJ9NCgCF2NJCpuZJy2HliCrDegymTf+Y18
|
||||||
|
Gt81NhNe9B8rB7slmX8XU7RlSdmMhNRm9fLSKGADJzhdwSPnaJxQ+AP6QgBeJWLf
|
||||||
|
35sZE2RHp4aEb9WceYHpjz8orPiLHJ/7OPbZ
|
||||||
|
-----END PUBLIC KEY-----
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
class AppleScriptDefinitionTests: XCTestCase {
|
class AppleScriptDefinitionTests: XCTestCase {
|
||||||
|
|
||||||
func testInline() {
|
func testInline() {
|
||||||
let buttonNoActionFixture = """
|
let buttonNoActionFixture = """
|
||||||
[ { "type": "appleScriptTitledButton", "source": { "inline": "tell everything fine" } } ]
|
[ { "type": "appleScriptTitledButton", "source": { "inline": "tell everything fine" } } ]
|
||||||
@@ -13,7 +12,7 @@ class AppleScriptDefinitionTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
XCTAssertEqual(source.string, "tell everything fine")
|
XCTAssertEqual(source.string, "tell everything fine")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPath() {
|
func testPath() {
|
||||||
let buttonNoActionFixture = """
|
let buttonNoActionFixture = """
|
||||||
[ { "type": "appleScriptTitledButton", "source": { "filePath": "/ololo/pew" } } ]
|
[ { "type": "appleScriptTitledButton", "source": { "filePath": "/ololo/pew" } } ]
|
||||||
@@ -26,7 +25,7 @@ class AppleScriptDefinitionTests: XCTestCase {
|
|||||||
let sourceStruct = source as? Source
|
let sourceStruct = source as? Source
|
||||||
XCTAssertEqual(sourceStruct?.filePath, "/ololo/pew")
|
XCTAssertEqual(sourceStruct?.filePath, "/ololo/pew")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRefreshInterval() {
|
func testRefreshInterval() {
|
||||||
let buttonNoActionFixture = """
|
let buttonNoActionFixture = """
|
||||||
[ { "type": "appleScriptTitledButton", "source": { "inline": "tell everything fine" }, "refreshInterval": 305} ]
|
[ { "type": "appleScriptTitledButton", "source": { "inline": "tell everything fine" }, "refreshInterval": 305} ]
|
||||||
@@ -37,5 +36,4 @@ class AppleScriptDefinitionTests: XCTestCase {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,27 @@
|
|||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
class BackgroundColorTests: XCTestCase {
|
class BackgroundColorTests: XCTestCase {
|
||||||
|
|
||||||
func testOpaque() {
|
func testOpaque() {
|
||||||
let buttonNoActionFixture = """
|
let buttonNoActionFixture = """
|
||||||
[ { "type": "staticButton", "title": "Pew", "background": "#FF0000" } ]
|
[ { "type": "staticButton", "title": "Pew", "background": "#FF0000" } ]
|
||||||
""".data(using: .utf8)!
|
""".data(using: .utf8)!
|
||||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
||||||
guard case .background(let color)? = result?.first?.additionalParameters[.background] else {
|
guard case let .background(color)? = result?.first?.additionalParameters[.background] else {
|
||||||
XCTFail()
|
XCTFail()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
XCTAssertEqual(color, .red)
|
XCTAssertEqual(color, .red)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAlpha() {
|
func testAlpha() {
|
||||||
let buttonNoActionFixture = """
|
let buttonNoActionFixture = """
|
||||||
[ { "type": "staticButton", "title": "Pew", "background": "#FF000080" } ]
|
[ { "type": "staticButton", "title": "Pew", "background": "#FF000080" } ]
|
||||||
""".data(using: .utf8)!
|
""".data(using: .utf8)!
|
||||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
||||||
guard case .background(let color)? = result?.first?.additionalParameters[.background] else {
|
guard case let .background(color)? = result?.first?.additionalParameters[.background] else {
|
||||||
XCTFail()
|
XCTFail()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
XCTAssertEqual(color.alphaComponent, 0.5, accuracy: 0.01)
|
XCTAssertEqual(color.alphaComponent, 0.5, accuracy: 0.01)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
class ParseConfig: XCTestCase {
|
class ParseConfig: XCTestCase {
|
||||||
|
|
||||||
func testButtonNoAction() {
|
func testButtonNoAction() {
|
||||||
let buttonNoActionFixture = """
|
let buttonNoActionFixture = """
|
||||||
[ { "type": "staticButton", "title": "Pew" } ]
|
[ { "type": "staticButton", "title": "Pew" } ]
|
||||||
@@ -31,7 +30,7 @@ class ParseConfig: XCTestCase {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPredefinedItem() {
|
func testPredefinedItem() {
|
||||||
let buttonKeycodeFixture = """
|
let buttonKeycodeFixture = """
|
||||||
[ { "type": "escape" } ]
|
[ { "type": "escape" } ]
|
||||||
@@ -46,7 +45,7 @@ class ParseConfig: XCTestCase {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExtendedWidthForPredefinedItem() {
|
func testExtendedWidthForPredefinedItem() {
|
||||||
let buttonKeycodeFixture = """
|
let buttonKeycodeFixture = """
|
||||||
[ { "type": "escape", "width": 110}, ]
|
[ { "type": "escape", "width": 110}, ]
|
||||||
@@ -65,5 +64,4 @@ class ParseConfig: XCTestCase {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,93 +1,105 @@
|
|||||||
|
# My touchbar. My rules. [](https://github.com/Toxblh/MTMR/releases) [](https://github.com/Toxblh/MTMR/blob/master/LICENSE) 
|
||||||
|
|
||||||
|
<img src="Resources/logo.png" align="right"
|
||||||
|
title="MTMR by Toxblh" width="110" height="110">
|
||||||
|
|
||||||
|
_The TouchBar Customization App for your MacBook Pro_
|
||||||
|
|
||||||
|
My idea is to create a platform for creating plugins to customize the TouchBar. I very much like BTT and having a full custom TouchBar (my BTT preset), and I wanted to create it. It's my first Swift project for MacOS :)
|
||||||
|
|
||||||
|
**Share your presets [here](https://github.com/Toxblh/MTMR-presets)**
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="Resources/logo.png" width="120">
|
<img src="./Resources/aaaaa-acc6-17fee7572ed0.png" alt="Mackbook with touchbar" width="800">
|
||||||
</p>
|
</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)  
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="Resources/TouchBar-v0.8.1.png">
|
<a href="https://discord.gg/CmNcDuQ"><img height="20px" src="https://camo.githubusercontent.com/88f53948f291c54736bf08f5fd7b037a848dfc62/68747470733a2f2f646973636f72646170702e636f6d2f6173736574732f30376463613830613130326434313439653937333664346231363263666636662e69636f"> Discord</a>
|
||||||
|
<a href="https://t.me/joinchat/AmVYGg8vW38c13_3MxdE_g"><img height="20px" src="https://telegram.org/img/t_logo.png" /> Telegram</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
**MTMR** Community:
|
<p align="center"><a href="https://www.paypal.me/toxblh/10" title="Donate via Paypal"><img height="36px" src="Resources/support_paypal.svg" alt="PayPal donate button" /></a>
|
||||||
[<img height="24px" src="https://github.com/discourse/DiscourseMobile/raw/master/icon.png" /> Discourse](https://forum.mtmr.app)
|
<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="36px" ></a>
|
||||||
[<img height="24px" src="https://telegram.org/img/t_logo.png" /> Telegram](https://t.me/joinchat/AmVYGg8vW38c13_3MxdE_g)
|
<a href="https://www.patreon.com/bePatron?u=9900748"><img height="36px" 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>
|
||||||
|
<a href="https://www.producthunt.com/posts/my-touchbar-my-rules-mtmr">
|
||||||
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 :)
|
<img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=my-touchbar-my-rules-mtmr&theme=light" alt="My TouchBar My Rules (MTMR)" height="36px" style="max-width:100%">
|
||||||
|
</a></p>
|
||||||
### Roadmap
|
|
||||||
- [x] Create the first prototype with TouchBar in Storyboard
|
|
||||||
- [x] Put in stripe menu on startup the application
|
|
||||||
- [x] Find how to simulate real buttons like brightness, volume, night shift and etc.
|
|
||||||
- [x] Time in touchbar!
|
|
||||||
- [x] First the weather plugin
|
|
||||||
- [x] Find how to open full-screen TouchBar without the cross and stripe menu
|
|
||||||
- [x] Find how to add haptic feedback
|
|
||||||
- [x] Add icon and menu in StatusBar
|
|
||||||
- [x] Hide from Dock
|
|
||||||
- [x] Status menu: "preferences", "quit"
|
|
||||||
- [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]
|
|
||||||
- [ ] 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
|
|
||||||
- [x] Startup at login
|
|
||||||
- [ ] Show on/off in Dock
|
|
||||||
- [ ] Show on/off in StatusBar
|
|
||||||
- [ ] On/off Haptic Feedback
|
|
||||||
|
|
||||||
Maybe:
|
|
||||||
- [ ] Refactoring the application on packages (AppleScript, JavaScript? and Swift?)
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
- Download last [release](https://github.com/Toxblh/MTMR/releases)
|
|
||||||
|
- Download lastest [release](https://github.com/Toxblh/MTMR/releases) (.dmg) from github
|
||||||
- Or via Homebrew `brew cask install mtmr`
|
- Or via Homebrew `brew cask install mtmr`
|
||||||
|
- [Dario Prski](https://medium.com/@urdigitalpulse) has written a [fantastic article on medium](https://medium.com/@urdigitalpulse/customise-your-macbook-pro-touch-bar-966998e606b5) that goes into more detail on installing MTMR
|
||||||
|
|
||||||
## Preset
|
**On first install** you need to allow access for MTMR in Accessibility otherwise buttons like <kbd>Esc</kbd>, <kbd>Volume</kbd>, <kbd>Brightness</kbd> and other system keys won't work
|
||||||
|
|
||||||
File for customize your preset for MTMR: `open ~/Library/Application\ Support/MTMR/items.json`
|
<p align="center">
|
||||||
|
<img width="450" alt="screenshot 2019-02-24 at 23 19 20" src="https://user-images.githubusercontent.com/2198153/53307057-2b078200-388c-11e9-8212-8c2b1aff0aa6.png">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
🍏→ System Preferences → Security and Privacy → tab Privacy → Accessibility → MTMR
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
- [@Toxblh preset](Resources/toxblh.json)
|
||||||
|
- [@ReDetection preset](Resources/ReDetection.json)
|
||||||
|
- [@luongvo209 preset](Resources/luongvo209.json)
|
||||||
|
- [aadi_vs_anand preset](Resources/aadi_vs_anand.json)
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="./Resources/Artboard.png" alt="Presets for touchbar" width="800">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
MTMR preferences are stored under `~/Library/Application\ Support/MTMR/items.json`.
|
||||||
|
|
||||||
|
The pre-installed configuration contains less or more than you'll probably want, try to configure:
|
||||||
|
|
||||||
## Built-in button types:
|
## Built-in button types:
|
||||||
|
|
||||||
|
> Buttons
|
||||||
|
|
||||||
- escape
|
- escape
|
||||||
- exitTouchbar
|
- exitTouchbar
|
||||||
- brightnessUp
|
- brightnessUp
|
||||||
- brightnessDown
|
- brightnessDown
|
||||||
|
- illuminationUp (keyboard illumination)
|
||||||
|
- illuminationDown (keyboard illumination)
|
||||||
- volumeDown
|
- volumeDown
|
||||||
- volumeUp
|
- volumeUp
|
||||||
- mute
|
- mute
|
||||||
- dock
|
|
||||||
|
|
||||||
> Native Plugins
|
> Native Plugins
|
||||||
|
|
||||||
- battery
|
- battery
|
||||||
- currency
|
- currency
|
||||||
- weather
|
- weather
|
||||||
|
- yandexWeather
|
||||||
- inputsource
|
- inputsource
|
||||||
- music (tap for pause, longTap for next)
|
- music (tap for pause, longTap for next)
|
||||||
|
- dock (half-long click to open app, full-long click to kill app)
|
||||||
|
- nightShift
|
||||||
|
- dnd (Don't disturb)
|
||||||
|
- darkMode
|
||||||
|
- pomodoro
|
||||||
|
- network
|
||||||
|
|
||||||
> Media Keys
|
> Media Keys
|
||||||
|
|
||||||
- previous
|
- previous
|
||||||
- play
|
- play
|
||||||
- next
|
- next
|
||||||
|
|
||||||
> AppleScript plugins
|
> AppleScript plugins
|
||||||
|
|
||||||
- sleep
|
- sleep
|
||||||
- displaySleep
|
- displaySleep
|
||||||
|
|
||||||
## Gestures on central part:
|
## Gestures on central part:
|
||||||
|
|
||||||
- two finger slide: change you Volume
|
- two finger slide: change you Volume
|
||||||
- three finger slide: change you Brightness
|
- three finger slide: change you Brightness
|
||||||
|
|
||||||
@@ -96,14 +108,17 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
|||||||
- brightness
|
- brightness
|
||||||
- volume
|
- volume
|
||||||
|
|
||||||
### You can also make a custom buttons using these types
|
### You can also make custom buttons using these types
|
||||||
|
|
||||||
- `staticButton`
|
- `staticButton`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"type": "staticButton",
|
"type": "staticButton",
|
||||||
"title": "esc",
|
"title": "esc",
|
||||||
```
|
```
|
||||||
|
|
||||||
- `appleScriptTitledButton`
|
- `appleScriptTitledButton`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"type": "appleScriptTitledButton",
|
"type": "appleScriptTitledButton",
|
||||||
"refreshInterval": 60, //optional
|
"refreshInterval": 60, //optional
|
||||||
@@ -117,69 +132,152 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
|||||||
```
|
```
|
||||||
|
|
||||||
- `timeButton`
|
- `timeButton`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"type": "timeButton",
|
"type": "timeButton",
|
||||||
"formatTemplate": "HH:mm" //optional
|
"formatTemplate": "HH:mm" //optional
|
||||||
```
|
```
|
||||||
|
|
||||||
## Groups
|
## Groups
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
"type": "group",
|
"type": "group",
|
||||||
"align": "center",
|
"align": "center",
|
||||||
"bordered": true,
|
"bordered": true,
|
||||||
"title": "stats",
|
"title": "stats",
|
||||||
"items": [{ button }, {button}, ...]
|
"items": [
|
||||||
|
{ "type": "play" }, { "type": "mute" }, ...]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To close a group, use the button:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"type": "close",
|
||||||
|
"width": 64
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
## Native plugins
|
## Native plugins
|
||||||
- `weather`
|
|
||||||
> Provider: https://openweathermap.org Need allowance location service
|
#### `timeButton`
|
||||||
|
|
||||||
|
> Attention! Works not all: https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"type": "timeButton",
|
||||||
|
"formatTemplate": "dd HH:mm",
|
||||||
|
"timeZone": "UTC"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `weather`
|
||||||
|
|
||||||
|
> Provider: https://openweathermap.org \
|
||||||
|
> Note: you need to register on https://openweathermap.org to get your API key \
|
||||||
|
> Note: you may need to wait for near 20 mins until your API key will be activated by Openweathermap \
|
||||||
|
> Note: you need to allow using "Location Services" in your Mac OS "Security & Privacy" settings for MTMR
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"type": "weather",
|
"type": "weather",
|
||||||
"refreshInterval": 600,
|
"refreshInterval": 600, // in seconds
|
||||||
"units": "metric", // or imperial
|
"units": "metric", // or imperial
|
||||||
"icon_type": "text" // or images
|
"icon_type": "text" // or images
|
||||||
"api_key": "" // you can get the key on openweather
|
"api_key": "" // you can get the key on openweather
|
||||||
```
|
```
|
||||||
|
|
||||||
- `currency`
|
#### `yandexWeather` (experimental)
|
||||||
|
|
||||||
|
> Provider: https://yandex.ru/pogoda. One click to open up weather forecast in your browser. \
|
||||||
|
> Note: you need to allow using "Location Services" in your Mac OS "Security & Privacy" settings for MTMR
|
||||||
|
|
||||||
|
```js
|
||||||
|
"type": "yandexWeather",
|
||||||
|
"refreshInterval": 600 // in seconds
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `currency`
|
||||||
|
|
||||||
> Provider: https://coinbase.com
|
> Provider: https://coinbase.com
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"type": "currency",
|
"type": "currency",
|
||||||
"refreshInterval": 600,
|
"refreshInterval": 600, // in seconds
|
||||||
"align": "right",
|
"align": "right",
|
||||||
"from": "BTC",
|
"from": "BTC",
|
||||||
"to": "USD",
|
"to": "USD",
|
||||||
|
"full": true // £‣1.29$
|
||||||
```
|
```
|
||||||
|
|
||||||
- `music`
|
#### `music`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
"type": "music",
|
"type": "music",
|
||||||
"align": "center",
|
"align": "center",
|
||||||
"width": 80,
|
"width": 80, // Optional
|
||||||
"bordered": false,
|
"bordered": false, // Optional
|
||||||
"refreshInterval": 2,
|
"refreshInterval": 2, // in seconds. Optional. Default 5 seconds
|
||||||
|
"disableMarquee": true // to disable marquee effect. Optional. Default false
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `pomodoro`
|
||||||
|
|
||||||
|
> Pomodoro plugin. One click to start the work timer, longclick to start the rest timer. Click in progress for reset.
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"type": "pomodoro",
|
||||||
|
"workTime": 1200, // set time work in seconds. Default 1500 (25 min)
|
||||||
|
"restTime": 600 // set time rest in seconds. Default 300 (5 min)
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `network`
|
||||||
|
|
||||||
|
> Network plugin. The plugin to show usage a network
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"type": "network",
|
||||||
|
"flip": true
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `dock`
|
||||||
|
|
||||||
|
> Dock plugin
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"type": "dock",
|
||||||
|
"autoResize": true
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
## Actions:
|
## Actions:
|
||||||
|
|
||||||
- `hidKey`
|
- `hidKey`
|
||||||
> https://github.com/aosm/IOHIDFamily/blob/master/IOHIDSystem/IOKit/hidsystem/ev_keymap.h use only numbers
|
> https://github.com/aosm/IOHIDFamily/blob/master/IOHIDSystem/IOKit/hidsystem/ev_keymap.h use only numbers
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"action": "hidKey",
|
"action": "hidKey",
|
||||||
"keycode": 53,
|
"keycode": 53,
|
||||||
```
|
```
|
||||||
|
|
||||||
- `keyPress`
|
- `keyPress`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"action": "keyPress",
|
"action": "keyPress",
|
||||||
"keycode": 1,
|
"keycode": 1,
|
||||||
```
|
```
|
||||||
|
|
||||||
- `appleScript`
|
- `appleScript`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"action": "appleScript",
|
"action": "appleScript",
|
||||||
"actionAppleScript": {
|
"actionAppleScript": {
|
||||||
@@ -189,6 +287,7 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
|||||||
```
|
```
|
||||||
|
|
||||||
- `shellScript`
|
- `shellScript`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"action": "shellScript",
|
"action": "shellScript",
|
||||||
"executablePath": "/usr/bin/pmset",
|
"executablePath": "/usr/bin/pmset",
|
||||||
@@ -197,13 +296,16 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT
|
|||||||
```
|
```
|
||||||
|
|
||||||
- `openUrl`
|
- `openUrl`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"action": "openUrl",
|
"action": "openUrl",
|
||||||
"url": "https://google.com",
|
"url": "https://google.com",
|
||||||
```
|
```
|
||||||
|
|
||||||
## LongActions
|
## LongActions
|
||||||
This then you want to use longPress for some operations is will the same values like for Actions but different additional parameters, example:
|
|
||||||
|
If you want to longPress for some operations, it is similar to the configuration for Actions but with additional parameters, for example:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"longAction": "hidKey",
|
"longAction": "hidKey",
|
||||||
"longKeycode": 53,
|
"longKeycode": 53,
|
||||||
@@ -218,84 +320,60 @@ This then you want to use longPress for some operations is will the same values
|
|||||||
|
|
||||||
## Additional parameters:
|
## Additional parameters:
|
||||||
|
|
||||||
- `width` allow to restrict how much room a particular button will take
|
- `width` restrict how much room a particular button will take
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"width": 34
|
"width": 34
|
||||||
```
|
```
|
||||||
|
|
||||||
- `align` can stick the item to the side. default is center
|
- `align` can stick the item to the side. default is center
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"align": "left" //or "right" or "center"
|
"align": "left" // "left", "right" or "center"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example configuration:
|
- `bordered` you can do button without border
|
||||||
```json
|
|
||||||
[
|
|
||||||
{ "type": "escape", "width": 110 },
|
|
||||||
{ "type": "exitTouchbar", "align": "left" },
|
|
||||||
{
|
|
||||||
"type": "brightnessUp",
|
|
||||||
"align": "left",
|
|
||||||
"width": 36
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "staticButton",
|
|
||||||
"align": "left",
|
|
||||||
"title": "🔆",
|
|
||||||
"action": "keyPress",
|
|
||||||
"keycode": 113,
|
|
||||||
"width": 36
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
```js
|
||||||
"type": "appleScriptTitledButton",
|
"bordered": "false" // "true" or "false"
|
||||||
"source": {
|
|
||||||
"filePath": "/Users/toxblh/Library/Application Support/MTMR/iTunes.nowPlaying.scpt"
|
|
||||||
},
|
|
||||||
"refreshInterval": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "staticButton",
|
|
||||||
"align": "left",
|
|
||||||
"image": { "base64" : "%base64Finder%"},
|
|
||||||
"action": "appleScript",
|
|
||||||
"actionAppleScript": {
|
|
||||||
"inline": "tell application \"Finder\"\rmake new Finder window\rset target of front window to path to home folder as string\ractivate\rend tell"
|
|
||||||
},
|
|
||||||
"width": 36
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "appleScriptTitledButton",
|
|
||||||
"source": {
|
|
||||||
"inline": "if application \"Safari\" is running then\r\ttell application \"Safari\"\r\t\trepeat with t in tabs of windows\r\t\t\ttell t\r\t\t\t\tif URL starts with \"https:\/\/music.yandex.ru\" and name does not end with \"на Яндекс.Музыке\" then\r\t\t\t\t\treturn name of t as text\r\t\t\t\tend if\r\t\t\tend tell\r\t\tend repeat\r\tend tell\rend if\rreturn \"\""
|
|
||||||
},
|
|
||||||
"refreshInterval": 1
|
|
||||||
},
|
|
||||||
{ "type": "previous", "width": 36, "align": "right" },
|
|
||||||
{ "type": "play", "width": 36, "align": "right" },
|
|
||||||
{ "type": "next", "width": 36, "align": "right" },
|
|
||||||
{ "type": "sleep", "width": 36 , "align": "right"},
|
|
||||||
{ "type": "displaySleep", "align": "right" },
|
|
||||||
{ "type": "weather", "refreshInterval": 1800, "width": 70, "align": "right" },
|
|
||||||
{ "type": "volumeDown", "width": 36 , "align": "right"},
|
|
||||||
{ "type": "volumeUp", "width": 36 , "align": "right"},
|
|
||||||
{ "type": "battery", "refreshInterval": 60 , "align": "right"},
|
|
||||||
{ "type": "appleScriptTitledButton", "refreshInterval": 1800, "source": { "filePath": "/Users/redetection/Library/Application Support/MTMR/Weather.scpt"} , "align": "right"},
|
|
||||||
{ "type": "timeButton", "formatTemplate": "HH:mm", "width": 64, "align": "right" }
|
|
||||||
]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Roadmap
|
||||||
|
|
||||||
### Author's presets
|
- [x] Create the first prototype with TouchBar in Storyboard
|
||||||
|
- [x] Put in stripe menu on startup the application
|
||||||
|
- [x] Find how to simulate real buttons like brightness, volume, night shift and etc.
|
||||||
|
- [x] Time in touchbar!
|
||||||
|
- [x] First the weather plugin
|
||||||
|
- [x] Find how to open full-screen TouchBar without the cross and stripe menu
|
||||||
|
- [x] Find how to add haptic feedback
|
||||||
|
- [x] Add icon and menu in StatusBar
|
||||||
|
- [x] Hide from Dock
|
||||||
|
- [x] Status menu: "preferences", "quit"
|
||||||
|
- [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
|
||||||
|
|
||||||
[@Toxblh preset](Resources/toxblh.json)
|
Settings:
|
||||||
|
|
||||||
[@ReDetection preset](Resources/ReDetection.json)
|
- [ ] Interface for plugins and export like presets
|
||||||
|
- [x] Startup at login
|
||||||
|
- [ ] Show on/off in Dock
|
||||||
|
- [ ] Show on/off in StatusBar
|
||||||
|
- [ ] On/off Haptic Feedback
|
||||||
|
|
||||||
|
Maybe:
|
||||||
|
|
||||||
|
- [ ] Refactoring the application into packages (AppleScript, JavaScript? and Swift?)
|
||||||
|
|
||||||
## Credits
|
## 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).
|
Built by [@Toxblh](https://patreon.com/toxblh) and [@ReDetection](http://patreon.com/ReDetection).
|
||||||
|
|
||||||
[](https://github.com/igrigorik/ga-beacon)
|
[](https://github.com/igrigorik/ga-beacon)
|
||||||
|
|||||||
|
After Width: | Height: | Size: 259 KiB |
|
After Width: | Height: | Size: 257 KiB |
|
After Width: | Height: | Size: 583 KiB |
@@ -0,0 +1,129 @@
|
|||||||
|
[
|
||||||
|
{ "type": "escape", "align": "left" },
|
||||||
|
// --- iTunes ---
|
||||||
|
{
|
||||||
|
"type": "appleScriptTitledButton",
|
||||||
|
"source": {
|
||||||
|
"inline":
|
||||||
|
"if application \"iTunes\" is running then\rtell application \"iTunes\"\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 \"iTunes\" is running then\rtell application \"iTunes\"\rif player state is playing then\rnext track\rend if\rend tell\rend if\r"
|
||||||
|
},
|
||||||
|
"refreshInterval": 1,
|
||||||
|
"image": {
|
||||||
|
"base64":
|
||||||
|
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAADAUExURUdwTOVVZCzB+3qc0gkDBgEBAgcKEwAAAA4EBP5aVU2V95iJv7V3rtBOvH5W6jaOyclScKZGX3wuQCMuUqZN7+NQYXtDvFd9/sxYni2z6UhBhyhvnIp7sf38/PXz9ePm69/k6fHv8/j29+3q7/v6+ufq7uvu8fTw8+1egOFki/dbboVj/HNy/T+j/dNtnEul81vC8Vmf3OeRqOBVofK4xZfF7sDb7PLe6LxU1KKK79PL6vrW3fh4g5Zi4bi16daa0A3Qc90AAAAddFJOUwD3/v0uOlYNG/z+/v7998OYYztt/Le2/eDqi5jEo2rNTwAABMtJREFUWMPdl1tjqjoQhauC0Hqvta26JVxUQBQFRPBS/f//as8kISBqd/twXs5KjBDyrZkEFfP09D+WoigqFxz+mlbVXncweEZVBoNuD1x+E1vtMVZoURn01J/mob52KRNuj4k5mZjJcRueFotFpfv6EwdVRfy0tSdXSranheN0/zkRSB7x42Q6udExdBy3972Fog4o/kBg4X6bhPJaeX7eTqeT6b0MJtPpdOu6n49XQgX+dOQ8vpWEvYn/2AHiL052PpoROcsOtND17ztQ3rwTuCQz9O/moKiMf6BkG/puKBzurKQ64PmbU2bDzUxk3Uql4lZcl3Vpvt9VbxLoLZwjY7E1WcNZoB0XpbELie/3Sg6KVHG2jGPs1LTCE2UXFfgIgtBgyq8d/E/pehJq1zmZGc7kAPsMX4Ec932T25uX5vUklFcHJlDU1OT4wllkvOtn9lrSbF7dCUggNEtaMOXhQZq4WkpBcksJQBCOnyjvM4P8KqQgFW9BFJka2NMKB1gw+VMxvN9smnwI1EuzpxS+g9FWYySjsTpOtnq+H162iW01m/wyXLUPzT/5HKQoSjQmU8vE6TAElvWggbhuNRpScQa002bVtJmBCz9qNusWBkJmoyHmoHajC4yybVujhR26mJVha7lDo2FrhnA4N0aq+BpE24zjgsMoEsfU0AADaKCwemiIRZA+o6N9oygyMi/EAWk0DMNgFvCmN/5IwqCV3PCGzzIwbINrzgwykVq2iorUalm2UTZotXKWqVYz5uBjzDUoxrxWyzKQWy061LZsNIJ3PAMDIcbVauwdGmxrNblgYNnCgStN54ylBSsYoAxerwwgJsCWTS0sepym0Mdp1gYBw5lmwgDXIDEoaeHLYE36BafzuQWFQ9RASM/XQPpMD5YQ2gA/AwPArQJyZWDsgo64C+/pBRkDG4s31hdmwFNAGz1mBjPukBs8qdSgLDBA1LJm1lw/14IgWAdAQ5nhax4HY/FR7qfpHQMPUChzS0c6eFmv17MZo7HZBP3MQJHTNCnzxPMgOFUteAGtMwMmfRPIijBgc+AmNK6+9zw+9Iw05YsG8aaT/7Kro7eUcoSWw3n/1W57SxgGOZCYxl+VDDabcf6LpNTf3g6IQ4XY7TbiyyUBmhqsViswWK02cE7ITIdmtxnWlcJz6f1tPyMsha+2R4UGyJPdywotwGSHOKHdm+IMYA40BRhtkXOb42DAh8crppjw8CyB4nMBlvFtD/0WSfZebkDHguLNar2JdyTXptqRrx6OmMKZkISQc4Yv9yyDXHiiEx1qXL1OAFdhBJPAAQeRQDEiRZEm+kwnu2p1XHo64yQ8j47bL1kCZ87pDKWxuW4mQJ9O9ba31xE5Y/rnA4VoTCJQwvnyBNgk+pkDi8sSJjlKRPxhX7r3Lytz0LPMi1H1Qv7VuzwuAzh4h1ukKFi/YV9+9E8THZbne2Ezxd/xsNGQ6u+wgoeH4SH9Tl367t+2Ko/acA8Oj/DhWP7X/30Zkvj4WMYlj10MOISXf7DlkPvvH6g43u0oCzDS1U5f/sHWC3d7cn3UAQf4HeHfwxXQY4yu/HTDKNXro3Gngw4vw2FnPKrXJfUXu0fqIdeFZOnXm08FTRSxcf391pW7oNGT8vRf6i9jqljwYzAm6AAAAABJRU5ErkJggg=="
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// --- 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": "dock", "width": 200, "align": "left"},
|
||||||
|
//{ "type": "button", "title": "alfred"},
|
||||||
|
//{ "type": "volume", "width": 160, "align": "right"},
|
||||||
|
{
|
||||||
|
"type": "group",
|
||||||
|
"align": "right",
|
||||||
|
"bordered": false,
|
||||||
|
"title": "Media",
|
||||||
|
"items": [
|
||||||
|
{"type": "close", "bordered": false, "align": "left"},
|
||||||
|
{
|
||||||
|
"type": "brightnessDown",
|
||||||
|
"bordered": false,
|
||||||
|
"align": "left",
|
||||||
|
"width": 36
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "brightness",
|
||||||
|
"width": 200,
|
||||||
|
"align": "left",
|
||||||
|
"image": {
|
||||||
|
"base64":
|
||||||
|
"iVBORw0KGgoAAAANSUhEUgAAAIAAAACAAQMAAAD58POIAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAGUExURffLOPfLNyaSVzUAAAACdFJOU/kBxOqnWgAAAbJJREFUSMfVljtyhDAQBVulQCFH4CgcDR1NR9ERFBKoeA5GfGddtkNvwFINFKP5tED22+Zxwviv6QVKfIEc/iNoF5gkpLIeYI8SUp4PsAUJiekADQntF6isQjvxCTrhAJlFqMMBeIH9BMsD7DAb2BhvYbIyNAOCZIWqYKGTpDZJFQu9EKVd44RxQRq3IrULWD62C8wSssWUZEsR0k6wcDOrJZmoBpMKI+s5qkBQCQOUJADVOECdOsDS0gDbsgHMfT4rVwHSrZQFIN5ABka8BgDgAeZ+BztBgvUEnSgVlhNsTFJjvoF5HAZorBpdYKAiSRbqNyBIUr6AjZMdPwO72R40MElS+wZUWA+wQ6LAYkFvdIhkmA+wQSDDdIAGAZ6A34H0x0fca11gBZZsIHSIfnE/5+NjCn/OuiuUB+/aunZwDeNayjXdTpDN0wlY+r1PfWu75nfj8RogN2JuCN2Y5qgMwTI0wGPUnQw6Qarx0sVNKA5Mn6VUL22lIbZoYitDbPmlvocc9Umfl2D7adz1reC3pF8av4m+DCenp/ndZuG3E7fhuC3pH2+vnz8V3MfE+bnxBTXuuIMTrLWHAAAAAElFTkSuQmCC"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "brightnessUp",
|
||||||
|
"bordered": false,
|
||||||
|
"align": "left",
|
||||||
|
"width": 36
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "volumeDown",
|
||||||
|
"bordered": false,
|
||||||
|
"align": "left",
|
||||||
|
"width": 36,
|
||||||
|
},
|
||||||
|
{ "type": "volume", "width": 200, "align": "left"},
|
||||||
|
{
|
||||||
|
"type": "volumeUp",
|
||||||
|
"bordered": false,
|
||||||
|
"align": "left",
|
||||||
|
"width": 36
|
||||||
|
},
|
||||||
|
{"type": "previous", "bordered": false, "align": "center"},
|
||||||
|
//{"type": "play", "bordered": false, "align": "center"},
|
||||||
|
|
||||||
|
{
|
||||||
|
"type": "appleScriptTitledButton",
|
||||||
|
"align": "center",
|
||||||
|
"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\rpause\rend if\rend tell\rend if\r"
|
||||||
|
},
|
||||||
|
"refreshInterval": 0.0001,
|
||||||
|
"image": {
|
||||||
|
"base64":
|
||||||
|
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAYUExURUdwTB3WXx3UXh3VXx7XYBkXFRpVLRyURmIaeAQAAAAEdFJOUwDDO3fSqUUkAAABbklEQVRIx61VbW6DMAztoAeYNA7ApB6gkzhAWS24wIAL0HABaK6/pHFNEhy8TXu/kPzkPD/8cTj8K7KPAqB+K5NhQPCUrABCXe7HOUYYZxgVRLiG8RfY4DUgFFtC7cffAfZTFBwBdhWEKfgEq4ocEjgj4ZQifO6/QG9kkETp1dDeVWfRKx3XYSW0LoqY5kCElXDrQkyeCCuh6WL0M4nIWQIyzqixdfKU1koFDKvyCA8NJMzU4xiD+b4kfHRpsIyKc6hBwjVptFHVY51EMAINNDFGJITKDNQcdpX74Hz0CQ3rY5qwMp4EIxrlafzrsYZ2Veb0DkRgfNCUok4Y1fqEijfyi2b8RE9beWqa48Y/uvCNMcH9btfUi+/CGLR1vhL6Zz9N/vBlaCU+7lwY/cmJ67Ryen/2tj23PLqJBodZH8vgj544vOL4pxfI5acrSFxi8hrkU9TSKr78ZpnL50A8KPJJEo+afBblwyqf5j/iGys5j6ScrST2AAAAAElFTkSuQmCC"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{"type": "next", "bordered": false, "align": "center"},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{ "type": "inputsource", "align": "right", },
|
||||||
|
{ "type": "mute", "bordered": false, "align": "right"},
|
||||||
|
{ "type": "dnd", "align": "right"},
|
||||||
|
{ "type": "nightShift", "align": "right"},
|
||||||
|
{ "type": "sleep", "align": "right", "bordered": false},
|
||||||
|
{ "type": "currency",
|
||||||
|
"refreshInterval": 600, // in seconds
|
||||||
|
"bordered": false,
|
||||||
|
"align": "right",
|
||||||
|
"from": "USD",
|
||||||
|
"to": "HKD",},
|
||||||
|
{
|
||||||
|
"type": "pomodoro",
|
||||||
|
"bordered": false,
|
||||||
|
"align": "right",
|
||||||
|
"workTime": 1800, // set time work in seconds. Default 1500 (25 min)
|
||||||
|
"restTime": 600, // set time rest in seconds. Default 300 (5 min)
|
||||||
|
},
|
||||||
|
{ "type": "weather", "refreshInterval": 60, "units": "metric", "align": "right", "bordered": false, "icon_type": "images", "api_key": "84645702688e83a35e2549ca77f73369"},
|
||||||
|
{ "type": "battery", "align": "right", "bordered": false },
|
||||||
|
{ "type": "timeButton", "align": "right", "formatTemplate": "E MMM d h:mm a", "bordered": false }
|
||||||
|
]
|
||||||
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 2.1 MiB |
@@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 250 49" style="enable-background:new 0 0 250 49;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st0{fill:#189BD7;}
|
||||||
|
.st1{enable-background:new ;}
|
||||||
|
.st2{fill:#FFFFFF;}
|
||||||
|
</style>
|
||||||
|
<title>support</title>
|
||||||
|
<path class="st0" d="M6.6,0h236.8c3.7,0,6.6,3,6.6,6.6v35.8c0,3.7-3,6.6-6.6,6.6c0,0,0,0,0,0H6.6C3,49,0,46,0,42.4c0,0,0,0,0,0V6.6
|
||||||
|
C0,3,3,0,6.6,0z"/>
|
||||||
|
<g class="st1">
|
||||||
|
<path class="st2" d="M25.4,18.8c-0.6-0.8-1.6-1.4-2.9-1.4c-1.4,0-3,0.8-3,2.6c0,1.8,1.5,2.2,3,2.7c2,0.7,4.1,1.3,4.1,4.1
|
||||||
|
c0,2.8-2.3,4-4.6,4c-1.7,0-3.4-0.7-4.4-2.1l1.2-0.9c0.6,1,1.7,1.8,3.2,1.8c1.4,0,3.1-0.9,3.1-2.7c0-2-1.6-2.4-3.4-3
|
||||||
|
c-1.9-0.6-3.8-1.4-3.8-3.9c0-2.7,2.4-3.9,4.5-3.9c1.9,0,3.3,0.8,3.9,1.7L25.4,18.8z"/>
|
||||||
|
<path class="st2" d="M36.4,30.6c0-0.5-0.1-1.2-0.1-1.6h0c-0.5,1.1-1.9,1.8-3.2,1.8c-2.3,0-3.5-1.5-3.5-3.8v-5.7h1.3v5.1
|
||||||
|
c0,1.9,0.6,3.2,2.5,3.2c1.4,0,2.8-1.1,2.8-3.6v-4.7h1.3v7.2c0,0.5,0,1.4,0.1,2H36.4z"/>
|
||||||
|
<path class="st2" d="M42.5,35.3h-1.3v-14h1.3v1.6h0.1c0.8-1.2,2.2-1.8,3.5-1.8c2.9,0,4.8,2.1,4.8,4.9c0,2.7-1.9,4.9-4.8,4.9
|
||||||
|
c-1.3,0-2.7-0.7-3.5-1.8h-0.1V35.3z M45.9,22.2c-2.1,0-3.6,1.6-3.6,3.7c0,2.1,1.5,3.7,3.6,3.7c2.2,0,3.5-1.7,3.5-3.7
|
||||||
|
C49.4,23.9,48.1,22.2,45.9,22.2z"/>
|
||||||
|
<path class="st2" d="M55,35.3h-1.3v-14H55v1.6h0.1c0.8-1.2,2.2-1.8,3.5-1.8c2.9,0,4.8,2.1,4.8,4.9c0,2.7-1.9,4.9-4.8,4.9
|
||||||
|
c-1.3,0-2.7-0.7-3.5-1.8H55V35.3z M58.4,22.2c-2.1,0-3.6,1.6-3.6,3.7c0,2.1,1.5,3.7,3.6,3.7c2.2,0,3.5-1.7,3.5-3.7
|
||||||
|
C61.9,23.9,60.6,22.2,58.4,22.2z"/>
|
||||||
|
<path class="st2" d="M70.4,30.8c-2.9,0-4.9-2.1-4.9-4.9c0-2.8,2.1-4.9,4.9-4.9c2.9,0,4.9,2.1,4.9,4.9
|
||||||
|
C75.4,28.7,73.3,30.8,70.4,30.8z M70.4,22.2c-2.1,0-3.5,1.7-3.5,3.7c0,2.1,1.4,3.7,3.5,3.7c2.2,0,3.5-1.6,3.5-3.7
|
||||||
|
C74,23.9,72.6,22.2,70.4,22.2z"/>
|
||||||
|
</g>
|
||||||
|
<g class="st1">
|
||||||
|
<path class="st2" d="M78.3,21.3h1.3c0,0.5,0.1,1.2,0.1,1.6h0c0.5-1.1,1.7-1.8,3-1.8c0.3,0,0.6,0,0.9,0.1l-0.2,1.3
|
||||||
|
c-0.2-0.1-0.6-0.1-0.9-0.1c-1.4,0-2.7,1-2.7,3.5v4.7h-1.3v-7.2C78.4,22.9,78.4,22,78.3,21.3z"/>
|
||||||
|
</g>
|
||||||
|
<g class="st1">
|
||||||
|
<path class="st2" d="M89.5,22.4h-2.6v5.4c0,1.4,0.6,1.7,1.4,1.7c0.4,0,0.8-0.1,1.2-0.3l0.1,1.2c-0.5,0.2-1,0.3-1.6,0.3
|
||||||
|
c-1,0-2.4-0.4-2.4-2.5v-5.8h-1.9v-1.1h1.9v-2.6h1.3v2.6h2.6V22.4z"/>
|
||||||
|
<path class="st2" d="M100.8,30.8c-2.9,0-4.9-2.1-4.9-4.9c0-2.8,2.1-4.9,4.9-4.9c2.9,0,4.9,2.1,4.9,4.9
|
||||||
|
C105.7,28.7,103.7,30.8,100.8,30.8z M100.8,22.2c-2.1,0-3.5,1.7-3.5,3.7c0,2.1,1.4,3.7,3.5,3.7c2.2,0,3.5-1.6,3.5-3.7
|
||||||
|
C104.3,23.9,102.9,22.2,100.8,22.2z"/>
|
||||||
|
<path class="st2" d="M109.8,21.3c0,0.5,0.1,1.2,0.1,1.6h0c0.5-1.1,1.9-1.8,3.2-1.8c2.3,0,3.5,1.5,3.5,3.8v5.7h-1.3v-5.1
|
||||||
|
c0-1.9-0.6-3.2-2.5-3.2c-1.4,0-2.8,1.1-2.8,3.6v4.7h-1.3v-7.2c0-0.5,0-1.4-0.1-2H109.8z"/>
|
||||||
|
</g>
|
||||||
|
<path class="st2" d="M166,18.3c0.1,0,0.2,0,0.3,0h4.9c1.1-0.1,2.2,0.1,3.2,0.4c0.8,0.2,1.5,0.7,2,1.4c0.5,0.8,0.7,1.8,0.6,2.8
|
||||||
|
c-0.1,0.9-0.3,1.7-0.6,2.5c-0.3,0.8-0.8,1.5-1.4,2.1c-0.9,0.7-2,1.2-3.1,1.4c-1.1,0.1-2.2,0.1-3.3,0.1c-0.3,0-0.5,0.1-0.6,0.4
|
||||||
|
c-0.1,0.2-0.2,0.4-0.2,0.6c-0.2,1.2-0.4,2.4-0.6,3.6c-0.1,0.4-0.4,0.7-0.8,0.7h-2.8c-0.3,0-0.5-0.2-0.5-0.5c0,0,0,0,0-0.1
|
||||||
|
c0.8-4.9,1.5-9.8,2.3-14.6C165.4,18.7,165.7,18.4,166,18.3z M169.1,21.5c-0.1,0.1-0.2,0.3-0.2,0.4c-0.2,1.2-0.4,2.5-0.6,3.7h0.9
|
||||||
|
c0.8,0.1,1.6-0.1,2.3-0.4c0.5-0.3,0.9-0.8,1-1.4c0.2-0.5,0.2-1.1,0-1.6c-0.2-0.4-0.5-0.6-0.9-0.8c-0.7-0.2-1.3-0.2-2-0.2
|
||||||
|
C169.5,21.4,169.3,21.4,169.1,21.5L169.1,21.5z"/>
|
||||||
|
<path class="st2" d="M179.3,24.1c1-0.6,2.1-0.9,3.2-0.8c0.9,0,1.7,0.2,2.5,0.6c0.3,0.2,0.5,0.5,0.7,0.8c0.1-0.3,0.1-0.5,0.1-0.8
|
||||||
|
c0.1-0.2,0.3-0.4,0.5-0.4h2.7c0.3,0,0.5,0.2,0.5,0.5c0,0,0,0.1,0,0.1c-0.5,3.1-1,6.2-1.5,9.4c-0.1,0.4-0.4,0.7-0.8,0.7h-2.5
|
||||||
|
c-0.2,0-0.4-0.1-0.5-0.3c0-0.1,0-0.3,0-0.4c0-0.2,0.1-0.4,0.1-0.6c-0.6,0.6-1.3,1-2.1,1.3c-0.9,0.3-1.9,0.3-2.9,0.1
|
||||||
|
c-0.7-0.1-1.4-0.5-2-1c-0.6-0.6-1.1-1.5-1.2-2.4c-0.2-1.1-0.1-2.1,0.2-3.2C176.9,26.2,177.9,24.9,179.3,24.1z M182.6,26.2
|
||||||
|
c-0.6,0.1-1.2,0.3-1.6,0.7c-0.6,0.5-1,1.1-1.1,1.9c-0.1,0.6,0,1.3,0.3,1.8c0.3,0.4,0.7,0.7,1.2,0.8c0.8,0.2,1.7,0.1,2.4-0.3
|
||||||
|
c1.1-0.7,1.7-1.9,1.5-3.2c-0.1-0.6-0.5-1.2-1.1-1.4C183.6,26.2,183.1,26.2,182.6,26.2z"/>
|
||||||
|
<path class="st2" d="M191,23.7c0.1-0.1,0.3-0.2,0.5-0.2h2.6c0.2,0,0.4,0.1,0.6,0.2c0.1,0.2,0.2,0.4,0.3,0.6l1.5,5.1
|
||||||
|
c1.2-1.7,2.3-3.5,3.5-5.2c0.1-0.2,0.3-0.4,0.4-0.6c0.2-0.1,0.4-0.2,0.6-0.2c0.9,0,1.8,0,2.7,0c0.3,0,0.5,0.3,0.4,0.5
|
||||||
|
c0,0.1,0,0.2-0.1,0.3l-9.2,13.2c-0.1,0.2-0.4,0.4-0.7,0.4h-2.7c-0.2,0-0.3,0-0.4-0.1c-0.2-0.2-0.2-0.5-0.1-0.7l2.8-3.9
|
||||||
|
c0-0.1,0-0.1,0-0.2l-3-8.8C190.8,24,190.9,23.8,191,23.7z"/>
|
||||||
|
<path class="st2" d="M206.9,18.3c0.1,0,0.2,0,0.4,0h5.1c1-0.1,2.1,0.1,3.1,0.4c0.8,0.3,1.4,0.8,1.9,1.5c0.5,0.9,0.7,1.8,0.5,2.8
|
||||||
|
c-0.1,1-0.4,2-0.9,2.9c-0.4,0.8-1,1.5-1.7,2c-0.8,0.5-1.7,0.9-2.7,1c-1.1,0.1-2.2,0.1-3.3,0.1c-0.3,0-0.5,0.2-0.6,0.4
|
||||||
|
c-0.1,0.2-0.1,0.4-0.2,0.6l-0.6,3.8c0,0.3-0.3,0.5-0.5,0.5h-3c-0.3,0-0.5-0.2-0.5-0.5c0,0,0,0,0-0.1c0.8-4.9,1.5-9.8,2.3-14.6
|
||||||
|
C206.3,18.6,206.6,18.4,206.9,18.3z M209.9,21.9c-0.2,1.3-0.4,2.5-0.6,3.8c0.9,0,1.8,0,2.7-0.2c0.5-0.1,0.9-0.4,1.1-0.7
|
||||||
|
c0.3-0.5,0.5-1,0.5-1.5c0.1-0.4-0.1-0.9-0.3-1.3c-0.3-0.3-0.7-0.5-1.1-0.5c-0.6-0.1-1.1-0.1-1.7-0.1
|
||||||
|
C210.1,21.4,209.9,21.6,209.9,21.9C209.9,21.8,209.9,21.8,209.9,21.9L209.9,21.9z"/>
|
||||||
|
<path class="st2" d="M233.6,18.3c0.1,0,0.3,0,0.4,0h2.4c0.3,0,0.5,0.2,0.5,0.5c0,0,0,0.1,0,0.1c-0.8,4.9-1.5,9.8-2.3,14.7
|
||||||
|
c-0.1,0.4-0.4,0.7-0.8,0.7h-2.4c-0.3,0-0.5-0.2-0.5-0.5c0,0,0-0.1,0-0.1c0.8-5,1.6-9.9,2.3-14.9C233.2,18.6,233.4,18.4,233.6,18.3z"
|
||||||
|
/>
|
||||||
|
<path class="st2" d="M152.5,19c0.8,0.4,1.5,1.2,1.8,2c0.3,1.1,0.4,2.2,0.1,3.3c-0.2,1.5-0.9,3-1.9,4.1c-0.6,0.7-1.4,1.3-2.3,1.6
|
||||||
|
c-1.3,0.5-2.7,0.7-4.1,0.7c-0.3,0-0.6,0-0.8,0.1c-0.3,0.2-0.5,0.5-0.6,0.8c-0.3,1.6-0.5,3.1-0.8,4.7c0,0.2-0.1,0.5-0.1,0.7
|
||||||
|
c-0.1,0.4-0.5,0.7-0.9,0.7H139c-0.2,0-0.5-0.1-0.6-0.3c-0.1-0.2-0.1-0.4,0-0.6c0.1-0.6,0.2-1.3,0.3-1.9c0-0.1,0-0.2,0.1-0.4
|
||||||
|
c0.3-2.3,0.7-4.6,1.1-6.8c0-0.2,0.1-0.4,0.2-0.7c0.2-0.2,0.4-0.4,0.7-0.5c0.3,0,0.6,0,0.9,0c1.2,0,2.4,0,3.6-0.1
|
||||||
|
c1.6-0.2,3.2-0.8,4.5-1.9c1.2-1.1,2-2.4,2.4-3.9C152.3,20.1,152.4,19.6,152.5,19z"/>
|
||||||
|
<path class="st2" d="M221.4,23.6c0.9-0.3,1.9-0.4,2.9-0.2c0.6,0.1,1.2,0.3,1.8,0.6c0.2,0.2,0.5,0.4,0.6,0.7c0-0.3,0.1-0.5,0.1-0.8
|
||||||
|
c0.1-0.2,0.3-0.4,0.5-0.3h2.7c0.3,0,0.5,0.2,0.5,0.5c0,0,0,0.1,0,0.1l-1.5,9.3c0,0.4-0.4,0.7-0.8,0.7h-2.5c-0.3,0-0.5-0.2-0.5-0.4
|
||||||
|
c0,0,0,0,0-0.1c0-0.3,0.1-0.5,0.1-0.8c-0.7,0.7-1.5,1.1-2.4,1.4c-0.9,0.2-1.8,0.2-2.7,0c-0.9-0.2-1.6-0.7-2.2-1.3
|
||||||
|
c-0.7-0.9-1-2-1-3.2c0-1.7,0.7-3.4,1.9-4.6C219.7,24.4,220.5,23.9,221.4,23.6z M223.5,26.2c-0.9,0.1-1.8,0.6-2.3,1.4
|
||||||
|
c-0.4,0.7-0.6,1.5-0.5,2.3c0.1,0.6,0.4,1.1,0.9,1.3c0.6,0.3,1.3,0.4,2,0.3c0.8-0.2,1.6-0.7,2-1.4c0.4-0.7,0.6-1.5,0.4-2.3
|
||||||
|
c-0.2-0.6-0.6-1.1-1.1-1.3C224.5,26.2,224.1,26.2,223.5,26.2L223.5,26.2z"/>
|
||||||
|
<path class="st2" d="M133.8,34.7c-0.2,0-0.3-0.1-0.3-0.3v-0.2c0.1-0.2,0.1-0.5,0.1-0.7l3.1-19.7c0-0.2,0.1-0.4,0.2-0.6
|
||||||
|
c0.1-0.2,0.3-0.3,0.6-0.3h8.5c1.4,0,2.7,0.3,4,0.9c0.9,0.5,1.7,1.3,2,2.3c0.3,0.9,0.3,1.8,0.1,2.8c-0.1,0.6-0.2,1.1-0.4,1.6
|
||||||
|
c-0.4,1.4-1.2,2.8-2.3,3.8c-1.2,1-2.7,1.6-4.3,1.8c-0.8,0.1-1.6,0.1-2.3,0.1h-1.7c-0.2,0-0.4,0-0.6,0c-0.4,0.1-0.7,0.3-0.9,0.7V27
|
||||||
|
v0.1c-0.1,0.2-0.1,0.5-0.2,0.8c-0.2,1-0.3,2-0.5,3.1c-0.2,1.3-0.4,2.5-0.6,3.8l0,0h-4.6L133.8,34.7z"/>
|
||||||
|
<path class="st0" d="M146,13.3c1.3,0,2.6,0.3,3.8,0.9c0.9,0.5,1.5,1.2,1.8,2.1c0.2,0.8,0.3,1.7,0.1,2.6l0,0l0,0
|
||||||
|
c-0.1,0.5-0.2,1-0.4,1.5c-0.4,1.4-1.1,2.6-2.2,3.6c-1.2,1-2.6,1.5-4.1,1.7c-0.8,0.1-1.5,0.1-2.3,0.1h-1.7c-0.2,0-0.4,0-0.6,0.1
|
||||||
|
c-0.5,0.1-0.9,0.4-1.1,0.8l-0.1,0.1V27c-0.1,0.3-0.1,0.5-0.2,0.8c-0.2,1-0.3,2-0.5,3c-0.2,1.2-0.4,2.3-0.6,3.5h-4.2
|
||||||
|
c0.1-0.2,0.1-0.5,0.1-0.7v-0.2l1.1-7.1l1.9-12.1c0-0.1,0-0.1,0-0.2c0-0.1,0-0.3,0.1-0.4c0.1-0.1,0.2-0.1,0.3-0.2L146,13.3 M146,12.5
|
||||||
|
h-8.6c-0.3,0-0.6,0.2-0.8,0.5c-0.2,0.3-0.2,0.6-0.3,0.9l-3,19.3c-0.1,0.3-0.1,0.6-0.2,1v0.3c0.1,0.3,0.3,0.5,0.6,0.6h4.4h0.5
|
||||||
|
c0-0.1,0-0.2,0.1-0.4c0.3-2.3,0.7-4.6,1.1-6.8c0-0.2,0.1-0.4,0.1-0.7c0.2-0.2,0.4-0.4,0.7-0.5c0.2,0,0.3,0,0.5,0h1.7
|
||||||
|
c0.8,0,1.6,0,2.4-0.1c1.6-0.2,3.2-0.8,4.5-1.9c1.2-1.1,2-2.4,2.4-3.9c0.2-0.5,0.3-1.1,0.4-1.7l0,0c0.2-1,0.1-2-0.1-2.9
|
||||||
|
c-0.4-1.1-1.2-2-2.2-2.6c-1.3-0.6-2.7-0.9-4.1-0.9l0,0L146,12.5z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 8.0 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>
|
||||||