1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-12-14 11:47:33 +00:00
Send push notifications to your phone or desktop using PUT/POST
Find a file
Philipp Heckel b775e6dfce Limits
2021-11-01 16:39:40 -04:00
assets Styling 2021-10-24 14:22:53 -04:00
cmd Add firebase support 2021-10-29 13:58:14 -04:00
config Limits 2021-11-01 16:39:40 -04:00
examples Make things prettier, better sound, FAQ, icon in desktop notification 2021-10-24 22:08:06 -04:00
scripts Makefile, Dockerfile, GoReleaser, config.yml, systemd service 2021-10-23 21:29:45 -04:00
server Limits 2021-11-01 16:39:40 -04:00
util Limits 2021-11-01 16:39:40 -04:00
.gitignore Makefile, Dockerfile, GoReleaser, config.yml, systemd service 2021-10-23 21:29:45 -04:00
.goreleaser.yml Makefile, Dockerfile, GoReleaser, config.yml, systemd service 2021-10-23 21:29:45 -04:00
Dockerfile Makefile, Dockerfile, GoReleaser, config.yml, systemd service 2021-10-23 21:29:45 -04:00
go.mod WIP: Firebase support 2021-10-28 23:50:38 -04:00
go.sum WIP: Firebase support 2021-10-28 23:50:38 -04:00
LICENSE Initial commit 2021-10-22 18:54:02 -04:00
main.go Makefile, Dockerfile, GoReleaser, config.yml, systemd service 2021-10-23 21:29:45 -04:00
Makefile Makefile, Dockerfile, GoReleaser, config.yml, systemd service 2021-10-23 21:29:45 -04:00
README.md Readme 2021-10-30 23:46:50 -04:00

ntfy

ntfy (pronounce: notify) is a super simple pub-sub notification service. It allows you to send desktop and (soon) phone notifications via scripts. I run a free version of it on ntfy.sh. No signups or cost.

Usage

Subscribe to a topic

Topics are created on the fly by subscribing to them. You can create and subscribe to a topic either in a web UI, or in your own app by subscribing to an SSE/EventSource, or a JSON or raw feed.

Because there is no sign-up, the topic is essentially a password, so pick something that's not easily guessable.

Here's how you can create a topic mytopic, subscribe to it topic and wait for events. This is using curl, but you can use any library that can do HTTP GETs:

# Subscribe to "mytopic" and output one message per line (\n are replaced with a space)
curl -s ntfy.sh/mytopic/raw

# Subscribe to "mytopic" and output one JSON message per line
curl -s ntfy.sh/mytopic/json

# Subscribe to "mytopic" and output an SSE stream (supported via JS/EventSource)
curl -s ntfy.sh/mytopic/sse

You can easily script it to execute any command when a message arrives. This sends desktop notifications (just like the web UI, but without it):

while read msg; do
  [ -n "$msg" ] && notify-send "$msg"
done < <(stdbuf -i0 -o0 curl -s ntfy.sh/mytopic/raw)

Publish messages

Publishing messages can be done via PUT or POST using. Here's an example using curl:

curl -d "long process is done" ntfy.sh/mytopic

Messages published to a non-existing topic or a topic without subscribers will not be delivered later. There is (currently) no buffering of any kind. If you're not listening, the message won't be delivered.

Installation

Please check out the releases page for binaries and deb/rpm packages.

  1. Install ntfy using one of the methods described below
  2. Then (optionally) edit /etc/ntfy/config.yml
  3. Then just run it with ntfy (or systemctl start ntfy when using the deb/rpm).

Binaries and packages

Debian/Ubuntu (from a repository):

curl -sSL https://archive.heckel.io/apt/pubkey.txt | sudo apt-key add -
sudo apt install apt-transport-https
sudo sh -c "echo 'deb [arch=amd64] https://archive.heckel.io/apt debian main' > /etc/apt/sources.list.d/archive.heckel.io.list"  
sudo apt update
sudo apt install ntfy

Debian/Ubuntu (manual install):

sudo apt install tmux
wget https://github.com/binwiederhier/ntfy/releases/download/v1.1.2/ntfy_1.1.2_amd64.deb
dpkg -i ntfy_1.1.2_amd64.deb

Fedora/RHEL/CentOS:

rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v1.1.2/ntfy_1.1.2_amd64.rpm

Docker:

docker run --rm -it binwiederhier/ntfy

Go:

go get -u heckel.io/ntfy

Manual install (any x86_64-based Linux):

wget https://github.com/binwiederhier/ntfy/releases/download/v1.1.2/ntfy_1.1.2_linux_x86_64.tar.gz
sudo tar -C /usr/bin -zxf ntfy_1.1.2_linux_x86_64.tar.gz ntfy
./ntfy

Building

Building ntfy is simple. Here's how you do it:

make build-simple
# Builds to dist/ntfy_linux_amd64/ntfy

To build releases, I use GoReleaser. If you have that installed, you can run make build or make build-snapshot.

TODO

  • add HTTPS
  • make limits configurable
  • limit max number of subscriptions

Contributing

I welcome any and all contributions. Just create a PR or an issue.

License

Made with ❤️ by Philipp C. Heckel, distributed under the Apache License 2.0.

Third party libraries and resources: