Unified Push

Chatty Matrix Push notifications

You need

  • Chatty as example application
  • kunifiedpush as distributor
  • A Push server (e.g. ntfy)
  • A Matrix push gateway (e.g. ntfy)
  • A Matrix server that sends push notifications (e.g. synapse)

It's recommended to run these on your own so you can peek at all points of the chain.

Server side

 curl https://ntfy.example.com/_matrix/push/v1/notify
 {"unifiedpush":{"gateway":"matrix"}}

Client side

  • Install and start kunified push. I'm currently using this branch
  sudo apt install --no-install-recommends extra-cmake-modules qmake6 qt6-base-dev qt6-websockets-dev libkf6coreaddons-dev libkf6kcmutils-dev libkf6service-dev
  git clone https://github.com/agx/kunifiedpush/tree/chatty
  cmake -DCMAKE_INSTALL_PREFIX=/usr/local -S . -B _build
  make -C _build install
  • Add kunifiedpush configuration
mkdir -p ~/.config/KDE/
cat <<EOF > ~/.config/KDE/kunifiedpush-distributor.conf
[Ntfy]
Url=https://ntfy.example.com/

[PushProvider]
Type=Ntfy
EOF
  • You can test this with the demo notifier (_build/bin/demo-notifier)

  • Install and run chatty. I'm currently using this MR

sudo apt build-dep chatty
git clone -b matrix/pushers https://gitlab.gnome.org/guidog/chatty
meson setup _build
meson compile -C _build
  • Run chatty and add a matrix user.
  G_MESSAGES_DEBUG=chatty-uf-connector _build/run -vvvvv
  • Check if chatty exposes the connector object on DBus
busctl tree --user sm.puri.Chatty
├─ /org
│ └─ /org/unifiedpush
│   └─ /org/unifiedpush/Connector
└─ /sm
  └─ /sm/puri
    └─ /sm/puri/Chatty
      └─ /sm/puri/Chatty/window
        └─ /sm/puri/Chatty/window/1
  • Add the push server. Use URL from above as push server (https://ntfy.example.com/_matrix/push/v1/notify)
  • This should happen:

    • Chatty calls Register on the distributor
    • The distributor responds with NewEndpoint
    • Chatty stores that in ~/.config/chatty/unified-push.cfg
    • When sending a notification into a room the user is part of you should see

      chatty-uf-connector[31115]: DEBUG: Received message:

If things don't work

  • Make sure chatty's unified-push.cfg and kunifiedpush's kunifiedpush-distributor.conf agree on the token.
  • Make sure endpoint in kunifiedpush-distributor.conf and the pushkey of the pusher registered on the Matrix server match. You can get registered pushers via
  curl -H "Authorization: Bearer ${ACCESS_TOKEN}" -X GET "${SERVER}/_matrix/client/r0/pushers"
  • Make the ntfy server gets the push notifications from the Matrix server. A simple way is to register the topic from the kunified push configuration via the webui.

Sending SMS notifications

Most Linux Mobile phones don't wake up yet on incoming data connections however devices like the Librem 5 or PinePhone wake up on incoming SMS. We can leverage this identify devices about incoming push notifications. For that we run a ntfy client on the the ntfy server like:

ntfy subscribe <token> ./textbelt-sms

where textbelt-sms is a simple shell script to send SMS via the textbelt SMS service:

#!/bin/bash

# The phone number of the phone you want notified
NUMBER="<yourphonenumber>"
# The token for the textbelt API
KEY="<textbeltoken>"

# Drop some json to fit into one SMS
msg=$(echo "$m" | jq -c '.notification.room_id, .notification.event_id' | base64)

curl -X POST https://textbelt.com/text \
     --data-urlencode phone="$NUMBER" \
     --data-urlencode message="$msg" \
     -d key="$KEY"

Instead of textbelt you can use an old phone or USB modem connected to your ntfy server and use mmcli to send the SMS. This would allow to make this free of charge.