├── Cooldown.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── jordibruin.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── Cooldown ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── mac1024.png │ │ ├── mac128.png │ │ ├── mac16.png │ │ ├── mac256.png │ │ ├── mac32.png │ │ ├── mac512.png │ │ └── mac64.png │ └── Contents.json ├── ContentView.swift ├── Cooldown.entitlements ├── CooldownApp.swift ├── CooldownRelease.entitlements ├── Extensions.swift ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json ├── RemoteConfig.swift └── StatusBar.swift ├── CooldownTests └── CooldownTests.swift ├── CooldownUITests ├── CooldownUITests.swift └── CooldownUITestsLaunchTests.swift └── README.md /Cooldown.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C21D060D27353F8A006548E2 /* CooldownApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C21D060C27353F8A006548E2 /* CooldownApp.swift */; }; 11 | C21D060F27353F8A006548E2 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C21D060E27353F8A006548E2 /* ContentView.swift */; }; 12 | C21D061127353F8B006548E2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C21D061027353F8B006548E2 /* Assets.xcassets */; }; 13 | C21D061427353F8B006548E2 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C21D061327353F8B006548E2 /* Preview Assets.xcassets */; }; 14 | C21D061F27353F8B006548E2 /* CooldownTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C21D061E27353F8B006548E2 /* CooldownTests.swift */; }; 15 | C21D062927353F8B006548E2 /* CooldownUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C21D062827353F8B006548E2 /* CooldownUITests.swift */; }; 16 | C21D062B27353F8B006548E2 /* CooldownUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C21D062A27353F8B006548E2 /* CooldownUITestsLaunchTests.swift */; }; 17 | C21D063C27355C7E006548E2 /* StatusBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C21D063B27355C7E006548E2 /* StatusBar.swift */; }; 18 | C21D063E27355C95006548E2 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C21D063D27355C95006548E2 /* Extensions.swift */; }; 19 | C21D064027355E2A006548E2 /* RemoteConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = C21D063F27355E2A006548E2 /* RemoteConfig.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | C21D061B27353F8B006548E2 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = C21D060127353F8A006548E2 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = C21D060827353F8A006548E2; 28 | remoteInfo = Cooldown; 29 | }; 30 | C21D062527353F8B006548E2 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = C21D060127353F8A006548E2 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = C21D060827353F8A006548E2; 35 | remoteInfo = Cooldown; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | C2104CF5273593CA0083B0AF /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; 41 | C2104CFB273596020083B0AF /* CooldownRelease.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = CooldownRelease.entitlements; sourceTree = ""; }; 42 | C21D060927353F8A006548E2 /* Cooldown.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Cooldown.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | C21D060C27353F8A006548E2 /* CooldownApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CooldownApp.swift; sourceTree = ""; }; 44 | C21D060E27353F8A006548E2 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 45 | C21D061027353F8B006548E2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 46 | C21D061327353F8B006548E2 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 47 | C21D061527353F8B006548E2 /* Cooldown.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Cooldown.entitlements; sourceTree = ""; }; 48 | C21D061A27353F8B006548E2 /* CooldownTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CooldownTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | C21D061E27353F8B006548E2 /* CooldownTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CooldownTests.swift; sourceTree = ""; }; 50 | C21D062427353F8B006548E2 /* CooldownUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CooldownUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | C21D062827353F8B006548E2 /* CooldownUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CooldownUITests.swift; sourceTree = ""; }; 52 | C21D062A27353F8B006548E2 /* CooldownUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CooldownUITestsLaunchTests.swift; sourceTree = ""; }; 53 | C21D063B27355C7E006548E2 /* StatusBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusBar.swift; sourceTree = ""; }; 54 | C21D063D27355C95006548E2 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; 55 | C21D063F27355E2A006548E2 /* RemoteConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteConfig.swift; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | C21D060627353F8A006548E2 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | C21D061727353F8B006548E2 /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | C21D062127353F8B006548E2 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | C21D060027353F8A006548E2 = { 84 | isa = PBXGroup; 85 | children = ( 86 | C21D060B27353F8A006548E2 /* Cooldown */, 87 | C21D061D27353F8B006548E2 /* CooldownTests */, 88 | C21D062727353F8B006548E2 /* CooldownUITests */, 89 | C21D060A27353F8A006548E2 /* Products */, 90 | C21D0641273568B5006548E2 /* Frameworks */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | C21D060A27353F8A006548E2 /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | C21D060927353F8A006548E2 /* Cooldown.app */, 98 | C21D061A27353F8B006548E2 /* CooldownTests.xctest */, 99 | C21D062427353F8B006548E2 /* CooldownUITests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | C21D060B27353F8A006548E2 /* Cooldown */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | C2104CFB273596020083B0AF /* CooldownRelease.entitlements */, 108 | C21D060C27353F8A006548E2 /* CooldownApp.swift */, 109 | C21D063B27355C7E006548E2 /* StatusBar.swift */, 110 | C21D060E27353F8A006548E2 /* ContentView.swift */, 111 | C21D063D27355C95006548E2 /* Extensions.swift */, 112 | C21D063F27355E2A006548E2 /* RemoteConfig.swift */, 113 | C21D061027353F8B006548E2 /* Assets.xcassets */, 114 | C21D061527353F8B006548E2 /* Cooldown.entitlements */, 115 | C21D061227353F8B006548E2 /* Preview Content */, 116 | ); 117 | path = Cooldown; 118 | sourceTree = ""; 119 | }; 120 | C21D061227353F8B006548E2 /* Preview Content */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | C21D061327353F8B006548E2 /* Preview Assets.xcassets */, 124 | ); 125 | path = "Preview Content"; 126 | sourceTree = ""; 127 | }; 128 | C21D061D27353F8B006548E2 /* CooldownTests */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | C21D061E27353F8B006548E2 /* CooldownTests.swift */, 132 | ); 133 | path = CooldownTests; 134 | sourceTree = ""; 135 | }; 136 | C21D062727353F8B006548E2 /* CooldownUITests */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | C21D062827353F8B006548E2 /* CooldownUITests.swift */, 140 | C21D062A27353F8B006548E2 /* CooldownUITestsLaunchTests.swift */, 141 | ); 142 | path = CooldownUITests; 143 | sourceTree = ""; 144 | }; 145 | C21D0641273568B5006548E2 /* Frameworks */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | C2104CF5273593CA0083B0AF /* MapKit.framework */, 149 | ); 150 | name = Frameworks; 151 | sourceTree = ""; 152 | }; 153 | /* End PBXGroup section */ 154 | 155 | /* Begin PBXNativeTarget section */ 156 | C21D060827353F8A006548E2 /* Cooldown */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = C21D062E27353F8B006548E2 /* Build configuration list for PBXNativeTarget "Cooldown" */; 159 | buildPhases = ( 160 | C21D060527353F8A006548E2 /* Sources */, 161 | C21D060627353F8A006548E2 /* Frameworks */, 162 | C21D060727353F8A006548E2 /* Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | ); 168 | name = Cooldown; 169 | productName = Cooldown; 170 | productReference = C21D060927353F8A006548E2 /* Cooldown.app */; 171 | productType = "com.apple.product-type.application"; 172 | }; 173 | C21D061927353F8B006548E2 /* CooldownTests */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = C21D063127353F8B006548E2 /* Build configuration list for PBXNativeTarget "CooldownTests" */; 176 | buildPhases = ( 177 | C21D061627353F8B006548E2 /* Sources */, 178 | C21D061727353F8B006548E2 /* Frameworks */, 179 | C21D061827353F8B006548E2 /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | C21D061C27353F8B006548E2 /* PBXTargetDependency */, 185 | ); 186 | name = CooldownTests; 187 | productName = CooldownTests; 188 | productReference = C21D061A27353F8B006548E2 /* CooldownTests.xctest */; 189 | productType = "com.apple.product-type.bundle.unit-test"; 190 | }; 191 | C21D062327353F8B006548E2 /* CooldownUITests */ = { 192 | isa = PBXNativeTarget; 193 | buildConfigurationList = C21D063427353F8B006548E2 /* Build configuration list for PBXNativeTarget "CooldownUITests" */; 194 | buildPhases = ( 195 | C21D062027353F8B006548E2 /* Sources */, 196 | C21D062127353F8B006548E2 /* Frameworks */, 197 | C21D062227353F8B006548E2 /* Resources */, 198 | ); 199 | buildRules = ( 200 | ); 201 | dependencies = ( 202 | C21D062627353F8B006548E2 /* PBXTargetDependency */, 203 | ); 204 | name = CooldownUITests; 205 | productName = CooldownUITests; 206 | productReference = C21D062427353F8B006548E2 /* CooldownUITests.xctest */; 207 | productType = "com.apple.product-type.bundle.ui-testing"; 208 | }; 209 | /* End PBXNativeTarget section */ 210 | 211 | /* Begin PBXProject section */ 212 | C21D060127353F8A006548E2 /* Project object */ = { 213 | isa = PBXProject; 214 | attributes = { 215 | BuildIndependentTargetsInParallel = 1; 216 | LastSwiftUpdateCheck = 1310; 217 | LastUpgradeCheck = 1310; 218 | TargetAttributes = { 219 | C21D060827353F8A006548E2 = { 220 | CreatedOnToolsVersion = 13.1; 221 | }; 222 | C21D061927353F8B006548E2 = { 223 | CreatedOnToolsVersion = 13.1; 224 | TestTargetID = C21D060827353F8A006548E2; 225 | }; 226 | C21D062327353F8B006548E2 = { 227 | CreatedOnToolsVersion = 13.1; 228 | TestTargetID = C21D060827353F8A006548E2; 229 | }; 230 | }; 231 | }; 232 | buildConfigurationList = C21D060427353F8A006548E2 /* Build configuration list for PBXProject "Cooldown" */; 233 | compatibilityVersion = "Xcode 13.0"; 234 | developmentRegion = en; 235 | hasScannedForEncodings = 0; 236 | knownRegions = ( 237 | en, 238 | Base, 239 | ); 240 | mainGroup = C21D060027353F8A006548E2; 241 | productRefGroup = C21D060A27353F8A006548E2 /* Products */; 242 | projectDirPath = ""; 243 | projectRoot = ""; 244 | targets = ( 245 | C21D060827353F8A006548E2 /* Cooldown */, 246 | C21D061927353F8B006548E2 /* CooldownTests */, 247 | C21D062327353F8B006548E2 /* CooldownUITests */, 248 | ); 249 | }; 250 | /* End PBXProject section */ 251 | 252 | /* Begin PBXResourcesBuildPhase section */ 253 | C21D060727353F8A006548E2 /* Resources */ = { 254 | isa = PBXResourcesBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | C21D061427353F8B006548E2 /* Preview Assets.xcassets in Resources */, 258 | C21D061127353F8B006548E2 /* Assets.xcassets in Resources */, 259 | ); 260 | runOnlyForDeploymentPostprocessing = 0; 261 | }; 262 | C21D061827353F8B006548E2 /* Resources */ = { 263 | isa = PBXResourcesBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | C21D062227353F8B006548E2 /* Resources */ = { 270 | isa = PBXResourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | /* End PBXResourcesBuildPhase section */ 277 | 278 | /* Begin PBXSourcesBuildPhase section */ 279 | C21D060527353F8A006548E2 /* Sources */ = { 280 | isa = PBXSourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | C21D063C27355C7E006548E2 /* StatusBar.swift in Sources */, 284 | C21D064027355E2A006548E2 /* RemoteConfig.swift in Sources */, 285 | C21D060F27353F8A006548E2 /* ContentView.swift in Sources */, 286 | C21D060D27353F8A006548E2 /* CooldownApp.swift in Sources */, 287 | C21D063E27355C95006548E2 /* Extensions.swift in Sources */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | C21D061627353F8B006548E2 /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | C21D061F27353F8B006548E2 /* CooldownTests.swift in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | C21D062027353F8B006548E2 /* Sources */ = { 300 | isa = PBXSourcesBuildPhase; 301 | buildActionMask = 2147483647; 302 | files = ( 303 | C21D062B27353F8B006548E2 /* CooldownUITestsLaunchTests.swift in Sources */, 304 | C21D062927353F8B006548E2 /* CooldownUITests.swift in Sources */, 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | }; 308 | /* End PBXSourcesBuildPhase section */ 309 | 310 | /* Begin PBXTargetDependency section */ 311 | C21D061C27353F8B006548E2 /* PBXTargetDependency */ = { 312 | isa = PBXTargetDependency; 313 | target = C21D060827353F8A006548E2 /* Cooldown */; 314 | targetProxy = C21D061B27353F8B006548E2 /* PBXContainerItemProxy */; 315 | }; 316 | C21D062627353F8B006548E2 /* PBXTargetDependency */ = { 317 | isa = PBXTargetDependency; 318 | target = C21D060827353F8A006548E2 /* Cooldown */; 319 | targetProxy = C21D062527353F8B006548E2 /* PBXContainerItemProxy */; 320 | }; 321 | /* End PBXTargetDependency section */ 322 | 323 | /* Begin XCBuildConfiguration section */ 324 | C21D062C27353F8B006548E2 /* Debug */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ALWAYS_SEARCH_USER_PATHS = NO; 328 | CLANG_ANALYZER_NONNULL = YES; 329 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 330 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 331 | CLANG_CXX_LIBRARY = "libc++"; 332 | CLANG_ENABLE_MODULES = YES; 333 | CLANG_ENABLE_OBJC_ARC = YES; 334 | CLANG_ENABLE_OBJC_WEAK = YES; 335 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 336 | CLANG_WARN_BOOL_CONVERSION = YES; 337 | CLANG_WARN_COMMA = YES; 338 | CLANG_WARN_CONSTANT_CONVERSION = YES; 339 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 341 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 342 | CLANG_WARN_EMPTY_BODY = YES; 343 | CLANG_WARN_ENUM_CONVERSION = YES; 344 | CLANG_WARN_INFINITE_RECURSION = YES; 345 | CLANG_WARN_INT_CONVERSION = YES; 346 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 347 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 348 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 349 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 350 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 351 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 352 | CLANG_WARN_STRICT_PROTOTYPES = YES; 353 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 354 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 355 | CLANG_WARN_UNREACHABLE_CODE = YES; 356 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 357 | COPY_PHASE_STRIP = NO; 358 | DEBUG_INFORMATION_FORMAT = dwarf; 359 | ENABLE_STRICT_OBJC_MSGSEND = YES; 360 | ENABLE_TESTABILITY = YES; 361 | GCC_C_LANGUAGE_STANDARD = gnu11; 362 | GCC_DYNAMIC_NO_PIC = NO; 363 | GCC_NO_COMMON_BLOCKS = YES; 364 | GCC_OPTIMIZATION_LEVEL = 0; 365 | GCC_PREPROCESSOR_DEFINITIONS = ( 366 | "DEBUG=1", 367 | "$(inherited)", 368 | ); 369 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 370 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 371 | GCC_WARN_UNDECLARED_SELECTOR = YES; 372 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 373 | GCC_WARN_UNUSED_FUNCTION = YES; 374 | GCC_WARN_UNUSED_VARIABLE = YES; 375 | MACOSX_DEPLOYMENT_TARGET = 12.0; 376 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 377 | MTL_FAST_MATH = YES; 378 | ONLY_ACTIVE_ARCH = YES; 379 | SDKROOT = macosx; 380 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 381 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 382 | }; 383 | name = Debug; 384 | }; 385 | C21D062D27353F8B006548E2 /* Release */ = { 386 | isa = XCBuildConfiguration; 387 | buildSettings = { 388 | ALWAYS_SEARCH_USER_PATHS = NO; 389 | CLANG_ANALYZER_NONNULL = YES; 390 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 391 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 392 | CLANG_CXX_LIBRARY = "libc++"; 393 | CLANG_ENABLE_MODULES = YES; 394 | CLANG_ENABLE_OBJC_ARC = YES; 395 | CLANG_ENABLE_OBJC_WEAK = YES; 396 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 397 | CLANG_WARN_BOOL_CONVERSION = YES; 398 | CLANG_WARN_COMMA = YES; 399 | CLANG_WARN_CONSTANT_CONVERSION = YES; 400 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 401 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 402 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 403 | CLANG_WARN_EMPTY_BODY = YES; 404 | CLANG_WARN_ENUM_CONVERSION = YES; 405 | CLANG_WARN_INFINITE_RECURSION = YES; 406 | CLANG_WARN_INT_CONVERSION = YES; 407 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 408 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 409 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 410 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 411 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 412 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 413 | CLANG_WARN_STRICT_PROTOTYPES = YES; 414 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 415 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 416 | CLANG_WARN_UNREACHABLE_CODE = YES; 417 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 418 | COPY_PHASE_STRIP = NO; 419 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 420 | ENABLE_NS_ASSERTIONS = NO; 421 | ENABLE_STRICT_OBJC_MSGSEND = YES; 422 | GCC_C_LANGUAGE_STANDARD = gnu11; 423 | GCC_NO_COMMON_BLOCKS = YES; 424 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 425 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 426 | GCC_WARN_UNDECLARED_SELECTOR = YES; 427 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 428 | GCC_WARN_UNUSED_FUNCTION = YES; 429 | GCC_WARN_UNUSED_VARIABLE = YES; 430 | MACOSX_DEPLOYMENT_TARGET = 12.0; 431 | MTL_ENABLE_DEBUG_INFO = NO; 432 | MTL_FAST_MATH = YES; 433 | SDKROOT = macosx; 434 | SWIFT_COMPILATION_MODE = wholemodule; 435 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 436 | }; 437 | name = Release; 438 | }; 439 | C21D062F27353F8B006548E2 /* Debug */ = { 440 | isa = XCBuildConfiguration; 441 | buildSettings = { 442 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 443 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 444 | CODE_SIGN_ENTITLEMENTS = Cooldown/Cooldown.entitlements; 445 | CODE_SIGN_IDENTITY = "Developer ID Application"; 446 | CODE_SIGN_STYLE = Manual; 447 | COMBINE_HIDPI_IMAGES = YES; 448 | CURRENT_PROJECT_VERSION = 20; 449 | DEVELOPMENT_ASSET_PATHS = "\"Cooldown/Preview Content\""; 450 | DEVELOPMENT_TEAM = 8Q7TMPA46J; 451 | ENABLE_HARDENED_RUNTIME = YES; 452 | ENABLE_PREVIEWS = YES; 453 | GENERATE_INFOPLIST_FILE = YES; 454 | INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; 455 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 456 | LD_RUNPATH_SEARCH_PATHS = ( 457 | "$(inherited)", 458 | "@executable_path/../Frameworks", 459 | ); 460 | MACOSX_DEPLOYMENT_TARGET = 12.0; 461 | MARKETING_VERSION = 1.0; 462 | PRODUCT_BUNDLE_IDENTIFIER = com.goodsnooze.cooldown; 463 | PRODUCT_NAME = "$(TARGET_NAME)"; 464 | PROVISIONING_PROFILE_SPECIFIER = "Cooldown Profile"; 465 | SWIFT_EMIT_LOC_STRINGS = YES; 466 | SWIFT_VERSION = 5.0; 467 | }; 468 | name = Debug; 469 | }; 470 | C21D063027353F8B006548E2 /* Release */ = { 471 | isa = XCBuildConfiguration; 472 | buildSettings = { 473 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 474 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 475 | CODE_SIGN_ENTITLEMENTS = Cooldown/CooldownRelease.entitlements; 476 | CODE_SIGN_IDENTITY = "Developer ID Application"; 477 | CODE_SIGN_STYLE = Manual; 478 | COMBINE_HIDPI_IMAGES = YES; 479 | CURRENT_PROJECT_VERSION = 20; 480 | DEVELOPMENT_ASSET_PATHS = "\"Cooldown/Preview Content\""; 481 | DEVELOPMENT_TEAM = 8Q7TMPA46J; 482 | ENABLE_HARDENED_RUNTIME = YES; 483 | ENABLE_PREVIEWS = YES; 484 | GENERATE_INFOPLIST_FILE = YES; 485 | INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; 486 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 487 | LD_RUNPATH_SEARCH_PATHS = ( 488 | "$(inherited)", 489 | "@executable_path/../Frameworks", 490 | ); 491 | MACOSX_DEPLOYMENT_TARGET = 12.0; 492 | MARKETING_VERSION = 1.0; 493 | PRODUCT_BUNDLE_IDENTIFIER = com.goodsnooze.cooldown; 494 | PRODUCT_NAME = "$(TARGET_NAME)"; 495 | PROVISIONING_PROFILE_SPECIFIER = "Cooldown Profile"; 496 | SWIFT_EMIT_LOC_STRINGS = YES; 497 | SWIFT_VERSION = 5.0; 498 | }; 499 | name = Release; 500 | }; 501 | C21D063227353F8B006548E2 /* Debug */ = { 502 | isa = XCBuildConfiguration; 503 | buildSettings = { 504 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 505 | BUNDLE_LOADER = "$(TEST_HOST)"; 506 | CODE_SIGN_STYLE = Automatic; 507 | COMBINE_HIDPI_IMAGES = YES; 508 | CURRENT_PROJECT_VERSION = 1; 509 | DEVELOPMENT_TEAM = 8Q7TMPA46J; 510 | GENERATE_INFOPLIST_FILE = YES; 511 | LD_RUNPATH_SEARCH_PATHS = ( 512 | "$(inherited)", 513 | "@executable_path/../Frameworks", 514 | "@loader_path/../Frameworks", 515 | ); 516 | MACOSX_DEPLOYMENT_TARGET = 12.0; 517 | MARKETING_VERSION = 1.0; 518 | PRODUCT_BUNDLE_IDENTIFIER = com.goodsnooze.CooldownTests; 519 | PRODUCT_NAME = "$(TARGET_NAME)"; 520 | SWIFT_EMIT_LOC_STRINGS = NO; 521 | SWIFT_VERSION = 5.0; 522 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Cooldown.app/Contents/MacOS/Cooldown"; 523 | }; 524 | name = Debug; 525 | }; 526 | C21D063327353F8B006548E2 /* Release */ = { 527 | isa = XCBuildConfiguration; 528 | buildSettings = { 529 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 530 | BUNDLE_LOADER = "$(TEST_HOST)"; 531 | CODE_SIGN_STYLE = Automatic; 532 | COMBINE_HIDPI_IMAGES = YES; 533 | CURRENT_PROJECT_VERSION = 1; 534 | DEVELOPMENT_TEAM = 8Q7TMPA46J; 535 | GENERATE_INFOPLIST_FILE = YES; 536 | LD_RUNPATH_SEARCH_PATHS = ( 537 | "$(inherited)", 538 | "@executable_path/../Frameworks", 539 | "@loader_path/../Frameworks", 540 | ); 541 | MACOSX_DEPLOYMENT_TARGET = 12.0; 542 | MARKETING_VERSION = 1.0; 543 | PRODUCT_BUNDLE_IDENTIFIER = com.goodsnooze.CooldownTests; 544 | PRODUCT_NAME = "$(TARGET_NAME)"; 545 | SWIFT_EMIT_LOC_STRINGS = NO; 546 | SWIFT_VERSION = 5.0; 547 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Cooldown.app/Contents/MacOS/Cooldown"; 548 | }; 549 | name = Release; 550 | }; 551 | C21D063527353F8B006548E2 /* Debug */ = { 552 | isa = XCBuildConfiguration; 553 | buildSettings = { 554 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 555 | CODE_SIGN_STYLE = Automatic; 556 | COMBINE_HIDPI_IMAGES = YES; 557 | CURRENT_PROJECT_VERSION = 1; 558 | DEVELOPMENT_TEAM = 8Q7TMPA46J; 559 | GENERATE_INFOPLIST_FILE = YES; 560 | LD_RUNPATH_SEARCH_PATHS = ( 561 | "$(inherited)", 562 | "@executable_path/../Frameworks", 563 | "@loader_path/../Frameworks", 564 | ); 565 | MARKETING_VERSION = 1.0; 566 | PRODUCT_BUNDLE_IDENTIFIER = com.goodsnooze.CooldownUITests; 567 | PRODUCT_NAME = "$(TARGET_NAME)"; 568 | SWIFT_EMIT_LOC_STRINGS = NO; 569 | SWIFT_VERSION = 5.0; 570 | TEST_TARGET_NAME = Cooldown; 571 | }; 572 | name = Debug; 573 | }; 574 | C21D063627353F8B006548E2 /* Release */ = { 575 | isa = XCBuildConfiguration; 576 | buildSettings = { 577 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 578 | CODE_SIGN_STYLE = Automatic; 579 | COMBINE_HIDPI_IMAGES = YES; 580 | CURRENT_PROJECT_VERSION = 1; 581 | DEVELOPMENT_TEAM = 8Q7TMPA46J; 582 | GENERATE_INFOPLIST_FILE = YES; 583 | LD_RUNPATH_SEARCH_PATHS = ( 584 | "$(inherited)", 585 | "@executable_path/../Frameworks", 586 | "@loader_path/../Frameworks", 587 | ); 588 | MARKETING_VERSION = 1.0; 589 | PRODUCT_BUNDLE_IDENTIFIER = com.goodsnooze.CooldownUITests; 590 | PRODUCT_NAME = "$(TARGET_NAME)"; 591 | SWIFT_EMIT_LOC_STRINGS = NO; 592 | SWIFT_VERSION = 5.0; 593 | TEST_TARGET_NAME = Cooldown; 594 | }; 595 | name = Release; 596 | }; 597 | /* End XCBuildConfiguration section */ 598 | 599 | /* Begin XCConfigurationList section */ 600 | C21D060427353F8A006548E2 /* Build configuration list for PBXProject "Cooldown" */ = { 601 | isa = XCConfigurationList; 602 | buildConfigurations = ( 603 | C21D062C27353F8B006548E2 /* Debug */, 604 | C21D062D27353F8B006548E2 /* Release */, 605 | ); 606 | defaultConfigurationIsVisible = 0; 607 | defaultConfigurationName = Release; 608 | }; 609 | C21D062E27353F8B006548E2 /* Build configuration list for PBXNativeTarget "Cooldown" */ = { 610 | isa = XCConfigurationList; 611 | buildConfigurations = ( 612 | C21D062F27353F8B006548E2 /* Debug */, 613 | C21D063027353F8B006548E2 /* Release */, 614 | ); 615 | defaultConfigurationIsVisible = 0; 616 | defaultConfigurationName = Release; 617 | }; 618 | C21D063127353F8B006548E2 /* Build configuration list for PBXNativeTarget "CooldownTests" */ = { 619 | isa = XCConfigurationList; 620 | buildConfigurations = ( 621 | C21D063227353F8B006548E2 /* Debug */, 622 | C21D063327353F8B006548E2 /* Release */, 623 | ); 624 | defaultConfigurationIsVisible = 0; 625 | defaultConfigurationName = Release; 626 | }; 627 | C21D063427353F8B006548E2 /* Build configuration list for PBXNativeTarget "CooldownUITests" */ = { 628 | isa = XCConfigurationList; 629 | buildConfigurations = ( 630 | C21D063527353F8B006548E2 /* Debug */, 631 | C21D063627353F8B006548E2 /* Release */, 632 | ); 633 | defaultConfigurationIsVisible = 0; 634 | defaultConfigurationName = Release; 635 | }; 636 | /* End XCConfigurationList section */ 637 | }; 638 | rootObject = C21D060127353F8A006548E2 /* Project object */; 639 | } 640 | -------------------------------------------------------------------------------- /Cooldown.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Cooldown.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Cooldown.xcodeproj/xcuserdata/jordibruin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Cooldown.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | }, 93 | { 94 | "filename" : "mac16.png", 95 | "idiom" : "mac", 96 | "scale" : "1x", 97 | "size" : "16x16" 98 | }, 99 | { 100 | "filename" : "mac32.png", 101 | "idiom" : "mac", 102 | "scale" : "2x", 103 | "size" : "16x16" 104 | }, 105 | { 106 | "filename" : "mac32.png", 107 | "idiom" : "mac", 108 | "scale" : "1x", 109 | "size" : "32x32" 110 | }, 111 | { 112 | "filename" : "mac64.png", 113 | "idiom" : "mac", 114 | "scale" : "2x", 115 | "size" : "32x32" 116 | }, 117 | { 118 | "filename" : "mac128.png", 119 | "idiom" : "mac", 120 | "scale" : "1x", 121 | "size" : "128x128" 122 | }, 123 | { 124 | "filename" : "mac256.png", 125 | "idiom" : "mac", 126 | "scale" : "2x", 127 | "size" : "128x128" 128 | }, 129 | { 130 | "filename" : "mac256.png", 131 | "idiom" : "mac", 132 | "scale" : "1x", 133 | "size" : "256x256" 134 | }, 135 | { 136 | "filename" : "mac512.png", 137 | "idiom" : "mac", 138 | "scale" : "2x", 139 | "size" : "256x256" 140 | }, 141 | { 142 | "filename" : "mac512.png", 143 | "idiom" : "mac", 144 | "scale" : "1x", 145 | "size" : "512x512" 146 | }, 147 | { 148 | "filename" : "mac1024.png", 149 | "idiom" : "mac", 150 | "scale" : "2x", 151 | "size" : "512x512" 152 | } 153 | ], 154 | "info" : { 155 | "author" : "xcode", 156 | "version" : 1 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/AppIcon.appiconset/mac1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jordibruin/cooldown/9635469d12532044db7843e641886af7e6cc27db/Cooldown/Assets.xcassets/AppIcon.appiconset/mac1024.png -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/AppIcon.appiconset/mac128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jordibruin/cooldown/9635469d12532044db7843e641886af7e6cc27db/Cooldown/Assets.xcassets/AppIcon.appiconset/mac128.png -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/AppIcon.appiconset/mac16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jordibruin/cooldown/9635469d12532044db7843e641886af7e6cc27db/Cooldown/Assets.xcassets/AppIcon.appiconset/mac16.png -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/AppIcon.appiconset/mac256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jordibruin/cooldown/9635469d12532044db7843e641886af7e6cc27db/Cooldown/Assets.xcassets/AppIcon.appiconset/mac256.png -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/AppIcon.appiconset/mac32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jordibruin/cooldown/9635469d12532044db7843e641886af7e6cc27db/Cooldown/Assets.xcassets/AppIcon.appiconset/mac32.png -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/AppIcon.appiconset/mac512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jordibruin/cooldown/9635469d12532044db7843e641886af7e6cc27db/Cooldown/Assets.xcassets/AppIcon.appiconset/mac512.png -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/AppIcon.appiconset/mac64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jordibruin/cooldown/9635469d12532044db7843e641886af7e6cc27db/Cooldown/Assets.xcassets/AppIcon.appiconset/mac64.png -------------------------------------------------------------------------------- /Cooldown/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Cooldown/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // Cooldown 4 | // 5 | // Created by Jordi Bruin on 05/11/2021. 6 | // 7 | 8 | import SwiftUI 9 | 10 | // Only used for debugging 11 | struct ContentView: View { 12 | 13 | @State var LPMActive = false 14 | 15 | var body: some View { 16 | VStack { 17 | Text("Low Power Mode") 18 | .bold() 19 | Text(LPMActive ? "Enabled" : "Disabled") 20 | Button { 21 | toggleLowPowerMode() 22 | } label: { 23 | Text(LPMActive ? "Disable LPM" : "Enable LPM") 24 | } 25 | } 26 | // .frame(width: 200, height: 200) 27 | .background(LPMActive ? Color.yellow : Color.gray) 28 | .onAppear { 29 | _ = isLPMActive() 30 | } 31 | } 32 | 33 | func isLPMActive() -> Bool { 34 | guard let response = run("pmset -g | grep lowpowermode") else { 35 | print("Could not get anything from terminal") 36 | return false 37 | } 38 | 39 | LPMActive = response.contains("1") 40 | return response.contains("1") 41 | } 42 | 43 | func toggleLowPowerMode() { 44 | if isLPMActive() { 45 | if let _ = run("osascript -e 'do shell script \"sudo pmset -a lowpowermode 0\" with prompt \"Cooldown\" with administrator privileges'") { 46 | print("Disabled Low Power Mode") 47 | _ = isLPMActive() 48 | } 49 | } else { 50 | if let _ = run("osascript -e 'do shell script \"sudo pmset -a lowpowermode 1\" with prompt \"Cooldown\" with administrator privileges'") { 51 | print("Enabled Low Power Mode") 52 | _ = isLPMActive() 53 | } 54 | } 55 | } 56 | 57 | func run(_ cmd: String) -> String? { 58 | let pipe = Pipe() 59 | let process = Process() 60 | process.launchPath = "/bin/sh" 61 | process.arguments = ["-c", String(format:"%@", cmd)] 62 | process.standardOutput = pipe 63 | let fileHandle = pipe.fileHandleForReading 64 | process.launch() 65 | return String(data: fileHandle.readDataToEndOfFile(), encoding: .utf8) 66 | } 67 | } 68 | 69 | struct ContentView_Previews: PreviewProvider { 70 | static var previews: some View { 71 | ContentView() 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Cooldown/Cooldown.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Cooldown/CooldownApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CooldownApp.swift 3 | // Cooldown 4 | // 5 | // Created by Jordi Bruin on 05/11/2021. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct CooldownApp: App { 12 | 13 | @NSApplicationDelegateAdaptor(StatusBarDelegate.self) var appDelegate 14 | 15 | @StateObject var config = ConfigManager() 16 | 17 | var body: some Scene { 18 | WindowGroup { 19 | Color.clear 20 | .frame(width: 0, height: 0) 21 | } 22 | .windowStyle(HiddenTitleBarWindowStyle()) 23 | } 24 | 25 | init() { 26 | NSApplication.shared.setActivationPolicy(.accessory) 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Cooldown/CooldownRelease.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Cooldown/Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Extensions.swift 3 | // Cooldown 4 | // 5 | // Created by Jordi Bruin on 05/11/2021. 6 | // 7 | 8 | import Foundation 9 | import AppKit 10 | 11 | extension NSImage { 12 | func tint(color: NSColor) -> NSImage { 13 | let image = self.copy() as! NSImage 14 | image.lockFocus() 15 | 16 | color.set() 17 | 18 | let imageRect = NSRect(origin: NSZeroPoint, size: image.size) 19 | imageRect.fill(using: .sourceAtop) 20 | 21 | image.unlockFocus() 22 | 23 | return image 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cooldown/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Cooldown/RemoteConfig.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RemoteConfig.swift 3 | // Cooldown 4 | // 5 | // Created by Jordi Bruin on 05/11/2021. 6 | // 7 | 8 | import Foundation 9 | import AppKit 10 | 11 | struct CooldownConfig: Decodable { 12 | var latestVersion: Int 13 | } 14 | 15 | class ConfigManager: ObservableObject { 16 | 17 | @Published var allowedVersion: Int = 0 18 | @Published var shouldUpdate: Bool = false 19 | 20 | init() { 21 | checkForUpdates() 22 | } 23 | 24 | func checkForUpdates() { 25 | loadJson(fromURLString: "https://simplejsoncms.com/api/") { result in 26 | switch result { 27 | case let .success(data): 28 | // print("Got data") 29 | let config: CooldownConfig = try! JSONDecoder().decode(CooldownConfig.self, from: data) 30 | print(config.latestVersion) 31 | DispatchQueue.main.async { [unowned self] in 32 | self.allowedVersion = config.latestVersion 33 | self.checkIfBuildIsNewEnough() 34 | } 35 | 36 | case let .failure(error): 37 | print("error:", error.localizedDescription) 38 | self.shouldUpdate = true 39 | } 40 | } 41 | } 42 | 43 | private func checkIfBuildIsNewEnough() { 44 | if let buildVersion = Bundle.main.buildVersionNumber { 45 | if let buildVersionInt = Int(buildVersion) { 46 | // print(buildVersionInt) 47 | 48 | if self.allowedVersion <= buildVersionInt { 49 | // print(buildVersionInt) 50 | // print("User is up to date") 51 | } else { 52 | // print(buildVersionInt) 53 | // print("User is using an older version of the app") 54 | DispatchQueue.main.async { [unowned self] in 55 | // self.shouldUpdate = true 56 | let alert = NSAlert() 57 | alert.messageText = "Update Available" 58 | alert.informativeText = "A new version of Cooldown is available." 59 | alert.alertStyle = NSAlert.Style.warning 60 | alert.addButton(withTitle: "Update now") 61 | alert.addButton(withTitle: "Cancel") 62 | 63 | let modalResult = alert.runModal() 64 | 65 | switch modalResult { 66 | case .alertFirstButtonReturn: // NSApplication.ModalResponse.alertFirstButtonReturn 67 | if let url = URL(string: "https://goodsnooze.gumroad.com/l/cooldown") { 68 | if NSWorkspace.shared.open(url) { 69 | print("Opened Gumroad") 70 | } 71 | } 72 | default: 73 | print("Cancel clicked") 74 | } 75 | } 76 | } 77 | } 78 | } 79 | } 80 | 81 | 82 | 83 | 84 | private func loadJson(fromURLString urlString: String, completion: @escaping (Result) -> Void) { 85 | if let url = URL(string: urlString) { 86 | let urlSession = URLSession(configuration: .ephemeral).dataTask(with: url) { (data, response, error) in 87 | if let error = error { 88 | completion(.failure(error)) 89 | } 90 | 91 | if let data = data { 92 | completion(.success(data)) 93 | } 94 | } 95 | urlSession.resume() 96 | } 97 | } 98 | } 99 | 100 | extension Bundle { 101 | var releaseVersionNumber: String? { 102 | return infoDictionary?["CFBundleShortVersionString"] as? String 103 | } 104 | var buildVersionNumber: String? { 105 | return infoDictionary?["CFBundleVersion"] as? String 106 | } 107 | } 108 | 109 | //Bundle.main.releaseVersionNumber 110 | //Bundle.main.buildVersionNumber 111 | 112 | -------------------------------------------------------------------------------- /Cooldown/StatusBar.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StatusBar.swift 3 | // Cooldown 4 | // 5 | // Created by Jordi Bruin on 05/11/2021. 6 | // 7 | 8 | import SwiftUI 9 | import Foundation 10 | import AppKit 11 | 12 | class StatusBarDelegate: NSObject, NSApplicationDelegate { 13 | 14 | var statusBar: StatusBar? 15 | 16 | lazy var windows = NSWindow() 17 | 18 | func applicationDidFinishLaunching(_ aNotification: Notification) { 19 | statusBar = StatusBar.init() 20 | } 21 | } 22 | 23 | class StatusBar { 24 | 25 | private var statusItem: NSStatusItem 26 | 27 | init() { 28 | 29 | statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) 30 | 31 | 32 | if let statusBarButton = statusItem.button { 33 | statusBarButton.image = NSImage(systemSymbolName: "bolt.batteryblock.fill", accessibilityDescription: "Cooldown")?.tint(color: .green) 34 | 35 | statusBarButton.image?.size = NSSize(width: 26.0, height: 26.0) 36 | statusBarButton.image?.isTemplate = false 37 | statusBarButton.action = #selector(self.doSomeAction(sender:)) 38 | statusBarButton.sendAction(on: [.leftMouseUp, .rightMouseUp]) 39 | statusBarButton.target = self 40 | 41 | } 42 | 43 | _ = isLPMActive() 44 | } 45 | 46 | @objc func doSomeAction(sender: NSStatusItem) { 47 | toggleLowPowerMode() 48 | } 49 | 50 | func tintedImage(_ image: NSImage, tint: NSColor) -> NSImage { 51 | guard let tinted = image.copy() as? NSImage else { return image } 52 | tinted.lockFocus() 53 | tint.set() 54 | 55 | let imageRect = NSRect(origin: NSZeroPoint, size: image.size) 56 | imageRect.fill(using: .sourceAtop) 57 | // NSRectFillUsingOperation(imageRect, .sourceAtop) 58 | 59 | tinted.unlockFocus() 60 | return tinted 61 | } 62 | 63 | 64 | 65 | func isLPMActive() -> Bool { 66 | guard let response = run("pmset -g | grep lowpowermode") else { 67 | print("Could not get anything from terminal") 68 | return false 69 | } 70 | 71 | let isActive = response.contains("1") 72 | 73 | // To add colors in the future 74 | if let image = NSImage(systemSymbolName: isActive ? "bolt.batteryblock.fill" : "bolt.batteryblock", accessibilityDescription: "Cooldown") { 75 | // let newImage = tintedImage(image, tint: isActive ? NSColor(red: 11/255, green: 157/255, blue: 142/255, alpha: 1) : .white) 76 | // newImage.isTemplate = isActive ? false : true 77 | statusItem.button?.image = image 78 | } 79 | 80 | statusItem.button?.toolTip = isActive ? "Disable Low Power Mode" : "Enable Low Power Mode" 81 | 82 | return response.contains("1") 83 | } 84 | 85 | func toggleLowPowerMode() { 86 | if isLPMActive() { 87 | if let _ = run("osascript -e 'do shell script \"sudo pmset -a lowpowermode 0\" with prompt \"🔋 Cooldown wants to disable Low Power Mode\" with administrator privileges'") { 88 | print("Disabled Low Power Mode") 89 | _ = isLPMActive() 90 | } 91 | } else { 92 | if let _ = run("osascript -e 'do shell script \"sudo pmset -a lowpowermode 1\" with prompt \"🔋 Cooldown wants to enable Low Power Mode\" with administrator privileges'") { 93 | print("Enabled Low Power Mode") 94 | _ = isLPMActive() 95 | } 96 | } 97 | } 98 | 99 | func run(_ cmd: String) -> String? { 100 | let pipe = Pipe() 101 | let process = Process() 102 | process.launchPath = "/bin/sh" 103 | process.arguments = ["-c", String(format:"%@", cmd)] 104 | process.standardOutput = pipe 105 | let fileHandle = pipe.fileHandleForReading 106 | process.launch() 107 | return String(data: fileHandle.readDataToEndOfFile(), encoding: .utf8) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /CooldownTests/CooldownTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CooldownTests.swift 3 | // CooldownTests 4 | // 5 | // Created by Jordi Bruin on 05/11/2021. 6 | // 7 | 8 | import XCTest 9 | @testable import Cooldown 10 | 11 | class CooldownTests: XCTestCase { 12 | 13 | override func setUpWithError() throws { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | } 16 | 17 | override func tearDownWithError() throws { 18 | // Put teardown code here. This method is called after the invocation of each test method in the class. 19 | } 20 | 21 | func testExample() throws { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | func testPerformanceExample() throws { 27 | // This is an example of a performance test case. 28 | self.measure { 29 | // Put the code you want to measure the time of here. 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /CooldownUITests/CooldownUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CooldownUITests.swift 3 | // CooldownUITests 4 | // 5 | // Created by Jordi Bruin on 05/11/2021. 6 | // 7 | 8 | import XCTest 9 | 10 | class CooldownUITests: XCTestCase { 11 | 12 | override func setUpWithError() throws { 13 | // Put setup code here. This method is called before the invocation of each test method in the class. 14 | 15 | // In UI tests it is usually best to stop immediately when a failure occurs. 16 | continueAfterFailure = false 17 | 18 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 19 | } 20 | 21 | override func tearDownWithError() throws { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | func testExample() throws { 26 | // UI tests must launch the application that they test. 27 | let app = XCUIApplication() 28 | app.launch() 29 | 30 | // Use recording to get started writing UI tests. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | } 33 | 34 | func testLaunchPerformance() throws { 35 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { 36 | // This measures how long it takes to launch your application. 37 | measure(metrics: [XCTApplicationLaunchMetric()]) { 38 | XCUIApplication().launch() 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /CooldownUITests/CooldownUITestsLaunchTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CooldownUITestsLaunchTests.swift 3 | // CooldownUITests 4 | // 5 | // Created by Jordi Bruin on 05/11/2021. 6 | // 7 | 8 | import XCTest 9 | 10 | class CooldownUITestsLaunchTests: XCTestCase { 11 | 12 | override class var runsForEachTargetApplicationUIConfiguration: Bool { 13 | true 14 | } 15 | 16 | override func setUpWithError() throws { 17 | continueAfterFailure = false 18 | } 19 | 20 | func testLaunch() throws { 21 | let app = XCUIApplication() 22 | app.launch() 23 | 24 | // Insert steps here to perform after app launch but before taking a screenshot, 25 | // such as logging into a test account or navigating somewhere in the app 26 | 27 | let attachment = XCTAttachment(screenshot: app.screenshot()) 28 | attachment.name = "Launch Screen" 29 | attachment.lifetime = .keepAlways 30 | add(attachment) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cooldown 2 | Quickly toggle Low Power Mode from the menu bar 3 | 4 | In macOS Monterey Apple introduced a new Low Power Mode for Mac. Cooldown is a simple menu bar app that allows you to quickly toggle Low Power Mode on and off. 5 | 6 | 📝 Release Notes 7 | 8 | 1.0 - Initial release 9 | 10 | 🗓 Planned features 11 | 12 | Automatically toggle LPM at certain times 13 | 14 | Automatically toggle LPM when certain apps are opened 15 | 16 | Design improvements 17 | 18 | ⚠️ Root access 19 | 20 | To toggle Low Power Mode, Cooldown uses Terminal commands that require root access. That is why the app will ask you to authenticate with TouchID on every toggle. I found a work around for this where the app will call a shortcut (that only needs to be approved once). 21 | 22 | --------------------------------------------------------------------------------