Git Product home page Git Product logo

notify-send-http's Introduction

notify-send-http

Trigger notify-send across the network using HTTP, useful for triggering notifications from local VMs / Containers into your own computer. It even supports notification icons!

demo

Tested on Ubuntu 14.04 only

Why?

Because I do all of my dev work on virtualized environments and I use guard quite a lot to keep my Ruby tests running when files get changed. The problem is that its builtin notification support will trigger a notify-send inside the virtual environment instead of my machine.

With notify-send-http I can run an HTTP server on my machine and make use of a custom notify-send executable on my virtual environments that has the same interface as the original command and will send notifications to the HTTP server so that I can see alerts poping up on my screen whenever the build fails.

Server setup

First you'll need to download the HTTP server on the machine where notifications will get displayed and drop it somewhere on your PATH.

For example, if $HOME/bin is on your PATH:

curl -L https://github.com/fgrehm/notify-send-http/releases/download/v0.2.0/server-linux_amd64 > $HOME/bin/notify-send-server
chmod +x $HOME/bin/notify-send-server

Then fire up the server with:

PORT=12345 notify-send-server

If you are on an Ubuntu machine, you can set it up to start automatically after logging in to the machine:

cat <<-STR > ~/.config/autostart/notify-send-server.desktop
[Desktop Entry]
Type=Application
Exec=env PORT=12345 ${HOME}/bin/notify-send-server
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=NotifySend server
Name=NotifySend server
Comment[en_US]=
Comment=
STR

Client setup

From another machine / VM / Linux Container you'll have to first download the client somewhere on the PATH:

curl -L https://github.com/fgrehm/notify-send-http/releases/download/v0.2.0/client-linux_amd64 | sudo tee /usr/local/bin/notify-send &>/dev/null
sudo chmod +x /usr/local/bin/notify-send

Then point the CLI to the notification server:

SERVER_IP=$(ip route|awk '/default/ { print $3 }')
export NOTIFY_SEND_URL="http://${SERVER_IP}:12345"

And trigger notifications with:

notify-send "A summary" "Some message"

Integration

Download the client to a folder under $HOME/devstep/bin:

DEVSTEP_DIR="$HOME/devstep/bin"
mkdir -p $DEVSTEP_DIR
curl -sL https://github.com/fgrehm/notify-send-http/releases/download/v0.2.0/client-linux_amd64 > $DEVSTEP_DIR/notify-send
chmod +x $DEVSTEP_DIR/notify-send

Add to your $HOME/devstep.yml:

volumes:
  # Share executable with container
  - '{{env "HOME"}}/devstep/bin/notify-send:/.devstep/bin/notify-send'
environment:
  # Set to a different IP if your docker0 bridge is set to something else
  NOTIFY_SEND_URL: "http://172.17.42.1:12345"
# Grab Docker bridge IP
DOCKER_BRIDGE_IP=$(/sbin/ifconfig docker0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')

# Download binary
curl -sL https://github.com/fgrehm/notify-send-http/releases/download/v0.2.0/client-linux_amd64 > /tmp/notify-send && chmod +x /tmp/notify-send

# Start container ready to send notifications
docker run -ti --rm \
           -e NOTIFY_SEND_URL="http://${DOCKER_BRIDGE_IP}:12345" \
           -v /tmp/notify-send:/usr/bin/notify-send \
           -v `pwd`/success.png:/tmp/success.png \
           ubuntu:14.04 \
           /usr/bin/notify-send "Hello docker" "It Works!" -i /tmp/success.png
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
Vagrant.configure("2") do |config|
  config.vm.box = "<YOUR BOX>"
  config.vm.provision :shell,
                      path: 'https://github.com/fgrehm/notify-send-http/raw/master/vagrant-installer.sh',
                      args: ['12345']
end

TODO

  • Handle other notify-send parameters
  • Implement support for other notifiers / platforms

notify-send-http's People

Contributors

fgrehm avatar kevinsperrine avatar

Stargazers

Chauncey Garrett avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.