aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sources/bar/bar.docc/patches.md1
-rw-r--r--Sources/bar/bar.docc/patches/patch-background-blur.md32
-rw-r--r--patches/patch-background_blur-20260811-10fed47.patch40
3 files changed, 73 insertions, 0 deletions
diff --git a/Sources/bar/bar.docc/patches.md b/Sources/bar/bar.docc/patches.md
index de0514a..1b05ffe 100644
--- a/Sources/bar/bar.docc/patches.md
+++ b/Sources/bar/bar.docc/patches.md
@@ -88,6 +88,7 @@ To publish, upload the patch somewhere publicly accessible (e.g., the *bar* GitH
### Appearance
- <doc:patch-font-offset>
+- <doc:patch-background-blur>
### Functionality
diff --git a/Sources/bar/bar.docc/patches/patch-background-blur.md b/Sources/bar/bar.docc/patches/patch-background-blur.md
new file mode 100644
index 0000000..2f6fc2b
--- /dev/null
+++ b/Sources/bar/bar.docc/patches/patch-background-blur.md
@@ -0,0 +1,32 @@
+# Background blur
+
+Set a backdrop blur to the entire bar.
+
+This patch adds a `backgroundBlur` option (Double) to ``Config``.
+Adjust the value to increase or decrease the blur effect behind the bar.
+
+```swift
+enum Config {
+ /// The blur amount used for the bar background.
+ static let backgroundBlur: Double = 10
+}
+```
+
+> Warning: This patch uses private Apple APIs.
+Future versions of macOS might break the functionality.
+
+## Installation
+
+```shell
+curl -sL https://raw.githubusercontent.com/paninihouse/bar/refs/heads/master/patches/patch-background_blur-20260811-10fed47.patch | patch -p1
+```
+
+After applying, rebuild the program:
+
+```shell
+make install
+```
+
+## Author
+
+Tommaso Negri [@tommasongr](https://github.com/tommasongr)
diff --git a/patches/patch-background_blur-20260811-10fed47.patch b/patches/patch-background_blur-20260811-10fed47.patch
new file mode 100644
index 0000000..642dfd1
--- /dev/null
+++ b/patches/patch-background_blur-20260811-10fed47.patch
@@ -0,0 +1,40 @@
+diff --git a/Sources/bar/Config.swift b/Sources/bar/Config.swift
+index c2299fc..425ac32 100644
+--- a/Sources/bar/Config.swift
++++ b/Sources/bar/Config.swift
+@@ -42,6 +42,9 @@ enum Config {
+ /// The color used for the bar background.
+ static let background: Color = .hex("#000000").opacity(0.75)
+
++ /// The blur amount used for the bar background.
++ static let backgroundBlur: Double = 10
++
+ /// The colors used to highlight a cell at different levels (see ``Cell``).
+ static let highlights: [Color] = [.blue, .purple]
+
+diff --git a/Sources/bar/Views/AppDelegate.swift b/Sources/bar/Views/AppDelegate.swift
+index cefdfc0..a9bdcb1 100644
+--- a/Sources/bar/Views/AppDelegate.swift
++++ b/Sources/bar/Views/AppDelegate.swift
+@@ -11,7 +11,20 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
+ for screen in NSScreen.screens {
+ let frame = Screen.barFrame(screen, position: Config.position, height: Config.height)
+ let window = BarWindow(contentRect: frame)
+- window.contentView = NSHostingView(rootView: BarView(blocks: blocks))
++
++ // Create the background blur view
++ let backgroundBlurView = BackgroundBlurView()
++ backgroundBlurView.autoresizingMask = [.width, .height]
++ backgroundBlurView.frame = window.contentView?.bounds ?? .zero
++
++ // Create the bar view as a child of the background blur view
++ let barView = NSHostingView(rootView: BarView(blocks: blocks))
++ barView.autoresizingMask = [.width, .height]
++ barView.frame = window.contentView?.bounds ?? .zero
++ backgroundBlurView.addSubview(barView)
++
++ // Present the window with the background blur view as content view
++ window.contentView = backgroundBlurView
+ window.orderFrontRegardless()
+ windows.append(window)
+ }