diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46dd32b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +xcuserdata +.DS_Store +node_modules +*.dmg +*.xcarchive diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0fb4e4b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +osx_image: xcode9.3 +language: objective-c + +script: ./build.sh diff --git a/Icons/.gitignore b/Icons/.gitignore new file mode 100644 index 0000000..1aff6a5 --- /dev/null +++ b/Icons/.gitignore @@ -0,0 +1 @@ +*.iconset diff --git a/Icons/README.md b/Icons/README.md new file mode 100644 index 0000000..7c83ca6 --- /dev/null +++ b/Icons/README.md @@ -0,0 +1 @@ +Images are downloaded from https://icons8.com/icon/1810/tomato diff --git a/Icons/convert.sh b/Icons/convert.sh new file mode 100755 index 0000000..1899f28 --- /dev/null +++ b/Icons/convert.sh @@ -0,0 +1,23 @@ +#!/bin/bash -e +APPICON_SRC=tomato.png +APPICON_ICONSET=tomato.iconset +BARICON_SRC=tomato-filled.png +BARICON_ICONSET=tomato-filled.iconset + +CONVERT="convert -background none -trim +repage" + +rm -rf ${APPICON_ICONSET} ${BARICON_ICONSET} +mkdir ${APPICON_ICONSET} ${BARICON_ICONSET} +${CONVERT} -resize '!16x16' ${APPICON_SRC} ${APPICON_ICONSET}/icon_16x16.png +${CONVERT} -resize '!32x32' ${APPICON_SRC} ${APPICON_ICONSET}/icon_16x16@2x.png +${CONVERT} -resize '!32x32' ${APPICON_SRC} ${APPICON_ICONSET}/icon_32x32.png +${CONVERT} -resize '!64x64' ${APPICON_SRC} ${APPICON_ICONSET}/icon_32x32@2x.png +${CONVERT} -resize '!128x128' ${APPICON_SRC} ${APPICON_ICONSET}/icon_128x128.png +${CONVERT} -resize '!256x256' ${APPICON_SRC} ${APPICON_ICONSET}/icon_128x128@2x.png +${CONVERT} -resize '!256x256' ${APPICON_SRC} ${APPICON_ICONSET}/icon_256x256.png +${CONVERT} -resize '!512x512' ${APPICON_SRC} ${APPICON_ICONSET}/icon_256x256@2x.png +${CONVERT} -resize '!512x512' ${APPICON_SRC} ${APPICON_ICONSET}/icon_512x512.png +${CONVERT} -resize '!1024x1024' ${APPICON_SRC} ${APPICON_ICONSET}/icon_512x512@2x.png +${CONVERT} -resize '!16x16' ${BARICON_SRC} ${BARICON_ICONSET}/icon_16x16.png +${CONVERT} -resize '!32x32' ${BARICON_SRC} ${BARICON_ICONSET}/icon_16x16@2x.png +${CONVERT} -resize '!48x48' ${BARICON_SRC} ${BARICON_ICONSET}/icon_16x16@3x.png diff --git a/Icons/tomato-filled.png b/Icons/tomato-filled.png new file mode 100644 index 0000000..c1e4f9b Binary files /dev/null and b/Icons/tomato-filled.png differ diff --git a/Icons/tomato.png b/Icons/tomato.png new file mode 100644 index 0000000..57973ab Binary files /dev/null and b/Icons/tomato.png differ diff --git a/TomatoBar.xcodeproj/project.pbxproj b/TomatoBar.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2c71729 --- /dev/null +++ b/TomatoBar.xcodeproj/project.pbxproj @@ -0,0 +1,370 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 8A112DDA2099E8AE00DDBDD0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A112DD92099E8AE00DDBDD0 /* AppDelegate.swift */; }; + 8A112DDE2099E8B000DDBDD0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8A112DDD2099E8B000DDBDD0 /* Assets.xcassets */; }; + 8A112DEA2099F1A500DDBDD0 /* TomatoBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8A112DE92099F1A500DDBDD0 /* TomatoBar.xib */; }; + 8A112E0A2099FB8000DDBDD0 /* DFRFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A112E092099FB8000DDBDD0 /* DFRFoundation.framework */; }; + 8A112E0C2099FD1A00DDBDD0 /* TomatoBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A112E0B2099FD1A00DDBDD0 /* TomatoBarController.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 8A112DD62099E8AE00DDBDD0 /* Tomato Bar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Tomato Bar.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 8A112DD92099E8AE00DDBDD0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 8A112DDD2099E8B000DDBDD0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 8A112DE22099E8B100DDBDD0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 8A112DE32099E8B100DDBDD0 /* TomatoBar.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TomatoBar.entitlements; sourceTree = ""; }; + 8A112DE92099F1A500DDBDD0 /* TomatoBar.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TomatoBar.xib; sourceTree = ""; }; + 8A112E052099F8A000DDBDD0 /* TouchBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBar.h; sourceTree = ""; }; + 8A112E072099F9D000DDBDD0 /* BridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BridgingHeader.h; sourceTree = ""; }; + 8A112E092099FB8000DDBDD0 /* DFRFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DFRFoundation.framework; path = ../../../../System/Library/PrivateFrameworks/DFRFoundation.framework; sourceTree = ""; }; + 8A112E0B2099FD1A00DDBDD0 /* TomatoBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TomatoBarController.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8A112DD32099E8AE00DDBDD0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8A112E0A2099FB8000DDBDD0 /* DFRFoundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 8A112DCD2099E8AE00DDBDD0 = { + isa = PBXGroup; + children = ( + 8A112DD82099E8AE00DDBDD0 /* TomatoBar */, + 8A112DD72099E8AE00DDBDD0 /* Products */, + 8A112E082099FB7F00DDBDD0 /* Frameworks */, + ); + sourceTree = ""; + }; + 8A112DD72099E8AE00DDBDD0 /* Products */ = { + isa = PBXGroup; + children = ( + 8A112DD62099E8AE00DDBDD0 /* Tomato Bar.app */, + ); + name = Products; + sourceTree = ""; + }; + 8A112DD82099E8AE00DDBDD0 /* TomatoBar */ = { + isa = PBXGroup; + children = ( + 8A112DD92099E8AE00DDBDD0 /* AppDelegate.swift */, + 8A112E0B2099FD1A00DDBDD0 /* TomatoBarController.swift */, + 8A112DE92099F1A500DDBDD0 /* TomatoBar.xib */, + 8A112DDD2099E8B000DDBDD0 /* Assets.xcassets */, + 8A112DE22099E8B100DDBDD0 /* Info.plist */, + 8A112DE32099E8B100DDBDD0 /* TomatoBar.entitlements */, + 8A112E052099F8A000DDBDD0 /* TouchBar.h */, + 8A112E072099F9D000DDBDD0 /* BridgingHeader.h */, + ); + path = TomatoBar; + sourceTree = ""; + }; + 8A112E082099FB7F00DDBDD0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 8A112E092099FB8000DDBDD0 /* DFRFoundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8A112DD52099E8AE00DDBDD0 /* Tomato Bar */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8A112DE62099E8B100DDBDD0 /* Build configuration list for PBXNativeTarget "Tomato Bar" */; + buildPhases = ( + 8A112DD22099E8AE00DDBDD0 /* Sources */, + 8A112DD32099E8AE00DDBDD0 /* Frameworks */, + 8A112DD42099E8AE00DDBDD0 /* Resources */, + 8A112E0F209A0BCE00DDBDD0 /* Swiftlint */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Tomato Bar"; + productName = "Tomato Bar"; + productReference = 8A112DD62099E8AE00DDBDD0 /* Tomato Bar.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 8A112DCE2099E8AE00DDBDD0 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0930; + LastUpgradeCheck = 0930; + ORGANIZATIONNAME = "Ilya Voronin"; + TargetAttributes = { + 8A112DD52099E8AE00DDBDD0 = { + CreatedOnToolsVersion = 9.3; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + }; + }; + buildConfigurationList = 8A112DD12099E8AE00DDBDD0 /* Build configuration list for PBXProject "TomatoBar" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 8A112DCD2099E8AE00DDBDD0; + productRefGroup = 8A112DD72099E8AE00DDBDD0 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8A112DD52099E8AE00DDBDD0 /* Tomato Bar */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8A112DD42099E8AE00DDBDD0 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8A112DEA2099F1A500DDBDD0 /* TomatoBar.xib in Resources */, + 8A112DDE2099E8B000DDBDD0 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 8A112E0F209A0BCE00DDBDD0 /* Swiftlint */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = Swiftlint; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "[ \"${CI}\" ] || swiftlint --enable-all-rules"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8A112DD22099E8AE00DDBDD0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8A112DDA2099E8AE00DDBDD0 /* AppDelegate.swift in Sources */, + 8A112E0C2099FD1A00DDBDD0 /* TomatoBarController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 8A112DE42099E8B100DDBDD0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 8A112DE52099E8B100DDBDD0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "Mac Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.13; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 8A112DE72099E8B100DDBDD0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = TomatoBar/TomatoBar.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 4C6H8UTMAG; + INFOPLIST_FILE = TomatoBar/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.12.2; + PRODUCT_BUNDLE_IDENTIFIER = com.github.ivoronin.TomatoBar; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = TomatoBar/BridgingHeader.h; + SWIFT_VERSION = 4.0; + SYSTEM_FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", + ); + }; + name = Debug; + }; + 8A112DE82099E8B100DDBDD0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = TomatoBar/TomatoBar.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 4C6H8UTMAG; + INFOPLIST_FILE = TomatoBar/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.12.2; + PRODUCT_BUNDLE_IDENTIFIER = com.github.ivoronin.TomatoBar; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = TomatoBar/BridgingHeader.h; + SWIFT_VERSION = 4.0; + SYSTEM_FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", + ); + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 8A112DD12099E8AE00DDBDD0 /* Build configuration list for PBXProject "TomatoBar" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8A112DE42099E8B100DDBDD0 /* Debug */, + 8A112DE52099E8B100DDBDD0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8A112DE62099E8B100DDBDD0 /* Build configuration list for PBXNativeTarget "Tomato Bar" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8A112DE72099E8B100DDBDD0 /* Debug */, + 8A112DE82099E8B100DDBDD0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 8A112DCE2099E8AE00DDBDD0 /* Project object */; +} diff --git a/TomatoBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/TomatoBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..18f9a4f --- /dev/null +++ b/TomatoBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/TomatoBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/TomatoBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/TomatoBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/TomatoBar/AppDelegate.swift b/TomatoBar/AppDelegate.swift new file mode 100644 index 0000000..cb743b5 --- /dev/null +++ b/TomatoBar/AppDelegate.swift @@ -0,0 +1,10 @@ +import Cocoa + +@NSApplicationMain +public class AppDelegate: NSObject, NSApplicationDelegate { + public func applicationDidFinishLaunching(_ aNotification: Notification) { + } + + public func applicationWillTerminate(_ aNotification: Notification) { + } +} diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/Contents.json b/TomatoBar/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..7cd4f8e --- /dev/null +++ b/TomatoBar/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "icon_16x16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "icon_16x16@2x.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "icon_32x32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "icon_32x32@2x.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "icon_128x128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "icon_128x128@2x.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "icon_256x256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "icon_256x256@2x.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "icon_512x512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "icon_512x512@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_128x128.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_128x128.png new file mode 100644 index 0000000..abffa36 Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_128x128.png differ diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png new file mode 100644 index 0000000..1de3ad7 Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png differ diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_16x16.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_16x16.png new file mode 100644 index 0000000..85cc10a Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_16x16.png differ diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png new file mode 100644 index 0000000..62f5548 Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png differ diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_256x256.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_256x256.png new file mode 100644 index 0000000..1de3ad7 Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_256x256.png differ diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png new file mode 100644 index 0000000..d392c25 Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png differ diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_32x32.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_32x32.png new file mode 100644 index 0000000..62f5548 Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_32x32.png differ diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png new file mode 100644 index 0000000..ef6a40e Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png differ diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_512x512.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_512x512.png new file mode 100644 index 0000000..d392c25 Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_512x512.png differ diff --git a/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png new file mode 100644 index 0000000..6e0a80d Binary files /dev/null and b/TomatoBar/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png differ diff --git a/TomatoBar/Assets.xcassets/BarIcon.imageset/Contents.json b/TomatoBar/Assets.xcassets/BarIcon.imageset/Contents.json new file mode 100644 index 0000000..26f48dd --- /dev/null +++ b/TomatoBar/Assets.xcassets/BarIcon.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "icon_16x16.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "icon_16x16@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "icon_16x16@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/TomatoBar/Assets.xcassets/BarIcon.imageset/icon_16x16.png b/TomatoBar/Assets.xcassets/BarIcon.imageset/icon_16x16.png new file mode 100644 index 0000000..2535544 Binary files /dev/null and b/TomatoBar/Assets.xcassets/BarIcon.imageset/icon_16x16.png differ diff --git a/TomatoBar/Assets.xcassets/BarIcon.imageset/icon_16x16@2x.png b/TomatoBar/Assets.xcassets/BarIcon.imageset/icon_16x16@2x.png new file mode 100644 index 0000000..b4bc548 Binary files /dev/null and b/TomatoBar/Assets.xcassets/BarIcon.imageset/icon_16x16@2x.png differ diff --git a/TomatoBar/Assets.xcassets/BarIcon.imageset/icon_16x16@3x.png b/TomatoBar/Assets.xcassets/BarIcon.imageset/icon_16x16@3x.png new file mode 100644 index 0000000..8b22d45 Binary files /dev/null and b/TomatoBar/Assets.xcassets/BarIcon.imageset/icon_16x16@3x.png differ diff --git a/TomatoBar/Assets.xcassets/Contents.json b/TomatoBar/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/TomatoBar/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TomatoBar/BridgingHeader.h b/TomatoBar/BridgingHeader.h new file mode 100644 index 0000000..e125813 --- /dev/null +++ b/TomatoBar/BridgingHeader.h @@ -0,0 +1,6 @@ +#ifndef BridgingHeader_h +#define BridgingHeader_h + +#import "TouchBar.h" + +#endif /* BridgingHeader_h */ diff --git a/TomatoBar/Info.plist b/TomatoBar/Info.plist new file mode 100644 index 0000000..956878b --- /dev/null +++ b/TomatoBar/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0.0 + CFBundleVersion + 1 + LSApplicationCategoryType + public.app-category.productivity + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + LSUIElement + + NSHumanReadableCopyright + Copyright © 2018 Ilya Voronin. All rights reserved. https://github.com/ivoronin/TomatoBar + NSMainNibFile + TomatoBar + NSPrincipalClass + NSApplication + + diff --git a/TomatoBar/TomatoBar.entitlements b/TomatoBar/TomatoBar.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/TomatoBar/TomatoBar.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/TomatoBar/TomatoBar.xib b/TomatoBar/TomatoBar.xib new file mode 100644 index 0000000..0969cf9 --- /dev/null +++ b/TomatoBar/TomatoBar.xib @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TomatoBar/TomatoBarController.swift b/TomatoBar/TomatoBarController.swift new file mode 100644 index 0000000..0203493 --- /dev/null +++ b/TomatoBar/TomatoBarController.swift @@ -0,0 +1,117 @@ +import Cocoa + +public class TomatoBarController: NSViewController { + /** Is sound enabled flag */ + private var isSoundEnabled: Bool { + return UserDefaults.standard.bool(forKey: "isSoundEnabled") + } + + /** Interval length, in minutes */ + private var intervalLength: Int { + return UserDefaults.standard.integer(forKey: "intervalLength") + } + /** Interval length as seconds */ + private var intervalLengthSeconds: Int { return intervalLength * 60 } + + /** Time left, in seconds */ + private var timeLeft: Int = 0 + /** Time left as MM:SS */ + private var timeLeftString: String { + return String(format: "%.2i:%.2i", timeLeft / 60, timeLeft % 60) + } + /** Timer instance */ + private var timer: Timer? + + /** Status bar item */ + public var statusItem: NSStatusItem? + /** Status bar button */ + private var statusBarButton: NSButton? { + return statusItem?.button + } + + @IBOutlet private var statusMenu: NSMenu! + @IBOutlet private var touchBarItem: NSTouchBarItem! + @IBOutlet private var touchBarButton: NSButton! + @IBOutlet private var startMenuItem: NSMenuItem! + @IBOutlet private var stopMenuItem: NSMenuItem! + @IBOutlet private var isSoundEnabledCheckBox: NSButton! + + /* Loaded because of fake view */ + override public func viewDidLoad() { + super.viewDidLoad() + /* Register defaults */ + UserDefaults.standard.register(defaults: ["intervalLength": 25, + "isSoundEnabled": true]) + + /* Initialize status bar */ + statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) + statusBarButton?.image = NSImage(named: NSImage.Name("BarIcon")) + statusBarButton?.imagePosition = .imageOnly + statusItem?.menu = statusMenu + + /* Initialize touch bar, WARNING: uses private framework methods */ + NSTouchBarItem.addSystemTrayItem(touchBarItem) + DFRElementSetControlStripPresenceForIdentifier(touchBarItem.identifier.rawValue, true) + } + + /** Called on Touch Bar button and Start and Stop menu items clicks */ + @IBAction private func startStopAction(_ sender: Any) { + if timer == nil { + playSound() + start() + } else { + playSound() + finish() + } + } + + /** Starts timer */ + private func start() { + touchBarButton.imagePosition = .noImage + statusBarButton?.imagePosition = .imageLeft + swap(&startMenuItem.isHidden, &stopMenuItem.isHidden) + timeLeft = intervalLengthSeconds + timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in self.tick() } + updateViews() + } + + /** Called on finish */ + private func finish() { + timer?.invalidate() + timer = nil + touchBarButton.imagePosition = .imageOnly + statusBarButton?.imagePosition = .imageOnly + swap(&startMenuItem.isHidden, &stopMenuItem.isHidden) + } + + /** Called every second by timer */ + private func tick() { + timeLeft -= 1 + if timeLeft >= 0 { + updateViews() + } else { + playSound() + finish() + /* Send notification */ + let notification: NSUserNotification = NSUserNotification() + notification.title = "Time's up" + notification.informativeText = "Keep up the good work!" + NSUserNotificationCenter.default.deliver(notification) + } + } + + /** Updates status and touch bar buttons text */ + private func updateViews() { + touchBarButton.title = timeLeftString + statusBarButton?.title = timeLeftString + } + + /** Plays sound */ + private func playSound() { + guard isSoundEnabled else { + return + } + NSSound.beep() + } + +} diff --git a/TomatoBar/TouchBar.h b/TomatoBar/TouchBar.h new file mode 100644 index 0000000..98b4232 --- /dev/null +++ b/TomatoBar/TouchBar.h @@ -0,0 +1,7 @@ +#import + +extern void DFRElementSetControlStripPresenceForIdentifier(NSString *, BOOL); + +@interface NSTouchBarItem () ++ (void)addSystemTrayItem:(NSTouchBarItem *)item; +@end diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..2a64f86 --- /dev/null +++ b/build.sh @@ -0,0 +1,15 @@ +#!/bin/bash -e +PROJECT=TomatoBar.xcodeproj +SCHEME=TomatoBar +CONFIGURATION=Release +ARCHIVEPATH=TomatoBar.xcarchive + +if [ "${CI}" ]; then + CODE_SIGNING_ALLOWED="NO" +else + CODE_SIGNING_ALLOWED="YES" +fi + +rm -rf "${ARCHIVEPATH}" +xcodebuild archive -project "${PROJECT}" -scheme "${SCHEME}" -configuration "${CONFIGURATION}" -archivePath "${ARCHIVEPATH}" CODE_SIGNING_ALLOWED="${CODE_SIGNING_ALLOWED}" +[ "${CI}" ] || ./node_modules/.bin/create-dmg --overwrite "${ARCHIVEPATH}/Products/Applications/Tomato Bar.app" diff --git a/package.json b/package.json new file mode 100644 index 0000000..0eaa244 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "name": "archivemounter", + "devDependencies": { + "create-dmg": "^3.1.0" + } +}