WinNotify
Manage Windows notification icons with Elixir
Installation
If available in Hex, the package can be installed as:
Add win_notify to your list of dependencies in
mix.exs:def deps do
[{:win_notify, "~> 0.0.1"}]end
Ensure win_notify is started before your application:
def application do
[applications: [:win_notify]]end
Usage
Define a module and invoke the
notify_icon/2macro. Optionally you can usedefalert/3to create shortcuts for an alert you expect to use a lot:defmodule MyApp.MyIcon do import WinNotify @icon Path.expand("../path/to/icon.ico", __DIR__) notify_icon "My Icon", @icon do defalert :welcome, :info, "Welcome ~s!" defalert :unexpected, :warning, "Expected value to be ~f, but got ~f" defalert :not_found, :error, "~s not found" end endAdd
MyIconto your applications supervision tree:def start(_type, _args) do import Supervisor.Spec, warn: false children = [ worker(MyApp.MyIcon, []]) ] opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(children, opts) endCreate balloop tip alerts:
iex> MyApp.MyIcon.info("Info", "This is an info alert.") iex> MyApp.MyIcon.warning("Warning", "This is a warning alert.") iex> MyApp.MyIcon.error("Error", "This is an error alert.")