Skip to content

Commit

Permalink
✨ Catalina support
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkulman committed Jan 24, 2021
1 parent 8cc106c commit e87ae71
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "ChangeMenuBarColor",
platforms: [
.macOS(.v11)
.macOS(.v10_15)
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "0.3.1"),
Expand Down
2 changes: 1 addition & 1 deletion Sources/ChangeMenuBarColor/Commands/Gradient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final class Gradient: Command, ParsableCommand {
return nil
}

Log.debug("Generating gradient image from \(AXNameFromColor(startColor.cgColor)) to \(AXNameFromColor(endColor.cgColor))")
Log.debug("Generating gradient image from \(colorName(startColor)) to \(colorName(endColor))")
guard let topImage = createGradientImage(startColor: startColor, endColor: endColor, width: screen.size.width, height: screen.menuBarHeight) else {
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions Sources/ChangeMenuBarColor/Commands/SolidColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Created by Igor Kulman on 19.11.2020.
//

import Accessibility
import ArgumentParser
import Foundation
import Cocoa
Expand Down Expand Up @@ -45,7 +44,7 @@ final class SolidColor: Command, ParsableCommand {
return nil
}

Log.debug("Generating \(AXNameFromColor(color.cgColor)) solid color image")
Log.debug("Generating \(colorName(color)) solid color image")
guard let topImage = createSolidImage(color: color, width: screen.size.width, height: screen.menuBarHeight) else {
return nil
}
Expand Down
11 changes: 11 additions & 0 deletions Sources/ChangeMenuBarColor/Extensions/ImageFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// Created by Igor Kulman on 19.11.2020.
//

#if canImport(Accessibility)
import Accessibility
#endif
import Foundation
import Cocoa

Expand Down Expand Up @@ -66,3 +69,11 @@ func combineImages(baseImage: NSImage, addedImage: NSImage) -> NSImage? {
func createContext(width: CGFloat, height: CGFloat) -> CGContext? {
return CGContext(data: nil, width: Int(width), height: Int(height), bitsPerComponent: 8, bytesPerRow: 0, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedFirst.rawValue)
}

func colorName(_ color: NSColor) -> String {
if #available(OSX 11.0, *) {
return AXNameFromColor(color.cgColor)
} else {
return color.description
}
}

0 comments on commit e87ae71

Please sign in to comment.