寻求适用于Ubuntu 22.04 Wayland SwayWM的虚拟通知守护进程
寻求适用于Ubuntu 22.04 Wayland SwayWM的虚拟通知守护进程
嘿,太懂你这种被那些凑活出来的弹窗烦到的心情了!刚好有几个靠谱的方案,不用再折腾dunst就能解决你的问题:
方案1:使用
notify-dummy轻量虚拟守护进程
这个小工具就是专门为这种场景设计的——它会在DBus上注册成标准的通知服务,接收所有通知请求但完全不做任何显示,完美符合你的需求。安装步骤如下:- 先安装编译依赖:
sudo apt install git build-essential libdbus-1-dev - 克隆项目源码:
git clone https://github.com/eworm-de/notify-dummy.git - 进入目录编译并安装:
cd notify-dummy && make && sudo make install - 最后在你的Sway配置文件(通常是
~/.config/sway/config)里添加一行,让它随Sway自动启动:exec --no-startup-id notify-dummy
- 先安装编译依赖:
方案2:自己写一个极简的Python脚本(零额外依赖)
如果你不想编译源码,也可以快速写个超简单的Python脚本,利用DBus模拟通知守护进程。具体步骤:- 创建脚本文件:
touch ~/.local/bin/dummy-notify-daemon.py - 将以下代码粘贴进去:
import dbus import dbus.service from dbus.mainloop.glib import DBusGMainLoop import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk class NotificationDaemon(dbus.service.Object): def __init__(self): bus_name = dbus.service.BusName('org.freedesktop.Notifications', bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, '/org/freedesktop/Notifications') @dbus.service.method('org.freedesktop.Notifications', in_signature='susssasa{sv}i', out_signature='u') def Notify(self, app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout): return 0 # 返回无效通知ID,假装处理成功 @dbus.service.method('org.freedesktop.Notifications', in_signature='', out_signature='as') def GetCapabilities(self): return [] # 声称无任何通知能力 @dbus.service.method('org.freedesktop.Notifications', in_signature='', out_signature='ssss') def GetServerInformation(self): return ('DummyNotify', 'DummyOrg', '1.0', '1.2') if __name__ == '__main__': DBusGMainLoop(set_as_default=True) NotificationDaemon() Gtk.main() - 给脚本添加执行权限:
chmod +x ~/.local/bin/dummy-notify-daemon.py - 在Sway配置文件里添加启动命令:
exec --no-startup-id python3 ~/.local/bin/dummy-notify-daemon.py
- 创建脚本文件:
这两个方案都能让系统里的应用认为存在正常的通知守护进程,不会再弹出那些烦人的替代窗口,而且完全不会显示任何通知内容,刚好匹配你的需求。
备注:内容来源于stack exchange,提问作者user
相关产品推荐
相关产品推荐

