一个小型 D-Bus 监听器,监视通知,按应用名称和发送者过滤,并将匹配项以纯文本格式记录到文件,作为持久的 systemd 用户服务运行。

Stars

44

7 天增长

暂无数据

Fork 数

11

开放 Issue

0

开源协议

暂无数据

最近更新

2026-07-08

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它提供了一种轻量级、低依赖的解决方案,用于选择性记录桌面通知,并具备自动重启和跨登录/重启的持久性。

适合谁使用

  • 希望记录特定应用通知的 Linux 用户
  • 监控通知活动的系统管理员
  • 需要审计通知发送者的隐私意识用户
  • 需要简单通知日志工具的开发者

典型使用场景

  • 将特定消息应用(如 WhatsApp)的消息记录到文件
  • 审计通知发送者和时间戳以进行个人跟踪
  • 无需手动干预即可在重启后持续监控通知
  • 测试和调试桌面应用的通知行为

项目优势

  • 仅依赖 libdbus-1 和单个 C 源文件,构建简单
  • 通过 systemd 用户服务实现持久化,并支持崩溃后自动重启
  • 人类可读的日志输出,包含时间戳、发送者和正文
  • 支持 linger 选项,可在用户登录前运行

使用前须知

  • 依赖 D-Bus 的 eavesdrop 策略,可能被限制性会话总线配置阻止
  • 仅按应用名称和 summary 字段匹配通知,不解析 hints 字典以获取更可靠的发送者标识
  • 目前硬编码为单个应用和发送者过滤,修改需编辑 systemd 单元文件

README 快速开始

Build & Install

A small D-Bus listener that watches for org.freedesktop.Notifications.Notify calls, filters by app name + sender, and appends matches to a plain-text log file in a human-readable [timestamp] Sender: body format. Runs as a persistent systemd user service so it survives logouts/reboots.

1. Dependencies

Debian/Ubuntu:

sudo apt install build-essential pkg-config libdbus-1-dev

Fedora:

sudo dnf install gcc pkgconf-pkg-config dbus-devel

Arch:

sudo pacman -S base-devel dbus

2. Build

make

Or manually:

gcc -O2 -Wall -Wextra -o build/notify_logger logger.c $(pkg-config --cflags --libs dbus-1)

Test it manually first (Ctrl+C to stop):

./notify_logger --app whatsapp-linux-app --sender Name --out ./matches.log

Send yourself a test notification, or wait for a real one, and confirm a line appears in matches.log and on stdout, e.g.:

[2026-07-08 14:32:10] Name : hey, are you around?

If nothing shows up, see Troubleshooting below (eavesdrop policy).

3. Install as a persistent user service (systemd)

make install
mkdir -p ~/notify_logger ~/.config/systemd/user
cp logger.service ~/.config/systemd/user/notify-logger.service

systemctl --user daemon-reload
systemctl --user enable --now notify-logger.service

This makes it:

  • Start automatically on login (WantedBy=default.target)
  • Restart automatically if it crashes (Restart=on-failure)
  • Log matches to ~/notify_logger/matches.log

Check status / logs:

systemctl --user status notify-logger.service
journalctl --user -u notify-logger.service -f

To change the target app/sender/output path, edit the ExecStart= line in ~/.config/systemd/user/notify-logger.service, then:

systemctl --user daemon-reload
systemctl --user restart notify-logger.service

Optional: survive reboot even when not logged in

By default, user systemd units only run once you're logged in (or after a graphical session starts, per After=graphical-session.target in the unit). If you want it running even before login (e.g. on headless boot), enable lingering:

loginctl enable-linger $USER

4. Uninstall

systemctl --user disable --now notify-logger.service
rm ~/.config/systemd/user/notify-logger.service
rm ~/.local/bin/notify_logger
systemctl --user daemon-re

项目描述

A small D-Bus listener that watches for notify calls, filters by app name + sender, and appends matches to a plain-text log file in a human-readable format.

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

Infatoshi
精选
Infatoshi GitHub avatar

netherite

A from-scratch C/CUDA reimplementation of Minecraft 1.11.2 that is bit-verified against the original Java game and includes batched CUDA reinforcement learning support.

AI 与机器学习大语言模型
251
nsdkinx
精选
nsdkinx GitHub avatar

twell

Twell is a tiny, embeddable, zero-allocation physics engine for interruptible, Apple-style UI animations, available as a single-header C library with Python bindings.

移动开发设计与创意
17
sqliteai
精选
sqliteai GitHub avatar

waste

WASTE is a C-based inference engine that streams MoE experts from disk to run a 2.78 trillion-parameter model on a consumer laptop with 64 GB RAM.

数据与数据库数据工程
14