-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d56852
commit 927f821
Showing
9 changed files
with
243 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Grayscale.swift | ||
// grayscale | ||
// | ||
// Created by Brett Gutstein on 1/31/21. | ||
// Copyright © 2021 Brett Gutstein. All rights reserved. | ||
// | ||
|
||
// see Sources/Bridge.h for information about toggling grayscale | ||
func grayscaleEnabled() -> Bool { | ||
return MADisplayFilterPrefGetCategoryEnabled(SYSTEM_FILTER) && | ||
(MADisplayFilterPrefGetType(SYSTEM_FILTER) == GRAYSCALE_TYPE) | ||
} | ||
|
||
func enableGrayscale() { | ||
MADisplayFilterPrefSetType(SYSTEM_FILTER, GRAYSCALE_TYPE) | ||
MADisplayFilterPrefSetCategoryEnabled(SYSTEM_FILTER, true) | ||
_UniversalAccessDStart(UNIVERSALACCESSD_MAGIC) | ||
} | ||
|
||
func disableGrayscale() { | ||
MADisplayFilterPrefSetCategoryEnabled(SYSTEM_FILTER, false) | ||
_UniversalAccessDStart(UNIVERSALACCESSD_MAGIC) | ||
} | ||
|
||
func toggleGrayscale() { | ||
grayscaleEnabled() ? disableGrayscale() : enableGrayscale() | ||
} | ||
|
||
func setGrayscale(_ enable: Bool) { | ||
if grayscaleEnabled() != enable { | ||
toggleGrayscale() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Logging.swift | ||
// grayscale | ||
// | ||
// Created by Brett Gutstein on 1/31/21. | ||
// Copyright © 2021 Brett Gutstein. All rights reserved. | ||
// | ||
|
||
enum LogLevel: Int { | ||
case VERBOSE = 0 | ||
case ALWAYS_PRINT | ||
} | ||
|
||
let currentLogLevel: LogLevel = .ALWAYS_PRINT | ||
|
||
func grayscaleLog(logLevel: LogLevel = .ALWAYS_PRINT, _ format: String, | ||
file: String = #file, caller: String = #function, args: CVarArg...) { | ||
if (logLevel.rawValue >= currentLogLevel.rawValue) { | ||
let fileName = file.components(separatedBy: "/").last ?? "" | ||
NSLog("\(fileName):\(caller) " + format, args) | ||
} | ||
} |
Oops, something went wrong.