Jay*_*iya 8 notification unity notify-osd
我正在我的机器上测试 i3wm(这sudo apt-get install i3是我运行的,并从登录屏幕中选择了 i3),过了一会儿,决定切换回 Unity。切换回来后,我注意到通知出现在右上角,类似于 i3,即使我使用的是 Unity。
我真的很喜欢它改用普通的 Unity 通知气泡。
我看着它,并证明代替notify-osd,dunst正在使用。
我尝试使用sudo vim /usr/share/dbus-1/services/org.freedesktop.Notifications.service和编辑该文件,但它Exec=/usr/lib/x86_64-linux-gnu/notify-osd按预期具有正确的行(即)。
我也尝试过,unity-tweak-tool --reset-unity但这没有做任何事情。
我可以恢复正常通知吗?任何帮助将不胜感激。谢谢 :)
编辑:通过删除 i3wm 本身(和 dunst),我能够返回正常通知。我实际上要问的是:是否可以更改为正常通知,同时仍将 i3 和 dunst 保留在我的系统上?
注意:这不是Notify-osd 通知出现在左上角无主题的副本。那里的解决方案是删除 dunst,我想保留 dunst 并在我选择 i3 时让它工作,当我选择 Unity 时让 notify-osd 工作。
我意识到我参加聚会晚了两年,但是如果其他人遇到这个问题,这里有一个解决方案,它会在登录 Unity 时使用 notify-osd,在运行 i3 时使用 dunst。
如果您只想安装 dunst,但不想通过 DBus 自动调用它,请跳至 Quick Hack 部分。
我们想要覆盖 的行为,/usr/share/dbus-1/services/org.freedesktop.Notifications.service更重要的是/usr/share/dbus-1/services/org.knopwob.dunst.service。
由于 Dbus 在搜索服务文件时会查看 $XDG_DATA_HOME,而 Ubuntu 出于某种原因没有设置该环境变量,因此我们需要自己进行:
echo 'export XDG_DATA_HOME=${XDG_DATA_HOME:="$HOME/.local/share"}' >> ~/.profile
Run Code Online (Sandbox Code Playgroud)
我们需要创建我们的服务文件:
mkdir -p $HOME/.local/share/dbus-1/services
nano $HOME/.local/share/dbus-1/services/usernotify.service
Run Code Online (Sandbox Code Playgroud)
使文件看起来像这样:
[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=/usr/bin/my_notifier
Run Code Online (Sandbox Code Playgroud)
创建 D-BUS 文件中引用的脚本,如果 i3 正在运行,则调用 dunst,否则调用 notify-osd:
sudo nano /usr/bin/my_notifier
Run Code Online (Sandbox Code Playgroud)
让它看起来像这样:
echo 'export XDG_DATA_HOME=${XDG_DATA_HOME:="$HOME/.local/share"}' >> ~/.profile
Run Code Online (Sandbox Code Playgroud)
使其可执行:
sudo chmod a+x /usr/bin/my_notifier
Run Code Online (Sandbox Code Playgroud)
应该是这样。注销然后重新登录。通过运行在 Unity 和 i3 中对其进行测试
notify-send foo bar
Run Code Online (Sandbox Code Playgroud)
如果您只想使用 notify-osd 进行相应编辑就足够了/usr/share/dbus-1/services/org.knopwob.dunst.service:
[D-BUS Service]
Name=org.freedesktop.Notifications
#Exec=/usr/bin/dunst
Exec=/usr/lib/x86_64-linux-gnu/notify-osd
Run Code Online (Sandbox Code Playgroud)