defmodule Ding do @moduledoc """ `Ding` handles desktop notifications on your local PC. Plays nice alongside: * Terminal Notifier * NotifySend * TmuxNotifier * TerminalTitle Only OS X and Linux are enabled so far; seeking help on Windows notifications! Source code originally appeared in the `ex_unit_notifier` package; this is a copy of only the general-purpose notification logic. Some modules and options are renamed. """ @handlers [ Ding.TerminalNotifier, Ding.NotifySend, Ding.TmuxNotifier, Ding.TerminalTitle ] @doc """ ## Send a message iex> Ding.send("Hello!", "Here is your message.") ## Options and appearance Each handler only recognizes a portion of these options; some options are recognized by more than one handler. iex> Ding.send("Hello!", "Here is your message.", %{ clear_history: true, color: color(status(counter)), icon_png: icon_png(status(counter)), icon_icns: icon_icns(status(counter)), }) """ def send(head, message), do: send(head, message, %{ clear_history: false }) def send(head, message, opts), do: handlers() |> Enum.map(& apply(&1, :send, [head, message, opts])) defp handlers, do: Application.get_env(:message, :handlers, choose_handlers()) defp choose_handlers, do: @handlers |> Enum.filter(fn handler -> handler.enabled? end) end