mirror of
https://github.com/swiftbar/SwiftBar.git
synced 2024-09-11 16:05:33 +03:00
Fixing Reduce Transparency #156
This commit is contained in:
parent
81291933e9
commit
efe39394a5
@ -171,6 +171,10 @@ class App: NSObject {
|
||||
UserDefaults.standard.string(forKey: "AppleInterfaceStyle") != nil
|
||||
}
|
||||
|
||||
public static var isReduceTransparencyEnabled: Bool {
|
||||
UserDefaults(suiteName: "com.apple.universalaccess.plist")?.bool(forKey: "reduceTransparency") ?? false
|
||||
}
|
||||
|
||||
public static func checkForUpdates() {
|
||||
delegate.softwareUpdater.checkForUpdates()
|
||||
}
|
||||
|
@ -127,7 +127,9 @@ extension MenubarItem: NSMenuDelegate {
|
||||
|
||||
var params = MenuLineParameters(line: currentTitleLine)
|
||||
params.params["color"] = "white"
|
||||
barItem.button?.attributedTitle = atributedTitle(with: params).title
|
||||
if !App.isReduceTransparencyEnabled {
|
||||
barItem.button?.attributedTitle = atributedTitle(with: params).title
|
||||
}
|
||||
|
||||
guard let lastUpdated = plugin?.lastUpdated else { return }
|
||||
let formatter = RelativeDateTimeFormatter()
|
||||
@ -472,30 +474,17 @@ extension MenubarItem {
|
||||
if let length = params.length, length < title.count {
|
||||
title = String(title.prefix(length)).appending("...")
|
||||
}
|
||||
let isMultilineTitle = title.contains("\\n")
|
||||
title = title.replacingOccurrences(of: "\\n", with: "\n")
|
||||
|
||||
let fontSize = params.size ?? 0
|
||||
let color = params.color ?? NSColor.labelColor
|
||||
let font = NSFont(name: params.font ?? "", size: fontSize) ??
|
||||
NSFont.menuBarFont(ofSize: fontSize)
|
||||
let offset = font.menuBarOffset
|
||||
|
||||
let style = NSMutableParagraphStyle()
|
||||
style.alignment = .left
|
||||
|
||||
var offset: CGFloat = 0
|
||||
|
||||
// custom offset for Big Sur, Catalina doesn't need one
|
||||
if #available(OSX 11.0, *) {
|
||||
offset = font.menuBarOffset
|
||||
if isMultilineTitle {
|
||||
offset = -5
|
||||
}
|
||||
}
|
||||
|
||||
if isMultilineTitle {
|
||||
style.paragraphSpacing = 0.1
|
||||
}
|
||||
|
||||
var attributedTitle = NSMutableAttributedString(string: title)
|
||||
|
||||
if params.symbolize, !params.ansi {
|
||||
|
Loading…
Reference in New Issue
Block a user