Thu, 07 Mar 2013
For those who haven't been keeping up with all of the awesome code Ralph Bean has been churning out lately, be sure to checkout fedmsg.com. Hop on #fedora-fedmsg on Freenode or load up busmon to see it in action. Not all of the Fedora Infrastructure services currently fire off fedmsgs, but we're getting very close.
This technology is built on top of Moksha, which I created many years ago while writing the first version of the fedoracommunity app. It's come a long way since then, and now can speak ØMQ over WebSockets, as well as AMQP and STOMP over Orbited. Now the time has finally come to bring Moksha to the desktop!
Introducing fedmsg-notifyfedmsg-notify lets you get realtime desktop notifications of activity within the Fedora community. It allows you to tap into the firehose of contributions as they happen and filter them to your liking. It works with any window manager that supports the notification-spec, however I've only seen the gravatars show up using GNOME.
For GNOME Shell users, you can
and then enable it with the
gnome-tweak-tool or by running
`gnome-shell-extension-tool -e email@example.com` (and
then hit alt+f2 and type 'r' to reload the shell). You will then be graced with the presence of The Bus:
For those who aren't running GNOME shell, you can simply
fedmsg-notify, and then run
launch it from your Settings menu. Due to a dependency on Twisted's
gtk3reactor, fedmsg-notify is currently only available on Fedora 18 and newer.
The first tab shows you all services that are currently hooked into fedmsg. As we add new ones, the gui will automatically display them. These services are defined in the fedmsg_meta_fedora_infrastructure package.
The Advanced tab lets you further customize what messages you want to see. The "Bugs that you have encountered" option will display all messages that reference any Bugzilla numbers for crashes that you have hit locally with ABRT. The other filters involve querying your local yum database or the PackageDB.
Under the hood
The fedmsg-notify-daemon itself is fairly minimal (see daemon.py).
At it's core, it's just a Twisted
reactor that consumes ØMQ messages. Moksha does all of the heavy lifting behind
the scenes, so all we really have to do is specify a
topic to subscribe to and define a
that gets called with each message. This is essentially just a basic Moksha
Consumer with some fedmsg + DBus glue.
class FedmsgNotifyService(dbus.service.Object, fedmsg.consumers.FedmsgConsumer): topic = 'org.fedoraproject.*' def consume(self, msg): …
The daemon will automatically startup upon login, or will get activated by DBus when enabled via the GUI. When a message arrives, it filters it accordingly, downloads & caches the icons, [optionally] relays the message over DBus, and then displays the notification on your desktop.
The API for writing custom filters is dead simple (see filters.py).
Here is an example of one:
""" Matches messages regarding packages that a given user has ACLs on """
__description__ = 'Packages that these users maintain'
__user_entry__ = 'Usernames'
def __init__(self, settings):
self.usernames = settings.replace(',', ' ').split()
self.packages = set()
for username in self.usernames:
log.info("Querying the PackageDB for %s's packages" % username)
for pkg in PackageDB().user_packages(username)['pkgs']:
def match(self, msg, processor):
packages = processor.packages(msg)
for package in self.packages:
if package in packages:
fedmsg-notify-config interface (see gui.py),
automatically introspects the filters and populates the Advanced tab with the
appropriate labels, switches, and text entries.
Consuming fedmsg over DBusLet's say you want to write an application that listens to fedmsg, but you don't want to deal with spinning up your own connection, or you're not using Python, etc. For these cases, fedmsg-notify supports relaying messages over DBus. This functionality can be enabled by running `
gsettings set org.fedoraproject.fedmsg.notify emit-dbus-signals true`. You can then easily listen for the
MessageReceivedDBus signal, like so:
import json, dbus from gi.repository import GObject from dbus.mainloop.glib import DBusGMainLoop def consume(topic, body): print(topic) print(json.loads(body)) DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() bus.add_signal_receiver(consume, signal_name='MessageReceived', dbus_interface='org.fedoraproject.fedmsg.notify', path='/org/fedoraproject/fedmsg/notify') loop = GObject.MainLoop() loop.run()
If you're interested in helping out with any layer of the fedmsg stack, hop in #fedora-apps, and fork it on GitHub:
Hop on the bus!
Posted by Renich at Fri Mar 8 07:49:27 2013
Now, this is what collaboration and community point towards to.
Posted by Matthias Clasen at Fri Mar 8 11:02:07 2013
that looks useful.
But I wonder why you decided to make it an extension and put it on the top panel - I think this would be much better off as an application, instead of a shell extension.
Posted by Luke Macken at Fri Mar 8 13:30:14 2013
@Matthias: The shell extension is totally optional. It's simply sends a dbus message to enable it and lets you easily open the config options. It was pretty much just an exercise for me to figure out how to write extensions…
Posted by Dan M at Sat Mar 9 05:06:38 2013
Works great on Fedora 19 and MATE Desktop!
Great job Luke!