aboutsummaryrefslogtreecommitdiff
path: root/Sources
diff options
context:
space:
mode:
authorTommaso Negri <me@tommasongr.com>2026-08-11 18:19:02 +0200
committerTommaso Negri <me@tommasongr.com>2026-08-11 18:19:02 +0200
commiteb51ef01a4bd8bd7bea61a0a5fd524f66cf276cd (patch)
treed750764614bf1e5125c4a09ba6c72084b6a5772e /Sources
parenta1d62dd085ac70fc90a05095220156897bdd8f82 (diff)
downloadbar-eb51ef01a4bd8bd7bea61a0a5fd524f66cf276cd.tar.gz
bar-eb51ef01a4bd8bd7bea61a0a5fd524f66cf276cd.zip
add additional daemons
Diffstat (limited to 'Sources')
-rw-r--r--Sources/bar/bar.docc/daemons.md39
-rw-r--r--Sources/bar/bar.docc/daemons/daemon-batteryd.md27
-rw-r--r--Sources/bar/bar.docc/daemons/daemon-brightnessd.md27
-rw-r--r--Sources/bar/bar.docc/daemons/daemon-devicesd.md30
-rw-r--r--Sources/bar/bar.docc/daemons/daemon-focusd.md27
-rw-r--r--Sources/bar/bar.docc/daemons/daemon-networkd.md31
-rw-r--r--Sources/bar/bar.docc/daemons/daemon-nowplayingd.md29
-rw-r--r--Sources/bar/bar.docc/daemons/daemon-spaced.md29
-rw-r--r--Sources/bar/bar.docc/patches.md2
9 files changed, 220 insertions, 21 deletions
diff --git a/Sources/bar/bar.docc/daemons.md b/Sources/bar/bar.docc/daemons.md
index e99ecfc..c73377b 100644
--- a/Sources/bar/bar.docc/daemons.md
+++ b/Sources/bar/bar.docc/daemons.md
@@ -21,7 +21,7 @@ notify_post("bar.touch.<block-name>");
The ``Notifier`` system in *bar* receives the notification and re-runs the corresponding block's command.
The block itself stays stateless, it just reads and prints the current state whenever it is called.
-For example, the <doc:daemon-bar-volumed> daemon listens for CoreAudio volume change events and posts `bar.touch.volume`.
+For example, the <doc:daemon-volumed> daemon listens for CoreAudio volume change events and posts `bar.touch.volume`.
The volume block in ``Config`` runs once per notification, prints the current volume, and the bar updates.
## How to install
@@ -56,27 +56,26 @@ The process is very similar to the one described in the <doc:run-at-login> artic
### Audio
- <doc:daemon-volumed>
-<!-- - <doc:daemon-bar-micd> -->
-
-<!-- ### Display -->
-<!---->
-<!-- - <doc:daemon-bar-brightnessd> -->
-<!-- - <doc:daemon-bar-spaced> -->
-<!---->
-<!-- ### Power -->
-<!---->
-<!-- - <doc:daemon-bar-batteryd> -->
-<!---->
-<!-- ### Network -->
-<!---->
-<!-- - <doc:daemon-bar-networkd> -->
+
+### Display
+
+- <doc:daemon-brightnessd>
+- <doc:daemon-spaced>
+
+### Power
+
+- <doc:daemon-batteryd>
+
+### Network
+
+- <doc:daemon-networkd>
### Media
+- <doc:daemon-nowplayingd>
- <doc:daemon-mpd>
-<!-- - <doc:daemon-bar-nowplayingd> -->
-<!-- ### System -->
-<!---->
-<!-- - <doc:daemon-bar-focusd> -->
-<!-- - <doc:daemon-bar-devicesd> -->
+### System
+
+- <doc:daemon-devicesd>
+- <doc:daemon-focusd>
diff --git a/Sources/bar/bar.docc/daemons/daemon-batteryd.md b/Sources/bar/bar.docc/daemons/daemon-batteryd.md
new file mode 100644
index 0000000..db7a5dc
--- /dev/null
+++ b/Sources/bar/bar.docc/daemons/daemon-batteryd.md
@@ -0,0 +1,27 @@
+# batteryd
+
+React to battery and power source changes.
+
+This daemon listens for power source changes via **IOKit** (`IOPowerSources`) and posts a Darwin notification that tells *bar* to refresh the desired block.
+It fires when the battery level changes, the charger is plugged or unplugged, or the machine enters low-power mode.
+
+## How it works
+
+The daemon uses `IOPSNotificationCreateRunLoopSource` to register a callback that fires every time the power source state changes.
+When the callback fires, the daemon calls `notify_post("bar.touch.<block-name>")`.
+
+The ``Notifier`` system in *bar* picks this up and re-runs the block's command.
+
+### Dependencies
+
+- IOKit.framework, CoreFoundation.framework
+
+## Compile
+
+```shell
+cc -o bar-batteryd daemons/batteryd.c -framework IOKit -framework CoreFoundation
+```
+
+## Author
+
+Tommaso Negri [@tommasongr](https://github.com/tommasongr)
diff --git a/Sources/bar/bar.docc/daemons/daemon-brightnessd.md b/Sources/bar/bar.docc/daemons/daemon-brightnessd.md
new file mode 100644
index 0000000..b617e3b
--- /dev/null
+++ b/Sources/bar/bar.docc/daemons/daemon-brightnessd.md
@@ -0,0 +1,27 @@
+# brightnessd
+
+React to display brightness changes.
+
+This daemon listens for display brightness changes via **IOKit** and posts a Darwin notification that tells *bar* to refresh the desired block.
+It fires when the brightness level changes through keyboard keys, the Touch Bar, or System Settings.
+
+## How it works
+
+The daemon uses IOKit notifications to watch for changes to the display backlight service (`AppleBacklightDisplay` or `AppleIntelPanel`).
+When the brightness changes, the daemon calls `notify_post("bar.touch.<block-name>")`.
+
+The ``Notifier`` system in *bar* picks this up and re-runs the block's command.
+
+### Dependencies
+
+- IOKit.framework, CoreFoundation.framework
+
+## Compile
+
+```shell
+cc -o bar-brightnessd daemons/brightnessd.c -framework IOKit -framework CoreFoundation
+```
+
+## Author
+
+Tommaso Negri [@tommasongr](https://github.com/tommasongr)
diff --git a/Sources/bar/bar.docc/daemons/daemon-devicesd.md b/Sources/bar/bar.docc/daemons/daemon-devicesd.md
new file mode 100644
index 0000000..554371d
--- /dev/null
+++ b/Sources/bar/bar.docc/daemons/daemon-devicesd.md
@@ -0,0 +1,30 @@
+# devicesd
+
+React to USB device hotplug events.
+
+This daemon listens for USB device connect and disconnect events via **IOKit** and posts a Darwin notification that tells *bar* to refresh the desired block.
+It fires when you plug in or unplug any USB device, including Bluetooth controllers.
+
+## How it works
+
+The daemon uses IOKit matching notifications to watch for:
+- `IOUSBDevice` — USB device connect and disconnect events.
+- `IOBluetoothHCIController` — Bluetooth controller events.
+
+When a device is added or removed, the daemon calls `notify_post("bar.touch.<block-name>")`.
+
+The ``Notifier`` system in *bar* picks this up and re-runs the block's command.
+
+### Dependencies
+
+- IOKit.framework, CoreFoundation.framework
+
+## Compile
+
+```shell
+cc -o bar-devicesd daemons/devicesd.c -framework IOKit -framework CoreFoundation
+```
+
+## Author
+
+Tommaso Negri [@tommasongr](https://github.com/tommasongr)
diff --git a/Sources/bar/bar.docc/daemons/daemon-focusd.md b/Sources/bar/bar.docc/daemons/daemon-focusd.md
new file mode 100644
index 0000000..73dc5f6
--- /dev/null
+++ b/Sources/bar/bar.docc/daemons/daemon-focusd.md
@@ -0,0 +1,27 @@
+# focusd
+
+React to Focus and Do Not Disturb mode changes.
+
+This daemon listens for Focus mode and DND changes via `DistributedNotificationCenter` and posts a Darwin notification that tells *bar* to refresh the desired block.
+
+## How it works
+
+The daemon registers a distributed notification observer for `com.apple.notificationcenter.dndprefs_changed`, which macOS fires whenever the Focus mode or Do Not Disturb state changes.
+
+When the notification fires, the daemon calls `notify_post("bar.touch.<block-name>")`.
+
+The ``Notifier`` system in *bar* picks this up and re-runs the block's command.
+
+### Dependencies
+
+- CoreFoundation.framework
+
+### Compile
+
+```shell
+cc -o bar-focusd daemons/focusd.c -framework CoreFoundation
+```
+
+## Author
+
+Tommaso Negri [@tommasongr](https://github.com/tommasongr)
diff --git a/Sources/bar/bar.docc/daemons/daemon-networkd.md b/Sources/bar/bar.docc/daemons/daemon-networkd.md
new file mode 100644
index 0000000..cb9c765
--- /dev/null
+++ b/Sources/bar/bar.docc/daemons/daemon-networkd.md
@@ -0,0 +1,31 @@
+# networkd
+
+React to network state changes.
+
+This daemon listens for network configuration changes via **SystemConfiguration** and posts a Darwin notification that tells *bar* to refresh the desired block.
+It fires when the WiFi connects or disconnects, the IP address changes, or a VPN toggles.
+
+## How it works
+
+The daemon uses `SCDynamicStore` to watch for changes to:
+- `State:/Network/Global/IPv4` — IPv4 address changes.
+- `State:/Network/Global/IPv6` — IPv6 address changes.
+- `State:/Network/Interface/en0/AirPort` — WiFi state changes.
+
+When any of these keys change, the daemon calls `notify_post("bar.touch.<block-name>")`.
+
+The ``Notifier`` system in *bar* picks this up and re-runs the block's command.
+
+### Dependencies
+
+- SystemConfiguration.framework, CoreFoundation.framework
+
+## Compile
+
+```shell
+cc -o bar-networkd daemons/networkd.c -framework SystemConfiguration -framework CoreFoundation
+```
+
+## Author
+
+Tommaso Negri [@tommasongr](https://github.com/tommasongr)
diff --git a/Sources/bar/bar.docc/daemons/daemon-nowplayingd.md b/Sources/bar/bar.docc/daemons/daemon-nowplayingd.md
new file mode 100644
index 0000000..9d33929
--- /dev/null
+++ b/Sources/bar/bar.docc/daemons/daemon-nowplayingd.md
@@ -0,0 +1,29 @@
+# nowplayingd
+
+React to music track changes.
+
+This daemon listens for track change notifications from **Music** and **Spotify** via `DistributedNotificationCenter` and posts a Darwin notification that tells *bar* to refresh the desired block.
+
+## How it works
+
+The daemon registers distributed notification observers for:
+- `com.apple.Music.playerInfo` — fired by Music.app when the track changes.
+- `com.spotify.client.PlaybackStateChanged` — fired by Spotify when the track changes.
+
+When either notification fires, the daemon calls `notify_post("bar.touch.<block-name>")`.
+
+The ``Notifier`` system in *bar* picks this up and re-runs the block's command, which can read the current track from any source.
+
+### Dependencies
+
+- CoreFoundation.framework
+
+### Compile
+
+```shell
+cc -o bar-nowplayingd daemons/nowplayingd.c -framework CoreFoundation
+```
+
+## Author
+
+Tommaso Negri [@tommasongr](https://github.com/tommasongr)
diff --git a/Sources/bar/bar.docc/daemons/daemon-spaced.md b/Sources/bar/bar.docc/daemons/daemon-spaced.md
new file mode 100644
index 0000000..1b4cea0
--- /dev/null
+++ b/Sources/bar/bar.docc/daemons/daemon-spaced.md
@@ -0,0 +1,29 @@
+# spaced
+
+React to desktop space changes.
+
+This daemon monitors the active desktop space and posts a Darwin notification that tells *bar* to refresh the desired block.
+It fires when you switch between Mission Control spaces, full-screen apps, or Stage Manager groups.
+
+## How it works
+
+The daemon uses a lightweight 0.5-second poll of a private CoreGraphics function (`CGSCopyActiveMenuBarDisplayIdentifier`) to detect when the active space changes.
+When a change is detected, the daemon calls `notify_post("bar.touch.<block-name>")`.
+
+The ``Notifier`` system in *bar* picks this up and re-runs the block's command.
+
+> Note: The 0.5-second poll interval is negligible — the daemon uses near-zero CPU while idle.
+
+### Dependencies
+
+- CoreFoundation.framework
+
+## Compile
+
+```shell
+cc -o bar-spaced daemons/spaced.c -framework CoreFoundation
+```
+
+## Author
+
+Tommaso Negri [@tommasongr](https://github.com/tommasongr)
diff --git a/Sources/bar/bar.docc/patches.md b/Sources/bar/bar.docc/patches.md
index 1b05ffe..c4f02e3 100644
--- a/Sources/bar/bar.docc/patches.md
+++ b/Sources/bar/bar.docc/patches.md
@@ -1,6 +1,6 @@
# Patches
-Extend the program with additional functionality.
+Extend the program by applying git diffs.
A *patch* is a set of source code changes that add a specific feature to a program.
Unlike plugins or extensions, patches modify the program directly — you edit the source, rebuild, and the new functionality becomes part of the binary.