Skip to content

Commit

Permalink
qubes-notification-daemon: WIP refactor notification daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
fepitre committed Mar 15, 2020
1 parent 5239e1f commit cbe8f59
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ install-init:
install -d $(DESTDIR)$(LIBDIR)/qubes/init
# FIXME: do a source code move vm-systemd/*.sh to init/
# since those scripts are shared between sysvinit and systemd.
install -m 0755 init/*.sh vm-systemd/*.sh $(DESTDIR)$(LIBDIR)/qubes/init/
install -m 0755 init/*.sh vm-systemd/*.sh vm-systemd/*.py $(DESTDIR)$(LIBDIR)/qubes/init/
install -m 0644 init/functions $(DESTDIR)$(LIBDIR)/qubes/init/

# Systemd service files
Expand All @@ -136,6 +136,8 @@ install-systemd: install-init
install -m 0644 vm-systemd/75-qubes-vm.preset $(DESTDIR)$(SYSLIBDIR)/systemd/system-preset/
install -m 0644 vm-systemd/qubes-core.conf $(DESTDIR)$(SYSLIBDIR)/modules-load.d/

mv $(DESTDIR)$(SYSLIBDIR)/systemd/system/org.freedesktop.qubes.Notifications.service $(DESTDIR)/usr/share/dbus-1/services/

install-sysvinit: install-init
install -d $(DESTDIR)/etc/init.d
install vm-init.d/qubes-sysinit $(DESTDIR)/etc/init.d/
Expand Down
3 changes: 3 additions & 0 deletions rpm_spec/core-agent.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ rm -f %{name}-%{version}
/usr/lib/qubes/init/resize-rootfs-if-needed.sh
/usr/lib/qubes/init/setup-rw.sh
/usr/lib/qubes/init/setup-rwdev.sh
/usr/lib/qubes/init/qubes-notifyd.py
%dir /usr/lib/qubes-bind-dirs.d
/usr/lib/qubes-bind-dirs.d/30_cron.conf
/usr/share/applications/qubes-run-terminal.desktop
Expand Down Expand Up @@ -851,6 +852,8 @@ The Qubes core startup configuration for SystemD init.
/lib/systemd/system/qubes-sync-time.timer
/lib/systemd/system/qubes-updates-proxy-forwarder@.service
/lib/systemd/system/qubes-updates-proxy-forwarder.socket
/lib/systemd/system/qubes-notifyd.service
/usr/share/dbus-1/services/org.freedesktop.qubes.Notifications.service
/lib/systemd/system-preset/%qubes_preset_file
/lib/modules-load.d/qubes-core.conf
/lib/systemd/system/boot.automount.d/30_qubes.conf
Expand Down
4 changes: 4 additions & 0 deletions vm-systemd/org.freedesktop.qubes.Notifications.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=/usr/lib/qubes/init/qubes-notifyd.py
SystemdService=qubes-notifyd.service
54 changes: 54 additions & 0 deletions vm-systemd/qubes-notifyd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3

import dbus.service
import dbus.mainloop.glib
from gi.repository import GLib
import subprocess
import dbus


class NotificationFetcher(dbus.service.Object):
_id = 0

@dbus.service.method("org.freedesktop.Notifications",
in_signature='susssasa{ss}i',
out_signature='u')
def Notify(self, app_name, notification_id, app_icon,
summary, body, actions, hints, expire_timeout):
if not notification_id:
self._id += 1
notification_id = self._id
# send data notification @default
subprocess.call(
["/usr/lib/qubes/qrexec-client-vm", "",
"qubes.TrayNotification",
"/usr/bin/printf", "{}\n{}\n{}\n".format(app_name, summary, body)])
return notification_id

@dbus.service.method("org.freedesktop.Notifications", in_signature='',
out_signature='as')
def GetCapabilities(self):
return "body"

@dbus.service.signal('org.freedesktop.Notifications', signature='uu')
def NotificationClosed(self, id_in, reason_in):
pass

@dbus.service.method("org.freedesktop.Notifications", in_signature='u',
out_signature='')
def CloseNotification(self, id):
pass

@dbus.service.method("org.freedesktop.Notifications", in_signature='',
out_signature='ssss')
def GetServerInformation(self):
return "qubes.TrayNotification", "https://www.qubes-os.org/", "0.0", "1"


if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
session_bus = dbus.SessionBus()
name = dbus.service.BusName("org.freedesktop.Notifications", session_bus)
NotificationFetcher(session_bus, '/org/freedesktop/Notifications')
loop = GLib.MainLoop()
loop.run()
8 changes: 8 additions & 0 deletions vm-systemd/qubes-notifyd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Qubes notifications service

[Service]
Type=dbus
BusName=org.freedesktop.Notifications
ExecStart=/usr/lib/qubes/init/qubes-notifyd.py

0 comments on commit cbe8f59

Please sign in to comment.