mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-11-02 11:18:35 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
221cc8a176 | ||
|
|
a6b52ebe95 | ||
|
|
a4fee54ae0 |
@@ -1,22 +0,0 @@
|
||||
name: Build-and-test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: macOS-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Run tests
|
||||
run: xcodebuild test -project MTMR.xcodeproj -scheme 'UnitTests' | xcpretty -c && exit ${PIPESTATUS[0]}
|
||||
|
||||
build:
|
||||
runs-on: macOS-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Build
|
||||
run: xcodebuild archive -project "MTMR.xcodeproj" -scheme "MTMR" -archivePath Release/App.xcarchive DEVELOPMENT_TEAM="" CODE_SIGN_IDENTITY="" | xcpretty -c && exit ${PIPESTATUS[0]}
|
||||
@@ -1,41 +0,0 @@
|
||||
name: Publish unsign version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
Build-and-release:
|
||||
runs-on: macOS-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- name: Install create-dmg
|
||||
run: npm i -g create-dmg
|
||||
|
||||
- name: Build Archive
|
||||
run: xcodebuild archive -project "MTMR.xcodeproj" -scheme "MTMR" -archivePath Release/App.xcarchive DEVELOPMENT_TEAM="" CODE_SIGN_IDENTITY="" | xcpretty -c && exit ${PIPESTATUS[0]}
|
||||
|
||||
- name: Build App
|
||||
run: xcodebuild -project "MTMR.xcodeproj" -exportArchive -archivePath Release/App.xcarchive -exportOptionsPlist export-options.plist -exportPath Release | xcpretty -c && exit ${PIPESTATUS[0]}
|
||||
|
||||
- name: Create DMG
|
||||
run: |
|
||||
cd Release
|
||||
create-dmg MTMR.app || true
|
||||
|
||||
- name: GitHub Release
|
||||
uses: "marvinpinto/action-automatic-releases@latest"
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
prerelease: false
|
||||
files: Release/MTMR*.dmg
|
||||
+1
-1
@@ -54,7 +54,7 @@ playground.xcworkspace
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
language: swift
|
||||
xcode_project: MTMR.xcodeproj
|
||||
xcode_scheme: UnitTests
|
||||
osx_image: xcode11.1
|
||||
install: gem install xcpretty
|
||||
script: "xcodebuild test -project MTMR.xcodeproj -scheme 'UnitTests' | xcpretty -c && exit ${PIPESTATUS[0]}"
|
||||
@@ -0,0 +1 @@
|
||||
github "stephencelis/SQLite.swift" "0.12.2"
|
||||
@@ -22,8 +22,6 @@
|
||||
4CC9FEDC22FDEA65001512EB /* AMR_ANSIEscapeHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC9FEDB22FDEA65001512EB /* AMR_ANSIEscapeHelper.m */; };
|
||||
4CDC6E5022FCA93F0069ADD4 /* ShellScriptTouchBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CDC6E4F22FCA93F0069ADD4 /* ShellScriptTouchBarItem.swift */; };
|
||||
4CFF5E5C22E623DD00BFB1EE /* YandexWeatherBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF5E5B22E623DD00BFB1EE /* YandexWeatherBarItem.swift */; };
|
||||
5DC6CA02241F92CB005CD5E8 /* Music.nowPlaying.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 5DC6CA00241F92CB005CD5E8 /* Music.nowPlaying.scpt */; };
|
||||
5DC6CA03241F92CB005CD5E8 /* Music.next.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 5DC6CA01241F92CB005CD5E8 /* Music.next.scpt */; };
|
||||
60173D3E20C0031B002C305F /* LaunchAtLoginController.m in Sources */ = {isa = PBXBuildFile; fileRef = 60173D3D20C0031B002C305F /* LaunchAtLoginController.m */; };
|
||||
6027D1B92080E52A004FFDC7 /* BrightnessViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */; };
|
||||
6027D1BA2080E52A004FFDC7 /* VolumeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */; };
|
||||
@@ -34,10 +32,14 @@
|
||||
607EEA4D2087A8DA009DA5F0 /* CurrencyBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607EEA4C2087A8DA009DA5F0 /* CurrencyBarItem.swift */; };
|
||||
60C44AFD20A373A100C0EC91 /* MusicBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */; };
|
||||
60F7D454208CC31400ABF5D2 /* InputSourceBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */; };
|
||||
8338290C2360CA31008981D7 /* SQLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8338290B2360CA31008981D7 /* SQLite.framework */; };
|
||||
8338290D2360CA3F008981D7 /* SQLite.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = 8338290B2360CA31008981D7 /* SQLite.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
839ECD8523600BF500BE2DA5 /* NotificationTouchBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 839ECD8423600BF500BE2DA5 /* NotificationTouchBarItem.swift */; };
|
||||
839ECD882360160100BE2DA5 /* Mail.scpt in Sources */ = {isa = PBXBuildFile; fileRef = 839ECD872360160100BE2DA5 /* Mail.scpt */; };
|
||||
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, ); }; };
|
||||
B00D181F2152F521000806F4 /* Sparkle.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = B00D181C2152F4A5000806F4 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
B04B7BB72087398C00C835D0 /* BatteryBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B04B7BB62087398C00C835D0 /* BatteryBarItem.swift */; };
|
||||
B05600D32083E9BB00EB218D /* CustomSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B05600D22083E9BB00EB218D /* CustomSlider.swift */; };
|
||||
B059D622205E03F5006E6B86 /* TouchBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B059D621205E03F5006E6B86 /* TouchBarController.swift */; };
|
||||
@@ -69,19 +71,19 @@
|
||||
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 */; };
|
||||
BAF5AB5724317B4300B04904 /* BasicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAF5AB5624317B4300B04904 /* BasicView.swift */; };
|
||||
BAF5AB5924317CAF00B04904 /* SwipeItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAF5AB5824317CAF00B04904 /* SwipeItem.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
B00D181E2152F507000806F4 /* CopyFiles */ = {
|
||||
B00D181E2152F507000806F4 /* Copy Files */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 12;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
B00D181F2152F521000806F4 /* Sparkle.framework in CopyFiles */,
|
||||
B00D181F2152F521000806F4 /* Sparkle.framework in Copy Files */,
|
||||
8338290D2360CA3F008981D7 /* SQLite.framework in Copy Files */,
|
||||
);
|
||||
name = "Copy Files";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
@@ -104,8 +106,6 @@
|
||||
4CC9FEDB22FDEA65001512EB /* AMR_ANSIEscapeHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AMR_ANSIEscapeHelper.m; sourceTree = "<group>"; };
|
||||
4CDC6E4F22FCA93F0069ADD4 /* ShellScriptTouchBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellScriptTouchBarItem.swift; sourceTree = "<group>"; };
|
||||
4CFF5E5B22E623DD00BFB1EE /* YandexWeatherBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YandexWeatherBarItem.swift; sourceTree = "<group>"; };
|
||||
5DC6CA00241F92CB005CD5E8 /* Music.nowPlaying.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Music.nowPlaying.scpt; sourceTree = "<group>"; };
|
||||
5DC6CA01241F92CB005CD5E8 /* Music.next.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Music.next.scpt; sourceTree = "<group>"; };
|
||||
60173D3C20C0031B002C305F /* LaunchAtLoginController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LaunchAtLoginController.h; sourceTree = "<group>"; };
|
||||
60173D3D20C0031B002C305F /* LaunchAtLoginController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LaunchAtLoginController.m; sourceTree = "<group>"; };
|
||||
6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BrightnessViewController.swift; sourceTree = "<group>"; };
|
||||
@@ -118,6 +118,10 @@
|
||||
607EEA4C2087A8DA009DA5F0 /* CurrencyBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrencyBarItem.swift; sourceTree = "<group>"; };
|
||||
60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicBarItem.swift; sourceTree = "<group>"; };
|
||||
60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputSourceBarItem.swift; sourceTree = "<group>"; };
|
||||
8338290B2360CA31008981D7 /* SQLite.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SQLite.framework; path = Carthage/Build/Mac/SQLite.framework; sourceTree = "<group>"; };
|
||||
839ECD8423600BF500BE2DA5 /* NotificationTouchBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationTouchBarItem.swift; sourceTree = "<group>"; };
|
||||
839ECD86236015E300BE2DA5 /* Messages.scpt */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = Messages.scpt; sourceTree = "<group>"; };
|
||||
839ECD872360160100BE2DA5 /* Mail.scpt */ = {isa = PBXFileReference; lastKnownFileType = text; path = Mail.scpt; 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>"; };
|
||||
@@ -161,8 +165,6 @@
|
||||
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>"; };
|
||||
B0F8771B207AC92700D6E430 /* TouchBarSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarSupport.h; sourceTree = "<group>"; };
|
||||
BAF5AB5624317B4300B04904 /* BasicView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicView.swift; sourceTree = "<group>"; };
|
||||
BAF5AB5824317CAF00B04904 /* SwipeItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwipeItem.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -172,6 +174,7 @@
|
||||
files = (
|
||||
B002E642216C0E38002774BA /* CoreDisplay.framework in Frameworks */,
|
||||
B081732A2135F354005D4908 /* CoreBrightness.framework in Frameworks */,
|
||||
8338290C2360CA31008981D7 /* SQLite.framework in Frameworks */,
|
||||
B059D62D205F11E8006E6B86 /* DFRFoundation.framework in Frameworks */,
|
||||
B09EB1E6207C0F8E00D5C1E0 /* MultitouchSupport.framework in Frameworks */,
|
||||
B00D181D2152F4A5000806F4 /* Sparkle.framework in Frameworks */,
|
||||
@@ -191,6 +194,7 @@
|
||||
B059D62B205F11E8006E6B86 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8338290B2360CA31008981D7 /* SQLite.framework */,
|
||||
B002E641216C0E38002774BA /* CoreDisplay.framework */,
|
||||
B00D181C2152F4A5000806F4 /* Sparkle.framework */,
|
||||
B08173292135F354005D4908 /* CoreBrightness.framework */,
|
||||
@@ -238,10 +242,8 @@
|
||||
36FEF871235A1CFC00A0ABCE /* AppSettings.swift */,
|
||||
B059D623205E04F3006E6B86 /* CustomButtonTouchBarItem.swift */,
|
||||
36C2ECD8207B74B4003CDA33 /* AppleScriptTouchBarItem.swift */,
|
||||
BAF5AB5824317CAF00B04904 /* SwipeItem.swift */,
|
||||
4CDC6E4F22FCA93F0069ADD4 /* ShellScriptTouchBarItem.swift */,
|
||||
B059D621205E03F5006E6B86 /* TouchBarController.swift */,
|
||||
BAF5AB5624317B4300B04904 /* BasicView.swift */,
|
||||
36C2ECDA207C3FE7003CDA33 /* ItemsParsing.swift */,
|
||||
B0008E542080286C003AD4DD /* SupportHelpers.swift */,
|
||||
B09EB1E3207C082000D5C1E0 /* HapticFeedback.swift */,
|
||||
@@ -268,8 +270,6 @@
|
||||
B0B17426207D6AFE0004B740 /* AppleScripts */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5DC6CA01241F92CB005CD5E8 /* Music.next.scpt */,
|
||||
5DC6CA00241F92CB005CD5E8 /* Music.nowPlaying.scpt */,
|
||||
B0B1742A207D6B580004B740 /* Battery.scpt */,
|
||||
B0B17429207D6B580004B740 /* Finder.scpt */,
|
||||
B0B1742C207D6B590004B740 /* iTunes.next.scpt */,
|
||||
@@ -280,6 +280,8 @@
|
||||
B0B1742E207D6B590004B740 /* Vox.next.scpt */,
|
||||
B0B1742F207D6B590004B740 /* Vox.nowPlaying.scpt */,
|
||||
B0B17428207D6B580004B740 /* Weather.scpt */,
|
||||
839ECD86236015E300BE2DA5 /* Messages.scpt */,
|
||||
839ECD872360160100BE2DA5 /* Mail.scpt */,
|
||||
);
|
||||
path = AppleScripts;
|
||||
sourceTree = "<group>";
|
||||
@@ -322,6 +324,7 @@
|
||||
4CFF5E5B22E623DD00BFB1EE /* YandexWeatherBarItem.swift */,
|
||||
B08126F0217BE19000A98970 /* WidgetProtocol.swift */,
|
||||
B0F54A792295AC7D00B4C509 /* DarkModeBarItem.swift */,
|
||||
839ECD8423600BF500BE2DA5 /* NotificationTouchBarItem.swift */,
|
||||
);
|
||||
path = Widgets;
|
||||
sourceTree = "<group>";
|
||||
@@ -336,7 +339,7 @@
|
||||
B082B24B205C7D8000BC04DC /* Sources */,
|
||||
B082B24C205C7D8000BC04DC /* Frameworks */,
|
||||
B082B24D205C7D8000BC04DC /* Resources */,
|
||||
B00D181E2152F507000806F4 /* CopyFiles */,
|
||||
B00D181E2152F507000806F4 /* Copy Files */,
|
||||
B0679BBF215AE085000FC6B4 /* ShellScript */,
|
||||
);
|
||||
buildRules = (
|
||||
@@ -419,8 +422,6 @@
|
||||
B0B1743A207D6B590004B740 /* iTunes.nowPlaying.scpt in Resources */,
|
||||
B082B257205C7D8000BC04DC /* Assets.xcassets in Resources */,
|
||||
B0B17437207D6B590004B740 /* Spotify.nowPlaying.scpt in Resources */,
|
||||
5DC6CA02241F92CB005CD5E8 /* Music.nowPlaying.scpt in Resources */,
|
||||
5DC6CA03241F92CB005CD5E8 /* Music.next.scpt in Resources */,
|
||||
B0B17436207D6B590004B740 /* iTunes.next.scpt in Resources */,
|
||||
B082B25A205C7D8000BC04DC /* Main.storyboard in Resources */,
|
||||
B0B17435207D6B590004B740 /* Spotify.next.scpt in Resources */,
|
||||
@@ -471,13 +472,11 @@
|
||||
B059D622205E03F5006E6B86 /* TouchBarController.swift in Sources */,
|
||||
B05600D32083E9BB00EB218D /* CustomSlider.swift in Sources */,
|
||||
36C2ECD9207B74B4003CDA33 /* AppleScriptTouchBarItem.swift in Sources */,
|
||||
BAF5AB5724317B4300B04904 /* BasicView.swift in Sources */,
|
||||
B0846A752220C968000288A7 /* NetworkBarItem.swift in Sources */,
|
||||
B0F8771A207AC1EA00D6E430 /* TouchBarSupport.m in Sources */,
|
||||
B08126F1217BE19000A98970 /* WidgetProtocol.swift in Sources */,
|
||||
B0008E552080286C003AD4DD /* SupportHelpers.swift in Sources */,
|
||||
6042B6A72083E03A00C525C8 /* AppScrubberTouchBarItem.swift in Sources */,
|
||||
BAF5AB5924317CAF00B04904 /* SwipeItem.swift in Sources */,
|
||||
B082B253205C7D8000BC04DC /* AppDelegate.swift in Sources */,
|
||||
B0F54A7A2295AC7D00B4C509 /* DarkModeBarItem.swift in Sources */,
|
||||
B08126EF217BD0B900A98970 /* PomodoroBarItem.swift in Sources */,
|
||||
@@ -495,8 +494,10 @@
|
||||
B08173272135F02B005D4908 /* NightShiftBarItem.swift in Sources */,
|
||||
36FEF872235A1CFC00A0ABCE /* AppSettings.swift in Sources */,
|
||||
60F7D454208CC31400ABF5D2 /* InputSourceBarItem.swift in Sources */,
|
||||
839ECD882360160100BE2DA5 /* Mail.scpt in Sources */,
|
||||
36A778BE20A6C27100B38714 /* GeneralExtensions.swift in Sources */,
|
||||
60669B4320AD8FA80074E817 /* GroupBarItem.swift in Sources */,
|
||||
839ECD8523600BF500BE2DA5 /* NotificationTouchBarItem.swift in Sources */,
|
||||
36C2ECDB207C3FE7003CDA33 /* ItemsParsing.swift in Sources */,
|
||||
B0A7E9AA205D6AA400EEF070 /* KeyPress.swift in Sources */,
|
||||
36C2ECD7207B6DAE003CDA33 /* TimeTouchBarItem.swift in Sources */,
|
||||
@@ -653,9 +654,15 @@
|
||||
"$(inherited)",
|
||||
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
|
||||
"$(PROJECT_DIR)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/Mac",
|
||||
);
|
||||
INFOPLIST_FILE = MTMR/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
"-framework",
|
||||
"\"SQLite\"",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMR;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -676,9 +683,15 @@
|
||||
"$(inherited)",
|
||||
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",
|
||||
"$(PROJECT_DIR)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/Mac",
|
||||
);
|
||||
INFOPLIST_FILE = MTMR/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
OTHER_LDFLAGS = (
|
||||
"$(inherited)",
|
||||
"-framework",
|
||||
"\"SQLite\"",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = Toxblh.MTMR;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
||||
@@ -92,7 +92,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
@objc func toggleMultitouch(_ item: NSMenuItem) {
|
||||
item.state = item.state == .on ? .off : .on
|
||||
AppSettings.multitouchGestures = item.state == .on
|
||||
TouchBarController.shared.basicView?.legacyGesturesEnabled = item.state == .on
|
||||
TouchBarController.shared.scrollArea?.gesturesEnabled = item.state == .on
|
||||
}
|
||||
|
||||
@objc func openPreset(_: Any?) {
|
||||
|
||||
@@ -4,11 +4,9 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
|
||||
private var script: NSAppleScript!
|
||||
private let interval: TimeInterval
|
||||
private var forceHideConstraint: NSLayoutConstraint!
|
||||
private let alternativeImages: [String: SourceProtocol]
|
||||
|
||||
init?(identifier: NSTouchBarItem.Identifier, source: SourceProtocol, interval: TimeInterval, alternativeImages: [String: SourceProtocol]) {
|
||||
init?(identifier: NSTouchBarItem.Identifier, source: SourceProtocol, interval: TimeInterval) {
|
||||
self.interval = interval
|
||||
self.alternativeImages = alternativeImages
|
||||
super.init(identifier: identifier, title: "⏳")
|
||||
forceHideConstraint = view.widthAnchor.constraint(equalToConstant: 0)
|
||||
title = "scheduled"
|
||||
@@ -59,16 +57,6 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
|
||||
}
|
||||
}
|
||||
|
||||
func updateIcon(iconLabel: String) {
|
||||
if alternativeImages[iconLabel] != nil {
|
||||
DispatchQueue.main.async {
|
||||
self.image = self.alternativeImages[iconLabel]!.image
|
||||
}
|
||||
} else {
|
||||
print("Cannot find icon with label \"\(iconLabel)\"")
|
||||
}
|
||||
}
|
||||
|
||||
func execute() -> String {
|
||||
var error: NSDictionary?
|
||||
let output = script.executeAndReturnError(&error)
|
||||
@@ -76,18 +64,6 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
|
||||
print(error)
|
||||
return "error"
|
||||
}
|
||||
if output.descriptorType == typeAEList {
|
||||
let arr = Array(1...output.numberOfItems).compactMap({ output.atIndex($0)!.stringValue ?? "" })
|
||||
|
||||
if arr.count <= 0 {
|
||||
return ""
|
||||
} else if arr.count == 1 {
|
||||
return arr[0]
|
||||
} else {
|
||||
updateIcon(iconLabel: arr[1])
|
||||
return arr[0]
|
||||
}
|
||||
}
|
||||
return output.stringValue ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
if application "Mail" is running then
|
||||
tell application "Mail"
|
||||
if player state is playing then
|
||||
return (get artist of current track) & " – " & (get name of current track)
|
||||
else
|
||||
return ""
|
||||
end if
|
||||
end tell
|
||||
end if
|
||||
return ""
|
||||
@@ -0,0 +1,10 @@
|
||||
if application "Messages" is running then
|
||||
tell application "Messages"
|
||||
if player state is playing then
|
||||
return (get artist of current track) & " – " & (get name of current track)
|
||||
else
|
||||
return ""
|
||||
end if
|
||||
end tell
|
||||
end if
|
||||
return ""
|
||||
@@ -1,7 +0,0 @@
|
||||
if application "Music" is running then
|
||||
tell application "Music"
|
||||
if player state is playing then
|
||||
next track
|
||||
end if
|
||||
end tell
|
||||
end if
|
||||
@@ -1,10 +0,0 @@
|
||||
if application "Music" is running then
|
||||
tell application "Music"
|
||||
if player state is playing then
|
||||
return (get artist of current track) & " – " & (get name of current track)
|
||||
else
|
||||
return ""
|
||||
end if
|
||||
end tell
|
||||
end if
|
||||
return ""
|
||||
@@ -2,10 +2,6 @@ if application "iTunes" is running then
|
||||
tell application "iTunes" to playpause
|
||||
end if
|
||||
|
||||
if application "Music" is running then
|
||||
tell application "Music" to playpause
|
||||
end if
|
||||
|
||||
if application "Spotify" is running then
|
||||
tell application "Spotify" to playpause
|
||||
end if
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
//
|
||||
// BasicView.swift
|
||||
// MTMR
|
||||
//
|
||||
// Created by Fedor Zaitsev on 3/29/20.
|
||||
// Copyright © 2020 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
||||
var twofingers: NSPanGestureRecognizer!
|
||||
var threefingers: NSPanGestureRecognizer!
|
||||
var fourfingers: NSPanGestureRecognizer!
|
||||
var swipeItems: [SwipeItem] = []
|
||||
var prevPositions: [Int: CGFloat] = [2:0, 3:0, 4:0]
|
||||
|
||||
// legacy gesture positions
|
||||
// by legacy I mean gestures to increse/decrease volume/brigtness which can be checked from app menu
|
||||
var legacyPrevPositions: [Int: CGFloat] = [2:0, 3:0, 4:0]
|
||||
var legacyGesturesEnabled = false
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, items: [NSTouchBarItem], swipeItems: [SwipeItem]) {
|
||||
super.init(identifier: identifier)
|
||||
self.swipeItems = swipeItems
|
||||
let views = items.compactMap { $0.view }
|
||||
let stackView = NSStackView(views: views)
|
||||
stackView.spacing = 8
|
||||
stackView.orientation = .horizontal
|
||||
view = stackView
|
||||
|
||||
twofingers = NSPanGestureRecognizer(target: self, action: #selector(twofingersHandler(_:)))
|
||||
twofingers.numberOfTouchesRequired = 2
|
||||
twofingers.allowedTouchTypes = .direct
|
||||
view.addGestureRecognizer(twofingers)
|
||||
|
||||
threefingers = NSPanGestureRecognizer(target: self, action: #selector(threefingersHandler(_:)))
|
||||
threefingers.numberOfTouchesRequired = 3
|
||||
threefingers.allowedTouchTypes = .direct
|
||||
view.addGestureRecognizer(threefingers)
|
||||
|
||||
fourfingers = NSPanGestureRecognizer(target: self, action: #selector(fourfingersHandler(_:)))
|
||||
fourfingers.numberOfTouchesRequired = 4
|
||||
fourfingers.allowedTouchTypes = .direct
|
||||
view.addGestureRecognizer(fourfingers)
|
||||
}
|
||||
|
||||
required init?(coder _: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func gestureHandler(position: CGFloat, fingers: Int, state: NSGestureRecognizer.State) {
|
||||
switch state {
|
||||
case .began:
|
||||
prevPositions[fingers] = position
|
||||
legacyPrevPositions[fingers] = position
|
||||
case .changed:
|
||||
if self.legacyGesturesEnabled {
|
||||
if fingers == 2 {
|
||||
let prevPos = legacyPrevPositions[fingers]!
|
||||
if ((position - prevPos) > 10) || ((prevPos - position) > 10) {
|
||||
if position > prevPos {
|
||||
HIDPostAuxKey(NX_KEYTYPE_SOUND_UP)
|
||||
} else if position < prevPos {
|
||||
HIDPostAuxKey(NX_KEYTYPE_SOUND_DOWN)
|
||||
}
|
||||
legacyPrevPositions[fingers] = position
|
||||
}
|
||||
}
|
||||
if fingers == 3 {
|
||||
let prevPos = legacyPrevPositions[fingers]!
|
||||
if ((position - prevPos) > 15) || ((prevPos - position) > 15) {
|
||||
if position > prevPos {
|
||||
GenericKeyPress(keyCode: CGKeyCode(144)).send()
|
||||
} else if position < prevPos {
|
||||
GenericKeyPress(keyCode: CGKeyCode(145)).send()
|
||||
}
|
||||
legacyPrevPositions[fingers] = position
|
||||
}
|
||||
}
|
||||
}
|
||||
case .ended:
|
||||
print("gesture ended \(position - prevPositions[fingers]!) \(fingers)")
|
||||
for item in swipeItems {
|
||||
item.processEvent(offset: position - prevPositions[fingers]!, fingers: fingers)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@objc func twofingersHandler(_ sender: NSGestureRecognizer?) {
|
||||
let position = (sender?.location(in: sender?.view).x)!
|
||||
self.gestureHandler(position: position, fingers: 2, state: sender!.state)
|
||||
}
|
||||
|
||||
@objc func threefingersHandler(_ sender: NSGestureRecognizer?) {
|
||||
let position = (sender?.location(in: sender?.view).x)!
|
||||
self.gestureHandler(position: position, fingers: 3, state: sender!.state)
|
||||
}
|
||||
|
||||
@objc func fourfingersHandler(_ sender: NSGestureRecognizer?) {
|
||||
let position = (sender?.location(in: sender?.view).x)!
|
||||
self.gestureHandler(position: position, fingers: 4, state: sender!.state)
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.26.1</string>
|
||||
<string>0.25</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>405</string>
|
||||
<string>297</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
@@ -39,7 +39,7 @@
|
||||
<key>NSHomeKitUsageDescription</key>
|
||||
<string>MTMR needs access to HomeKit for work</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2018 - 2020 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>
|
||||
|
||||
+39
-21
@@ -56,6 +56,13 @@ class SupportedTypesHolder {
|
||||
parameters: [.align: .align(.left)]
|
||||
) },
|
||||
|
||||
"reply": { _ in (
|
||||
item: .staticButton(title: "Reply"),
|
||||
action: .shellScript(executable: "/usr/bin/open", parameters: ["sms://"]),
|
||||
longAction: .none,
|
||||
parameters: [.align: .align(.right)]
|
||||
) },
|
||||
|
||||
"delete": { _ in (
|
||||
item: .staticButton(title: "del"),
|
||||
action: .keyPress(keycode: 117),
|
||||
@@ -177,6 +184,27 @@ class SupportedTypesHolder {
|
||||
parameters: [:]
|
||||
) },
|
||||
|
||||
"notification": { decoder in
|
||||
enum CodingKeys: String, CodingKey { case refreshInterval; case disableMarquee; case image }
|
||||
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)
|
||||
if var img = try container.decodeIfPresent(Source.self, forKey: .image) {
|
||||
return (
|
||||
item: .notification(interval: interval ?? 5.0, disableMarquee: disableMarquee ?? false),
|
||||
action: .shellScript(executable: "/usr/bin/open", parameters: ["sms://"]),
|
||||
longAction: .none,
|
||||
parameters: [.image: .image(source: img)]
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
item: .notification(interval: interval ?? 5.0, disableMarquee: disableMarquee ?? false),
|
||||
action: .shellScript(executable: "/usr/bin/open", parameters: ["sms://"]),
|
||||
longAction: .none,
|
||||
parameters: [:]
|
||||
)
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
static let sharedInstance = SupportedTypesHolder()
|
||||
@@ -208,7 +236,7 @@ class SupportedTypesHolder {
|
||||
|
||||
enum ItemType: Decodable {
|
||||
case staticButton(title: String)
|
||||
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double, alternativeImages: [String: SourceProtocol])
|
||||
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
|
||||
case shellScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
|
||||
case timeButton(formatTemplate: String, timeZone: String?, locale: String?)
|
||||
case battery
|
||||
@@ -220,13 +248,13 @@ enum ItemType: Decodable {
|
||||
case currency(interval: Double, from: String, to: String, full: Bool)
|
||||
case inputsource
|
||||
case music(interval: Double, disableMarquee: Bool)
|
||||
case notification(interval: Double, disableMarquee: Bool)
|
||||
case group(items: [BarItemDefinition])
|
||||
case nightShift
|
||||
case dnd
|
||||
case pomodoro(workTime: Double, restTime: Double)
|
||||
case network(flip: Bool)
|
||||
case darkMode
|
||||
case swipe(direction: String, fingers: Int, minOffset: Float, sourceApple: SourceProtocol?, sourceBash: SourceProtocol?)
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
@@ -252,12 +280,6 @@ enum ItemType: Decodable {
|
||||
case autoResize
|
||||
case filter
|
||||
case disableMarquee
|
||||
case alternativeImages
|
||||
case sourceApple
|
||||
case sourceBash
|
||||
case direction
|
||||
case fingers
|
||||
case minOffset
|
||||
}
|
||||
|
||||
enum ItemTypeRaw: String, Decodable {
|
||||
@@ -274,13 +296,13 @@ enum ItemType: Decodable {
|
||||
case currency
|
||||
case inputsource
|
||||
case music
|
||||
case notification
|
||||
case group
|
||||
case nightShift
|
||||
case dnd
|
||||
case pomodoro
|
||||
case network
|
||||
case darkMode
|
||||
case swipe
|
||||
}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
@@ -290,9 +312,8 @@ enum ItemType: Decodable {
|
||||
case .appleScriptTitledButton:
|
||||
let source = try container.decode(Source.self, forKey: .source)
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||
let alternativeImages = try container.decodeIfPresent([String: Source].self, forKey: .alternativeImages) ?? [:]
|
||||
self = .appleScriptTitledButton(source: source, refreshInterval: interval, alternativeImages: alternativeImages)
|
||||
|
||||
self = .appleScriptTitledButton(source: source, refreshInterval: interval)
|
||||
|
||||
case .shellScriptTitledButton:
|
||||
let source = try container.decode(Source.self, forKey: .source)
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||
@@ -329,7 +350,7 @@ enum ItemType: Decodable {
|
||||
let api_key = try container.decodeIfPresent(String.self, forKey: .api_key) ?? "32c4256d09a4c52b38aecddba7a078f6"
|
||||
let icon_type = try container.decodeIfPresent(String.self, forKey: .icon_type) ?? "text"
|
||||
self = .weather(interval: interval, units: units, api_key: api_key, icon_type: icon_type)
|
||||
|
||||
|
||||
case .yandexWeather:
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 1800.0
|
||||
self = .yandexWeather(interval: interval)
|
||||
@@ -349,6 +370,11 @@ enum ItemType: Decodable {
|
||||
let disableMarquee = try container.decodeIfPresent(Bool.self, forKey: .disableMarquee) ?? false
|
||||
self = .music(interval: interval, disableMarquee: disableMarquee)
|
||||
|
||||
case .notification:
|
||||
let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) ?? 5.0
|
||||
let disableMarquee = try container.decodeIfPresent(Bool.self, forKey: .disableMarquee) ?? false
|
||||
self = .notification(interval: interval, disableMarquee: disableMarquee)
|
||||
|
||||
case .group:
|
||||
let items = try container.decode([BarItemDefinition].self, forKey: .items)
|
||||
self = .group(items: items)
|
||||
@@ -370,14 +396,6 @@ enum ItemType: Decodable {
|
||||
|
||||
case .darkMode:
|
||||
self = .darkMode
|
||||
|
||||
case .swipe:
|
||||
let sourceApple = try container.decodeIfPresent(Source.self, forKey: .sourceApple)
|
||||
let sourceBash = try container.decodeIfPresent(Source.self, forKey: .sourceBash)
|
||||
let direction = try container.decode(String.self, forKey: .direction)
|
||||
let fingers = try container.decode(Int.self, forKey: .fingers)
|
||||
let minOffset = try container.decodeIfPresent(Float.self, forKey: .minOffset) ?? 0.0
|
||||
self = .swipe(direction: direction, fingers: fingers, minOffset: minOffset, sourceApple: sourceApple, sourceBash: sourceBash)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import Foundation
|
||||
|
||||
class ScrollViewItem: NSCustomTouchBarItem/*, NSGestureRecognizerDelegate*/ {
|
||||
class ScrollViewItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
||||
var twofingersPrev: CGFloat = 0.0
|
||||
var threefingersPrev: CGFloat = 0.0
|
||||
var twofingers: NSPanGestureRecognizer!
|
||||
var threefingers: NSPanGestureRecognizer!
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, items: [NSTouchBarItem]) {
|
||||
super.init(identifier: identifier)
|
||||
@@ -11,10 +15,70 @@ class ScrollViewItem: NSCustomTouchBarItem/*, NSGestureRecognizerDelegate*/ {
|
||||
let scrollView = NSScrollView(frame: CGRect(origin: .zero, size: stackView.fittingSize))
|
||||
scrollView.documentView = stackView
|
||||
view = scrollView
|
||||
|
||||
twofingers = NSPanGestureRecognizer(target: self, action: #selector(twofingersHandler(_:)))
|
||||
twofingers.allowedTouchTypes = .direct
|
||||
twofingers.numberOfTouchesRequired = 2
|
||||
view.addGestureRecognizer(twofingers)
|
||||
|
||||
threefingers = NSPanGestureRecognizer(target: self, action: #selector(threefingersHandler(_:)))
|
||||
threefingers.allowedTouchTypes = .direct
|
||||
threefingers.numberOfTouchesRequired = 3
|
||||
view.addGestureRecognizer(threefingers)
|
||||
}
|
||||
|
||||
var gesturesEnabled = true {
|
||||
didSet {
|
||||
twofingers.isEnabled = gesturesEnabled
|
||||
threefingers.isEnabled = gesturesEnabled
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder _: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@objc func twofingersHandler(_ sender: NSGestureRecognizer?) { // Volume
|
||||
let position = (sender?.location(in: sender?.view).x)!
|
||||
|
||||
switch sender!.state {
|
||||
case .began:
|
||||
twofingersPrev = position
|
||||
case .changed:
|
||||
if ((position - twofingersPrev) > 10) || ((twofingersPrev - position) > 10) {
|
||||
if position > twofingersPrev {
|
||||
HIDPostAuxKey(NX_KEYTYPE_SOUND_UP)
|
||||
} else if position < twofingersPrev {
|
||||
HIDPostAuxKey(NX_KEYTYPE_SOUND_DOWN)
|
||||
}
|
||||
twofingersPrev = position
|
||||
}
|
||||
case .ended:
|
||||
twofingersPrev = 0.0
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@objc func threefingersHandler(_ sender: NSGestureRecognizer?) { // Brightness
|
||||
let position = (sender?.location(in: sender?.view).x)!
|
||||
|
||||
switch sender!.state {
|
||||
case .began:
|
||||
threefingersPrev = position
|
||||
case .changed:
|
||||
if ((position - threefingersPrev) > 15) || ((threefingersPrev - position) > 15) {
|
||||
if position > threefingersPrev {
|
||||
GenericKeyPress(keyCode: CGKeyCode(144)).send()
|
||||
} else if position < threefingersPrev {
|
||||
GenericKeyPress(keyCode: CGKeyCode(145)).send()
|
||||
}
|
||||
threefingersPrev = position
|
||||
}
|
||||
case .ended:
|
||||
threefingersPrev = 0.0
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,19 +62,11 @@ class ShellScriptTouchBarItem: CustomButtonTouchBarItem {
|
||||
|
||||
let pipe = Pipe()
|
||||
task.standardOutput = pipe
|
||||
|
||||
// kill process if it is over update interval
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + interval) { [weak task] in
|
||||
task?.terminate()
|
||||
}
|
||||
|
||||
task.launch()
|
||||
|
||||
let data = pipe.fileHandleForReading.readDataToEndOfFile()
|
||||
var output: String = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as String? ?? ""
|
||||
|
||||
//always wait until task end or you can catch "task still running" error while accessing task.terminationStatus variable
|
||||
task.waitUntilExit()
|
||||
if (output == "" && task.terminationStatus != 0) {
|
||||
output = "error"
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
//
|
||||
// SwipeItem.swift
|
||||
// MTMR
|
||||
//
|
||||
// Created by Fedor Zaitsev on 3/29/20.
|
||||
// Copyright © 2020 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Foundation
|
||||
|
||||
class SwipeItem: NSCustomTouchBarItem {
|
||||
private var scriptApple: NSAppleScript?
|
||||
private var scriptBash: String?
|
||||
private var direction: String
|
||||
private var fingers: Int
|
||||
private var minOffset: Float
|
||||
init?(identifier: NSTouchBarItem.Identifier, direction: String, fingers: Int, minOffset: Float, sourceApple: SourceProtocol?, sourceBash: SourceProtocol?) {
|
||||
self.direction = direction
|
||||
self.fingers = fingers
|
||||
self.scriptBash = sourceBash?.string
|
||||
self.scriptApple = sourceApple?.appleScript
|
||||
self.minOffset = minOffset
|
||||
super.init(identifier: identifier)
|
||||
}
|
||||
|
||||
required init?(coder _: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func processEvent(offset: CGFloat, fingers: Int) {
|
||||
if direction == "right" && Float(offset) > self.minOffset && self.fingers == fingers {
|
||||
self.execute()
|
||||
}
|
||||
if direction == "left" && Float(offset) < -self.minOffset && self.fingers == fingers {
|
||||
self.execute()
|
||||
}
|
||||
}
|
||||
|
||||
func execute() {
|
||||
if scriptApple != nil {
|
||||
DispatchQueue.appleScriptQueue.async {
|
||||
var error: NSDictionary?
|
||||
self.scriptApple?.executeAndReturnError(&error)
|
||||
if let error = error {
|
||||
print("SwipeItem apple script error: \(error)")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if scriptBash != nil {
|
||||
DispatchQueue.shellScriptQueue.async {
|
||||
let task = Process()
|
||||
task.launchPath = "/bin/bash"
|
||||
task.arguments = ["-c", self.scriptBash!]
|
||||
task.launch()
|
||||
task.waitUntilExit()
|
||||
|
||||
|
||||
if (task.terminationStatus != 0) {
|
||||
print("SwipeItem bash script error. Status: \(task.terminationStatus)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,8 @@ extension ItemType {
|
||||
return "com.toxblh.mtmr.inputsource."
|
||||
case .music(interval: _):
|
||||
return "com.toxblh.mtmr.music."
|
||||
case .notification(interval: _):
|
||||
return "com.toxblh.mtmr.notification."
|
||||
case .group(items: _):
|
||||
return "com.toxblh.mtmr.groupBar."
|
||||
case .nightShift:
|
||||
@@ -57,8 +59,6 @@ extension ItemType {
|
||||
return NetworkBarItem.identifier
|
||||
case .darkMode:
|
||||
return DarkModeBarItem.identifier
|
||||
case .swipe(direction: _, fingers: _, minOffset: _, sourceApple: _, sourceBash: _):
|
||||
return "com.toxblh.mtmr.swipe."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,10 +78,10 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:]
|
||||
var leftIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||
var centerIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||
var centerItems: [NSTouchBarItem] = []
|
||||
var rightIdentifiers: [NSTouchBarItem.Identifier] = []
|
||||
var basicViewIdentifier = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollView.".appending(UUID().uuidString))
|
||||
var basicView: BasicView?
|
||||
var swipeItems: [SwipeItem] = []
|
||||
var scrollArea: ScrollViewItem?
|
||||
var centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||
|
||||
var blacklistAppIdentifiers: [String] = []
|
||||
var frontmostApplicationIdentifier: String? {
|
||||
@@ -100,7 +100,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
}
|
||||
|
||||
blacklistAppIdentifiers = AppSettings.blacklistedAppIds
|
||||
|
||||
|
||||
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.didActivateApplicationNotification, object: nil)
|
||||
@@ -116,29 +116,24 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
jsonItems = newJsonItems
|
||||
itemDefinitions = [:]
|
||||
items = [:]
|
||||
leftIdentifiers = []
|
||||
centerItems = []
|
||||
rightIdentifiers = []
|
||||
|
||||
loadItemDefinitions(jsonItems: jsonItems)
|
||||
createItems()
|
||||
|
||||
let centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
||||
centerItems = centerIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
||||
items[identifier]
|
||||
})
|
||||
|
||||
let centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||
let scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)
|
||||
|
||||
centerScrollArea = NSTouchBarItem.Identifier("com.toxblh.mtmr.scrollArea.".appending(UUID().uuidString))
|
||||
scrollArea = ScrollViewItem(identifier: centerScrollArea, items: centerItems)
|
||||
scrollArea?.gesturesEnabled = AppSettings.multitouchGestures
|
||||
|
||||
touchBar.delegate = self
|
||||
touchBar.defaultItemIdentifiers = [basicViewIdentifier]
|
||||
|
||||
let leftItems = leftIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
||||
items[identifier]
|
||||
})
|
||||
let rightItems = rightIdentifiers.compactMap({ (identifier) -> NSTouchBarItem? in
|
||||
items[identifier]
|
||||
})
|
||||
|
||||
basicView = BasicView(identifier: basicViewIdentifier, items:leftItems + [scrollArea] + rightItems, swipeItems: swipeItems)
|
||||
basicView?.legacyGesturesEnabled = AppSettings.multitouchGestures
|
||||
touchBar.defaultItemIdentifiers = []
|
||||
touchBar.defaultItemIdentifiers = leftIdentifiers + [centerScrollArea] + rightIdentifiers
|
||||
|
||||
updateActiveApp()
|
||||
}
|
||||
@@ -194,12 +189,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
|
||||
func createItems() {
|
||||
for (identifier, definition) in itemDefinitions {
|
||||
let item = createItem(forIdentifier: identifier, definition: definition)
|
||||
if item is SwipeItem {
|
||||
swipeItems.append(item as! SwipeItem)
|
||||
} else {
|
||||
items[identifier] = item
|
||||
}
|
||||
items[identifier] = createItem(forIdentifier: identifier, definition: definition)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,11 +225,16 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
}
|
||||
|
||||
func touchBar(_: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
||||
if identifier == basicViewIdentifier {
|
||||
return basicView
|
||||
if identifier == centerScrollArea {
|
||||
return scrollArea
|
||||
}
|
||||
|
||||
return nil
|
||||
guard let item = self.items[identifier],
|
||||
let definition = self.itemDefinitions[identifier],
|
||||
definition.align != .center else {
|
||||
return nil
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
func createItem(forIdentifier identifier: NSTouchBarItem.Identifier, definition item: BarItemDefinition) -> NSTouchBarItem? {
|
||||
@@ -247,8 +242,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
switch item.type {
|
||||
case let .staticButton(title: title):
|
||||
barItem = CustomButtonTouchBarItem(identifier: identifier, title: title)
|
||||
case let .appleScriptTitledButton(source: source, refreshInterval: interval, alternativeImages: alternativeImages):
|
||||
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval, alternativeImages: alternativeImages)
|
||||
case let .appleScriptTitledButton(source: source, refreshInterval: interval):
|
||||
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval)
|
||||
case let .shellScriptTitledButton(source: source, refreshInterval: interval):
|
||||
barItem = ShellScriptTouchBarItem(identifier: identifier, source: source, interval: interval)
|
||||
case let .timeButton(formatTemplate: template, timeZone: timeZone, locale: locale):
|
||||
@@ -265,7 +260,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
} else {
|
||||
barItem = AppScrubberTouchBarItem(identifier: identifier, autoResize: autoResize)
|
||||
}
|
||||
case .volume:
|
||||
case .volume:
|
||||
if case let .image(source)? = item.additionalParameters[.image] {
|
||||
barItem = VolumeViewController(identifier: identifier, image: source.image)
|
||||
} else {
|
||||
@@ -287,6 +282,12 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
barItem = InputSourceBarItem(identifier: identifier)
|
||||
case let .music(interval: interval, disableMarquee: disableMarquee):
|
||||
barItem = MusicBarItem(identifier: identifier, interval: interval, disableMarquee: disableMarquee)
|
||||
case let .notification(interval: interval, disableMarquee: disableMarquee):
|
||||
if case let .image(source)? = item.additionalParameters[.image] {
|
||||
barItem = NotificationBarItem(identifier: identifier, interval: interval, disableMarquee: disableMarquee, image: source.image)
|
||||
} else {
|
||||
barItem = NotificationBarItem(identifier: identifier, interval: interval, disableMarquee: disableMarquee)
|
||||
}
|
||||
case let .group(items: items):
|
||||
barItem = GroupBarItem(identifier: identifier, items: items)
|
||||
case .nightShift:
|
||||
@@ -299,8 +300,6 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
barItem = NetworkBarItem(identifier: identifier, flip: flip)
|
||||
case .darkMode:
|
||||
barItem = DarkModeBarItem(identifier: identifier)
|
||||
case let .swipe(direction: direction, fingers: fingers, minOffset: minOffset, sourceApple: sourceApple, sourceBash: sourceBash):
|
||||
barItem = SwipeItem(identifier: identifier, direction: direction, fingers: fingers, minOffset: minOffset, sourceApple: sourceApple, sourceBash: sourceBash)
|
||||
}
|
||||
|
||||
if let action = self.action(forItem: item), let item = barItem as? CustomButtonTouchBarItem {
|
||||
|
||||
@@ -15,9 +15,6 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
private var postfix: String
|
||||
private var from: String
|
||||
private var to: String
|
||||
private var decimal: Int
|
||||
private var decimalValue: Float32!
|
||||
private var decimalString: String!
|
||||
private var oldValue: Float32!
|
||||
private var full: Bool = false
|
||||
|
||||
@@ -35,29 +32,11 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
"IDR": "Rp",
|
||||
"MXN": "$",
|
||||
"SGD": "$",
|
||||
"CHF": "Fr.",
|
||||
"BTC": "฿",
|
||||
"LTC": "Ł",
|
||||
"ETH": "Ξ",
|
||||
]
|
||||
private let decimals = [
|
||||
"USD": 4,
|
||||
"EUR": 4,
|
||||
"RUB": 2,
|
||||
"JPY": 2,
|
||||
"GBP": 4,
|
||||
"CAD": 4,
|
||||
"KRW": 4,
|
||||
"CNY": 4,
|
||||
"AUD": 4,
|
||||
"BRL": 4,
|
||||
"IDR": 1,
|
||||
"MXN": 2,
|
||||
"SGD": 4,
|
||||
"CHF": 4,
|
||||
"BTC": 2,
|
||||
"LTC": 2,
|
||||
"ETH": 2,
|
||||
]
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: String, to: String, full: Bool) {
|
||||
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
||||
@@ -78,14 +57,6 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
postfix = to
|
||||
}
|
||||
|
||||
|
||||
if let decimal = decimals[to] {
|
||||
self.decimal = decimal
|
||||
} else {
|
||||
decimal = 2
|
||||
}
|
||||
|
||||
|
||||
super.init(identifier: identifier, title: "⏳")
|
||||
|
||||
activity.repeats = true
|
||||
@@ -143,12 +114,10 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
}
|
||||
|
||||
oldValue = value
|
||||
decimalValue = (value * pow(10,Float(decimal))).rounded() / pow(10,Float(decimal))
|
||||
decimalString = String(decimalValue)
|
||||
|
||||
var title = ""
|
||||
if full {
|
||||
title = String(format: "%@%@‣%@", prefix, postfix, decimalString)
|
||||
title = String(format: "%@‣%.2f%@", prefix, value, postfix)
|
||||
} else {
|
||||
title = String(format: "%@%.2f", prefix, value)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import ScriptingBridge
|
||||
|
||||
class MusicBarItem: CustomButtonTouchBarItem {
|
||||
private enum Player: String {
|
||||
case Music = "com.apple.Music"
|
||||
case iTunes = "com.apple.iTunes"
|
||||
case Spotify = "com.spotify.client"
|
||||
case VOX = "com.coppertino.Vox"
|
||||
@@ -20,7 +19,6 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
}
|
||||
|
||||
private let playerBundleIdentifiers = [
|
||||
Player.Music,
|
||||
Player.iTunes,
|
||||
Player.Spotify,
|
||||
Player.VOX,
|
||||
@@ -73,10 +71,6 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
let mp = (musicPlayer as iTunesApplication)
|
||||
mp.playpause!()
|
||||
return
|
||||
} else if ident == .Music {
|
||||
let mp = (musicPlayer as MusicApplication)
|
||||
mp.playpause!()
|
||||
return
|
||||
} else if ident == .VOX {
|
||||
let mp = (musicPlayer as VoxApplication)
|
||||
mp.playpause!()
|
||||
@@ -140,11 +134,6 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
mp.nextTrack!()
|
||||
updatePlayer()
|
||||
return
|
||||
} else if ident == .Music {
|
||||
let mp = (musicPlayer as MusicApplication)
|
||||
mp.nextTrack!()
|
||||
updatePlayer()
|
||||
return
|
||||
} else if ident == .VOX {
|
||||
let mp = (musicPlayer as VoxApplication)
|
||||
mp.next!()
|
||||
@@ -199,8 +188,6 @@ class MusicBarItem: CustomButtonTouchBarItem {
|
||||
tempTitle = (musicPlayer as SpotifyApplication).title
|
||||
} else if ident == .iTunes {
|
||||
tempTitle = (musicPlayer as iTunesApplication).title
|
||||
} else if ident == .Music {
|
||||
tempTitle = (musicPlayer as MusicApplication).title
|
||||
} else if ident == .VOX {
|
||||
tempTitle = (musicPlayer as VoxApplication).title
|
||||
} else if ident == .Safari {
|
||||
@@ -334,29 +321,6 @@ extension iTunesApplication {
|
||||
}
|
||||
}
|
||||
|
||||
@objc protocol MusicApplication {
|
||||
@objc optional var currentTrack: MusicTrack { get }
|
||||
@objc optional func playpause()
|
||||
@objc optional func nextTrack()
|
||||
@objc optional func previousTrack()
|
||||
}
|
||||
|
||||
extension SBApplication: MusicApplication {}
|
||||
|
||||
@objc protocol MusicTrack {
|
||||
@objc optional var artist: String { get }
|
||||
@objc optional var name: String { get }
|
||||
}
|
||||
|
||||
extension SBObject: MusicTrack {}
|
||||
|
||||
extension MusicApplication {
|
||||
var title: String {
|
||||
guard let t = currentTrack else { return "" }
|
||||
return (t.artist ?? "") + " — " + (t.name ?? "")
|
||||
}
|
||||
}
|
||||
|
||||
@objc protocol VoxApplication {
|
||||
@objc optional func playpause()
|
||||
@objc optional func next()
|
||||
|
||||
@@ -0,0 +1,566 @@
|
||||
//
|
||||
// NotificationsTouchBarItem.swift
|
||||
// MTMR
|
||||
//
|
||||
// Created by Matthew Cox on 10/22/19.
|
||||
// Copyright © 2019 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Cocoa
|
||||
import ScriptingBridge
|
||||
import SQLite
|
||||
import Contacts
|
||||
import UserNotifications
|
||||
|
||||
class NotificationBarItem: CustomButtonTouchBarItem {
|
||||
public enum Message: String {
|
||||
case Messages = "com.apple.iChat"
|
||||
case Mail = "com.apple.mail"
|
||||
}
|
||||
|
||||
|
||||
private let notificationIdentifiers = [
|
||||
Message.Messages,
|
||||
Message.Mail,
|
||||
]
|
||||
|
||||
private let interval: TimeInterval
|
||||
private let disableMarquee: Bool
|
||||
private var messageText: String?
|
||||
private var messageFrom: String?
|
||||
private var timer: Timer?
|
||||
private let iconSize = NSSize(width: 21, height: 21)
|
||||
private let activity: NSBackgroundActivityScheduler
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, disableMarquee: Bool, image: NSImage? = nil) {
|
||||
|
||||
self.interval = interval
|
||||
self.disableMarquee = disableMarquee
|
||||
//tapClosure = { [weak self] in self?.DarkModeToggle() }
|
||||
if image == nil {
|
||||
//sliderItem = CustomSlider()
|
||||
} else {
|
||||
// sliderItem = CustomSlider(knob: image!)
|
||||
}
|
||||
|
||||
|
||||
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updatecheck")
|
||||
activity.interval = interval
|
||||
|
||||
super.init(identifier: identifier, title: "⏳")
|
||||
//var systemBlue: NSColor { set }
|
||||
isBordered = false
|
||||
backgroundColor = NSColor.systemRed
|
||||
//button = item.view as? NSButton else { continue }
|
||||
|
||||
//let textRange = NSRange(location: 0, length: button.title.characters.count)
|
||||
//let titleColor = useCustomColor.state == NSControl.StateValue.on ? NSColor.black : NSColor.white
|
||||
//let newTitle = NSMutableAttributedString(string: button.title)
|
||||
//newTitle.addAttribute(NSAttributedStringKey.foregroundColor, value: titleColor, range: textRange)
|
||||
//newTitle.addAttribute(NSAttributedStringKey.font, value: button.font!, range: textRange)
|
||||
//newTitle.setAlignment(.center, range: textRange)
|
||||
//button.attributedTitle = newTitle
|
||||
//attributedTitle = "test"
|
||||
//image = NSImage(name: NSUserGroup)
|
||||
//title = "\(Noti.0)"
|
||||
// func getDeliveredNotifications(completionHandler: @escaping ([UNNotification]) -> Void) {
|
||||
// print("")
|
||||
// }
|
||||
// let notificationCenter = UNUserNotificationCenter.current()
|
||||
|
||||
// notificationCenter.requestAuthorization(options: [.alert, .badge, .provisional]) {}
|
||||
|
||||
// UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in
|
||||
// print("Noti")
|
||||
// print(notifications)
|
||||
|
||||
// }
|
||||
|
||||
/* let center = UNUserNotificationCenter.current()
|
||||
let options: UNAuthorizationOptions = [.alert, .badge, .sound]
|
||||
center.requestAuthorization(options: options) { (granted, error) in
|
||||
if granted {
|
||||
application.registerForRemoteNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||
let actionIdentifier = response.actionIdentifier
|
||||
let content = response.notification.request.content
|
||||
print("\(content)")
|
||||
switch actionIdentifier {
|
||||
case UNNotificationDismissActionIdentifier: // Notification was dismissed by user
|
||||
// Do something
|
||||
completionHandler()
|
||||
case UNNotificationDefaultActionIdentifier: // App was opened from notification
|
||||
// Do something
|
||||
completionHandler()
|
||||
case "com.usernotificationstutorial.reply":
|
||||
if let textResponse = response as? UNTextInputNotificationResponse {
|
||||
let reply = textResponse.userText
|
||||
// Send reply message
|
||||
completionHandler()
|
||||
}
|
||||
case "com.usernotificationstutorial.delete":
|
||||
// Delete message
|
||||
completionHandler()
|
||||
default:
|
||||
completionHandler()
|
||||
}
|
||||
|
||||
*/
|
||||
/*let replyAction = UNTextInputNotificationAction(identifier: "com.usernotificationstutorial.reply", title: "Reply", options: [], textInputButtonTitle: "Send", textInputPlaceholder: "Type your message")
|
||||
let deleteAction = UNNotificationAction(identifier: "com.usernotificationstutorial.delete", title: "Delete", options: [.authenticationRequired, .destructive])
|
||||
let category = UNNotificationCategory(identifier: "com.usernotificationstutorial.message", actions: [replyAction, deleteAction], intentIdentifiers: [], options: [])
|
||||
center.setNotificationCategories([category])
|
||||
|
||||
}
|
||||
|
||||
userNotificationCenter(center: center)
|
||||
*/
|
||||
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 indexSecond = str.index(str.startIndex, offsetBy: 1)
|
||||
title = String(str.suffix(from: indexSecond)) + String(str[indexFirst])
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder _: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@objc func playPause() {
|
||||
for ident in notificationIdentifiers {
|
||||
if let messageApplication = SBApplication(bundleIdentifier: ident.rawValue) {
|
||||
if messageApplication.isRunning {
|
||||
if ident == .Messages {
|
||||
let mp = (messageApplication as MessagesApplication)
|
||||
mp.playpause!()
|
||||
return
|
||||
} else if ident == .Mail {
|
||||
let mp = (messageApplication as MailApplication)
|
||||
mp.playpause!()
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func nextTrack() {
|
||||
for ident in notificationIdentifiers {
|
||||
if let messageApplication = SBApplication(bundleIdentifier: ident.rawValue) {
|
||||
if messageApplication.isRunning {
|
||||
if ident == .Messages {
|
||||
let mp = (messageApplication as MessagesApplication)
|
||||
mp.nextTrack!()
|
||||
updateNotification()
|
||||
return
|
||||
} else if ident == .Mail {
|
||||
let mp = (messageApplication as MailApplication)
|
||||
mp.nextTrack!()
|
||||
updateNotification()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func refreshAndSchedule() {
|
||||
DispatchQueue.main.async {
|
||||
self.updateNotification()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + self.interval) { [weak self] in
|
||||
self?.refreshAndSchedule()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func updateNotification() {
|
||||
var iconUpdated = false
|
||||
var titleUpdated = false
|
||||
var notificationbuilder = ""
|
||||
|
||||
let name = ""
|
||||
let message = ""
|
||||
let durl = ""
|
||||
let person = ""
|
||||
let dbpath = ""
|
||||
let Noti = NotiBar().getAll(name: name, message: message, durl: durl, person: person, dbpath: dbpath)
|
||||
//let lastNotificationItem = ""
|
||||
|
||||
print("\(Noti.0) \(Noti.1) \(Noti.3)")
|
||||
//icon \(Noti.0)
|
||||
//Message \(Noti.1)
|
||||
//button path \(Noti.2)
|
||||
//Number \(Noti.3)
|
||||
let fromBox = String(Noti.3)
|
||||
let messageBox = String(Noti.1)
|
||||
|
||||
if fromBox.isEmpty
|
||||
{
|
||||
notificationbuilder = ""
|
||||
}
|
||||
else
|
||||
{
|
||||
notificationbuilder = "\(fromBox) - \(messageBox)"
|
||||
}
|
||||
|
||||
let lastNotificationItem = "\(notificationbuilder)"
|
||||
|
||||
for ident in notificationIdentifiers {
|
||||
if let messageApplication = SBApplication(bundleIdentifier: ident.rawValue) {
|
||||
if messageApplication.isRunning {
|
||||
|
||||
var tempTitle = ""
|
||||
if ident == .Messages {
|
||||
tempTitle = lastNotificationItem
|
||||
} else if ident == .Mail {
|
||||
tempTitle = (messageApplication as MailApplication).title
|
||||
}
|
||||
|
||||
if tempTitle == self.messageText {
|
||||
return
|
||||
} else {
|
||||
self.messageText = tempTitle
|
||||
}
|
||||
|
||||
if let messageText = self.messageText?.ifNotEmpty {
|
||||
self.timer?.invalidate()
|
||||
self.timer = nil
|
||||
|
||||
if (disableMarquee) {
|
||||
self.title = " " + messageText
|
||||
} else {
|
||||
self.title = " " + messageText + " "
|
||||
self.timer = Timer.scheduledTimer(timeInterval: 0.25, target: self, selector: #selector(self.marquee), userInfo: nil, repeats: true)
|
||||
}
|
||||
|
||||
titleUpdated = true
|
||||
}
|
||||
if let _ = tempTitle.ifNotEmpty,
|
||||
let appPath = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: ident.rawValue) {
|
||||
let image = NSWorkspace.shared.icon(forFile: appPath)
|
||||
image.size = self.iconSize
|
||||
self.image = image
|
||||
iconUpdated = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if !iconUpdated {
|
||||
self.image = nil
|
||||
}
|
||||
|
||||
if !titleUpdated {
|
||||
self.title = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class NotiRun {
|
||||
static func shell(launchPath path: String, arguments args: [String]) -> String {
|
||||
let task = Process()
|
||||
task.launchPath = path
|
||||
task.arguments = args
|
||||
|
||||
let pipe = Pipe()
|
||||
task.standardOutput = pipe
|
||||
task.standardError = pipe
|
||||
task.launch()
|
||||
|
||||
let data = pipe.fileHandleForReading.readDataToEndOfFile()
|
||||
let output = String(data: data, encoding: .utf8)
|
||||
task.waitUntilExit()
|
||||
|
||||
return(output!)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NotiBar
|
||||
{
|
||||
|
||||
func getAll(name:String, message:String, durl: String, person:String, dbpath: String) -> (String, String, String, String, String)
|
||||
{
|
||||
|
||||
let res = NotiRun.shell(launchPath: "/usr/bin/getconf", arguments: ["DARWIN_USER_DIR"])
|
||||
let trimmedres = res.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let db = try! Connection("\(trimmedres)com.apple.notificationcenter/db2/db")
|
||||
|
||||
let record = Table("record")
|
||||
let app = Table("app")
|
||||
let presented = Expression<Int?>("presented")
|
||||
let identifier = Expression<String?>("identifier")
|
||||
let delivered_date = Expression<Int?>("delivered_date")
|
||||
let app_id = Expression<Int?>("app_id")
|
||||
// let app_id = Expression<Int64>("app_id")
|
||||
let data = Expression<Data>("data")
|
||||
var name = ""
|
||||
var message = ""
|
||||
var durl = ""
|
||||
var person = ""
|
||||
var dbpath = ""
|
||||
let timestamp = Int(NSDate().timeIntervalSinceReferenceDate - 86400)
|
||||
//var image = ""
|
||||
//var reply = ""
|
||||
//var dismiss = ""
|
||||
//var other = ""
|
||||
let Messages = String("com.apple.iChat")
|
||||
let Mail = String("com.apple.mail")
|
||||
|
||||
for app in try! db.prepare(app.select(app[*]))
|
||||
{
|
||||
if ("\(app[identifier]!)" == Messages)
|
||||
{
|
||||
|
||||
}
|
||||
if ("\(app[identifier]!)" == Mail)
|
||||
{
|
||||
|
||||
}
|
||||
// Messages
|
||||
// Mail
|
||||
}
|
||||
// print("\(timestamp)")
|
||||
//for record in try! db.prepare(record.join(app, on: record[app_id] == app[app_id]).select(record[*]).filter(delivered_date > timestamp) ) {
|
||||
//app_id == 4 ||
|
||||
for record in try! db.prepare(record.select(record[*]).filter(delivered_date > timestamp && app_id == 5) ) {
|
||||
|
||||
guard let notifierout = try? PropertyListSerialization.propertyList(from: record[data], options: [], format: nil) else {
|
||||
fatalError("failed to deserialize")
|
||||
}
|
||||
if let notiDescAppName = (notifierout as AnyObject)["app"]! as? String
|
||||
{
|
||||
if let ret = self.getPath(appNamedNew: "\(notiDescAppName)") {
|
||||
let retfix = ("\(ret)")
|
||||
let rettrimmed = retfix.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
let notifierbuilder = Bundle(url: URL(fileURLWithPath: "\(rettrimmed)"))?.infoDictionary?["CFBundleDisplayName"] as? String ?? Bundle(url: URL(fileURLWithPath: "\(rettrimmed)"))?.infoDictionary?["CFBundleName"] as? String
|
||||
if notifierbuilder == nil
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (notifierbuilder == "Messages" || notifierbuilder == "Mail")
|
||||
{
|
||||
if (notifierbuilder == "Messages")
|
||||
{
|
||||
name = "💬"
|
||||
}
|
||||
else if notifierbuilder == "Mail"
|
||||
{
|
||||
name = "✉️"
|
||||
}
|
||||
|
||||
if let notiDescAppMessageTop = (notifierout as AnyObject)["req"]! as? AnyObject
|
||||
{
|
||||
if let notiDescAppMail = (notiDescAppMessageTop as AnyObject)["subt"]! as? String
|
||||
{
|
||||
message = notiDescAppMail
|
||||
}
|
||||
else if let notiDescAppMessage = (notiDescAppMessageTop as AnyObject)["body"]! as? String
|
||||
{
|
||||
message = notiDescAppMessage
|
||||
}
|
||||
}
|
||||
if let notiDescAppURLTop = (notifierout as AnyObject)["req"]! as? AnyObject
|
||||
{
|
||||
if let notiDescAppURL = (notiDescAppURLTop as AnyObject)["durl"]! as? String
|
||||
{
|
||||
durl = notiDescAppURL
|
||||
}
|
||||
}
|
||||
if let notiDescAppPersonTop = (notifierout as AnyObject)["req"]! as? AnyObject
|
||||
{
|
||||
if let notiDescAppPerson = (notiDescAppPersonTop as AnyObject)["titl"]! as? String
|
||||
{
|
||||
|
||||
person = notiDescAppPerson
|
||||
}
|
||||
// let imagee = getContactImage(imgu: "\(person)")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = notifierbuilder!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dbpath = "\(trimmedres)com.apple.notificationcenter/db2/db"
|
||||
}
|
||||
//print("\(name)-\(message)-\(durl)-\(person)-\(dbpath)")
|
||||
return (name, message, durl, person, dbpath)
|
||||
}
|
||||
// static func getImage(image: String) -> String
|
||||
//{
|
||||
|
||||
//}
|
||||
//static func getOptionReply(reply: String) -> String
|
||||
//{
|
||||
|
||||
//}
|
||||
//static func getOptionDismiss(dismiss: String) -> String
|
||||
//{
|
||||
|
||||
//}
|
||||
//static func getOptionOther(otNSView()her: String) -> String
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
func getPath(appNamedNew: String) -> String? {
|
||||
|
||||
if let absopath = NSWorkspace.shared.absolutePathForApplication(withBundleIdentifier: appNamedNew) {
|
||||
return "\(absopath)"
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func lastModified(path: String) -> NSDate? {
|
||||
let fileUrl = NSURL(fileURLWithPath: path)
|
||||
var modified: AnyObject?
|
||||
do {
|
||||
try fileUrl.getResourceValue(&modified, forKey: URLResourceKey.contentModificationDateKey)
|
||||
return modified as? NSDate
|
||||
} catch let error as NSError {
|
||||
print("\(#function) Error: \(error)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func getContactImage(imgu:String) -> NSImage?
|
||||
{
|
||||
let store = CNContactStore()
|
||||
//let contactStore = CNContactStore()
|
||||
let keys = [CNContactPhoneNumbersKey, CNContactFamilyNameKey, CNContactGivenNameKey, CNContactNicknameKey, CNContactImageDataKey] as! CNKeyDescriptor
|
||||
// let request = CNContactFetchRequest(keysToFetch: keys)
|
||||
|
||||
// try? contactStore.enumerateContacts(with: request) { (contact, error) in
|
||||
|
||||
// Do something with contact
|
||||
|
||||
//}
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
let contacts = try! store.unifiedContacts(matching: CNContact.predicateForContacts(matchingName: imgu), keysToFetch:[keys])
|
||||
|
||||
if contacts.count > 0
|
||||
{
|
||||
if let image = contacts[0].imageData
|
||||
{
|
||||
return NSImage.init(data: image)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@objc protocol MessagesApplication {
|
||||
@objc optional var currentTrack: SpotifyTrack { get }
|
||||
@objc optional func nextTrack()
|
||||
@objc optional func previousTrack()
|
||||
@objc optional func playpause()
|
||||
}
|
||||
|
||||
extension SBApplication: MessagesApplication {}
|
||||
|
||||
@objc protocol MessagesTrack {
|
||||
@objc optional var artist: String { get }
|
||||
@objc optional var name: String { get }
|
||||
}
|
||||
|
||||
extension SBObject: MessagesTrack {}
|
||||
|
||||
extension MessagesApplication {
|
||||
var title: String {
|
||||
guard let t = currentTrack else { return "" }
|
||||
return (t.artist ?? "") + " — " + (t.name ?? "")
|
||||
}
|
||||
}
|
||||
|
||||
@objc protocol MailApplication {
|
||||
@objc optional var currentTrack: MailTrack { get }
|
||||
@objc optional func playpause()
|
||||
@objc optional func nextTrack()
|
||||
@objc optional func previousTrack()
|
||||
}
|
||||
|
||||
extension SBApplication: MailApplication {}
|
||||
|
||||
@objc protocol MailTrack {
|
||||
@objc optional var artist: String { get }
|
||||
@objc optional var name: String { get }
|
||||
}
|
||||
|
||||
extension SBObject: MailTrack {}
|
||||
|
||||
extension MailApplication {
|
||||
var title: String {
|
||||
guard let t = currentTrack else { return "" }
|
||||
return (t.artist ?? "") + " — " + (t.name ?? "")
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class PomodoroBarItem: CustomButtonTouchBarItem, Widget {
|
||||
case none
|
||||
}
|
||||
|
||||
private let defaultTitle = "🍅 "
|
||||
private let defaultTitle = "🍅"
|
||||
private let workTime: TimeInterval
|
||||
private let restTime: TimeInterval
|
||||
private var typeTime: TimeTypes = .none
|
||||
|
||||
@@ -12,10 +12,7 @@ import CoreLocation
|
||||
class YandexWeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
|
||||
private let activity: NSBackgroundActivityScheduler
|
||||
private let unitsStr = "°C"
|
||||
private let iconsSource = [
|
||||
"Ясно": "☀️", "Малооблачно": "🌤", "Облачно с прояснениями": "⛅️", "Пасмурно": "☁️", "Небольшой дождь": "🌦", "Дождь": "🌧", "Ливень": "⛈", "Гроза": "🌩", "Дождь со снегом": "☔️", "Небольшой снег": "❄️", "Снег": "🌨", "Туман": "🌫",
|
||||
"Clear": "☀️", "Mostly clear": "🌤", "Partly cloudy": "⛅️", "Overcast": "☁️", "Light rain": "🌦", "Rain": "🌧", "Heavy rain": "⛈", "Storm": "🌩", "Sleet": "☔️", "Light snow": "❄️", "Snow": "🌨", "Fog": "🌫"
|
||||
]
|
||||
private let iconsSource = ["Ясно": "☀️", "Малооблачно": "🌤", "Облачно с прояснениями": "⛅️", "Пасмурно": "☁️", "Небольшой дождь": "🌦", "Дождь": "🌧", "Ливень": "⛈", "Гроза": "🌩", "Дождь со снегом": "☔️", "Небольшой снег": "❄️", "Снег": "🌨", "Туман": "🌫"]
|
||||
private var location: CLLocation!
|
||||
private var prevLocation: CLLocation!
|
||||
private var manager: CLLocationManager!
|
||||
|
||||
@@ -28,26 +28,6 @@
|
||||
}
|
||||
},
|
||||
|
||||
// Music
|
||||
{
|
||||
"type": "appleScriptTitledButton",
|
||||
"source": {
|
||||
"inline": "if application \"Music\" is running then\rtell application \"Music\"\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 \"Music\" is running then\rtell application \"Music\"\rif player state is playing then\rnext track\rend if\rend tell\rend if\r"
|
||||
},
|
||||
"longAction": "appleScript",
|
||||
"longActionAppleScript": {
|
||||
"inline": "if application \"Music\" is running then\rtell application \"Music\"\rif player state is playing then\rprev track\rend if\rend tell\rend if\r"
|
||||
},
|
||||
"refreshInterval": 2,
|
||||
"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=="
|
||||
}
|
||||
},
|
||||
|
||||
// iTunes
|
||||
{
|
||||
"type": "appleScriptTitledButton",
|
||||
|
||||
@@ -6,7 +6,7 @@ class AppleScriptDefinitionTests: XCTestCase {
|
||||
[ { "type": "appleScriptTitledButton", "source": { "inline": "tell everything fine" } } ]
|
||||
""".data(using: .utf8)!
|
||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
||||
guard case .appleScriptTitledButton(let source, _, _)? = result?.first?.type else {
|
||||
guard case .appleScriptTitledButton(let source, _)? = result?.first?.type else {
|
||||
XCTFail()
|
||||
return
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class AppleScriptDefinitionTests: XCTestCase {
|
||||
[ { "type": "appleScriptTitledButton", "source": { "filePath": "/ololo/pew" } } ]
|
||||
""".data(using: .utf8)!
|
||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
||||
guard case .appleScriptTitledButton(let source, _, _)? = result?.first?.type else {
|
||||
guard case .appleScriptTitledButton(let source, _)? = result?.first?.type else {
|
||||
XCTFail()
|
||||
return
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class AppleScriptDefinitionTests: XCTestCase {
|
||||
[ { "type": "appleScriptTitledButton", "source": { "filePath": "~/pew" } } ]
|
||||
""".data(using: .utf8)!
|
||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
||||
guard case .appleScriptTitledButton(let source, _, _)? = result?.first?.type else {
|
||||
guard case .appleScriptTitledButton(let source, _)? = result?.first?.type else {
|
||||
XCTFail()
|
||||
return
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class AppleScriptDefinitionTests: XCTestCase {
|
||||
[ { "type": "appleScriptTitledButton", "source": { "inline": "tell everything fine" }, "refreshInterval": 305} ]
|
||||
""".data(using: .utf8)!
|
||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
||||
guard case .appleScriptTitledButton(_, 305, _)? = result?.first?.type else {
|
||||
guard case .appleScriptTitledButton(_, 305)? = result?.first?.type else {
|
||||
XCTFail()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -102,31 +102,11 @@ The pre-installed configuration contains less or more than you'll probably want,
|
||||
- appleScriptTitledButton
|
||||
- shellScriptTitledButton
|
||||
|
||||
## Gestures
|
||||
## Gestures on central part:
|
||||
|
||||
By default you can enable basic gestures from application menu (status bar -> MTMR icon -> Volume/Brightness gestures):
|
||||
- two finger slide: change you Volume
|
||||
- three finger slide: change you Brightness
|
||||
|
||||
### Custom gestures
|
||||
|
||||
You can add custom actions for two/three/four finger swipes. To do it, you need to use `swipe` type:
|
||||
|
||||
```json
|
||||
"type": "swipe",
|
||||
"fingers": 2, // number of fingers required (2,3 or 4)
|
||||
"direction": "right", // direction of swipe (right/left)
|
||||
"minOffset" 10, // optional: minimal required offset for gesture to emit event
|
||||
"sourceApple": { // optional: apple script to run
|
||||
"inline": "beep"
|
||||
},
|
||||
"sourceBash": { // optional: bash script to run
|
||||
"inline": "touch /Users/lobster/test"
|
||||
}
|
||||
```
|
||||
|
||||
You may create as many `swipe` objects in the preset as you want.
|
||||
|
||||
## Built-in slider types:
|
||||
|
||||
- brightness
|
||||
@@ -153,35 +133,8 @@ You may create as many `swipe` objects in the preset as you want.
|
||||
"inline": "tell application \"Finder\"\rif not (exists window 1) then\rmake new Finder window\rset target of front window to path to home folder as string\rend if\ractivate\rend tell",
|
||||
// or
|
||||
"base64": "StringInbase64"
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
> Note: appleScriptTitledButton can change its icon. To do it, you need to do the following things:
|
||||
1. Declarate dictionary of icons in `alternativeImages` field
|
||||
2. Make you script return array of two values - `{"TITLE", "IMAGE_LABEL"}`
|
||||
3. Make sure that your `IMAGE_LABEL` is declared in `alternativeImages` field
|
||||
|
||||
Example:
|
||||
```js
|
||||
{
|
||||
"type": "appleScriptTitledButton",
|
||||
"source": {
|
||||
"inline": "if (random number from 1 to 2) = 1 then\n\tset val to {\"title\", \"play\"}\nelse\n\tset val to {\"title\", \"pause\"}\nend if\nreturn val"
|
||||
},
|
||||
"refreshInterval": 1,
|
||||
"image": {
|
||||
"base64": "iVBORw0KGgoAAAANSUhEUgA..."
|
||||
},
|
||||
"alternativeImages": {
|
||||
"play": {
|
||||
"base64": "iVBORw0KGgoAAAANSUhEUgAAAAAA..."
|
||||
},
|
||||
"pause": {
|
||||
"base64": "iVBORw0KGgoAAAANSUhEUgAAAIAA..."
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
#### `shellScriptTitledButton`
|
||||
@@ -422,31 +375,6 @@ If you want to longPress for some operations, it is similar to the configuration
|
||||
"bordered": "false" // "true" or "false"
|
||||
```
|
||||
|
||||
- `background` allow to specify you button background color
|
||||
|
||||
```js
|
||||
"background": "#FF0000",
|
||||
```
|
||||
by using background with color "#000000" and bordered == false you can create button without gray background but with background when the button is pressed
|
||||
|
||||
- `title` specify button title
|
||||
|
||||
```js
|
||||
"title": "hello"
|
||||
```
|
||||
|
||||
- `image` specify button icon
|
||||
|
||||
```js
|
||||
"image": {
|
||||
//Can be either of those
|
||||
"base64": "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAABGdB...."
|
||||
//or
|
||||
"filePath": "~/img.png"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Roadmap
|
||||
|
||||
- [x] Create the first prototype with TouchBar in Storyboard
|
||||
@@ -475,7 +403,7 @@ Settings:
|
||||
- [x] Startup at login
|
||||
- [ ] Show on/off in Dock
|
||||
- [ ] Show on/off in StatusBar
|
||||
- [ x] On/off Haptic Feedback
|
||||
- [ ] On/off Haptic Feedback
|
||||
|
||||
Maybe:
|
||||
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
# INSTALL xcpretty: sudo gem install xcpretty
|
||||
|
||||
NAME='MTMR'
|
||||
|
||||
rm -r Release 2>/dev/null
|
||||
|
||||
xcodebuild archive \
|
||||
-scheme "$NAME" \
|
||||
-archivePath Release/App.xcarchive | xcpretty -c
|
||||
-archivePath Release/App.xcarchive
|
||||
|
||||
xcodebuild \
|
||||
-exportArchive \
|
||||
-archivePath Release/App.xcarchive \
|
||||
-exportOptionsPlist export-options.plist \
|
||||
-exportPath Release | xcpretty -c
|
||||
-exportPath Release
|
||||
|
||||
cd Release
|
||||
rm -r App.xcarchive
|
||||
@@ -22,7 +20,7 @@ NAME_DMG="${NAME}.app"
|
||||
echo $NAME_DMG
|
||||
create-dmg $NAME_DMG
|
||||
|
||||
DATE=`LC_ALL=en_US.utf8 date +"%a, %d %b %Y %H:%M:%S %z"`
|
||||
DATE=`date +"%a, %d %b %Y %H:%M:%S %z"`
|
||||
BUILD=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ${NAME}.app/Contents/Info.plist`
|
||||
VERSION=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" ${NAME}.app/Contents/Info.plist`
|
||||
MINIMUM=`/usr/libexec/PlistBuddy -c "Print LSMinimumSystemVersion" ${NAME}.app/Contents/Info.plist`
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# INSTALL xcpretty: sudo gem install xcpretty
|
||||
|
||||
NAME='MTMR'
|
||||
killall $NAME
|
||||
@@ -12,13 +11,13 @@ rm -r Release 2>/dev/null
|
||||
|
||||
xcodebuild archive \
|
||||
-scheme "$NAME" \
|
||||
-archivePath Release/App.xcarchive | xcpretty
|
||||
-archivePath Release/App.xcarchive
|
||||
|
||||
xcodebuild \
|
||||
-exportArchive \
|
||||
-archivePath Release/App.xcarchive \
|
||||
-exportOptionsPlist export-options.plist \
|
||||
-exportPath Release | xcpretty
|
||||
-exportPath Release
|
||||
|
||||
cd Release
|
||||
rm -r App.xcarchive
|
||||
|
||||
Reference in New Issue
Block a user