noti

package module
v2.7.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2017 License: MIT Imports: 2 Imported by: 0

README

noti

Gitter Open Hub CircleCI

Trigger notifications when a process completes.

Never sit and wait for some long-running process to finish! noti will alert you when it's done—on your computer or smartphone—so you can stop worrying about constantly checking the terminal.

OS X Banner Notification

Types

These are the different notification types noti supports and on which OSes.

type       | macOS | Linux | FreeBSD | Windows
------------------------------------------------
Banner     |   ✔   |   ✔   |    ✔    |    ✔
Speech     |   ✔   |   ✔   |    ✔    |
BearyChat  |   ✔   |   ✔   |    ✔    |    ✔
HipChat    |   ✔   |   ✔   |    ✔    |    ✔
Pushbullet |   ✔   |   ✔   |    ✔    |    ✔
Pushover   |   ✔   |   ✔   |    ✔    |    ✔
Pushsafer  |   ✔   |   ✔   |    ✔    |    ✔
Simplepush |   ✔   |   ✔   |    ✔    |    ✔
Slack      |   ✔   |   ✔   |    ✔    |    ✔

Check out the docs for more information on how to configure mobile notifications. If you're curious, you can also browse the screenshots directory.

Installation

# Anywhere, latest.
go get -u github.com/variadico/noti/cmd/noti

# Alternatively on macOS.
brew install noti

If you only want a binary, get it from the releases page. You can download it with your browser or just use curl!

# For macOS.
curl -L https://github.com/variadico/noti/releases/download/v2.7.0/noti2.7.0.darwin-amd64.tar.gz | tar -xz

# For Linux.
curl -L https://github.com/variadico/noti/releases/download/v2.7.0/noti2.7.0.linux-amd64.tar.gz | tar -xz

# For Windows.
curl -L https://github.com/variadico/noti/releases/download/v2.7.0/noti2.7.0.windows-amd64.tar.gz | tar -xz

Usage

Put noti at the beginning or end of your regular commands.

noti [options] [utility [args...]]
Options
-t <string>, --title <string>
    Notification title. Default is utility name.
-m <string>, --message <string>
    Notification message. Default is "Done!"
-w <pid>, --pwatch <pid>
    Trigger notification after PID disappears.

-b, --banner
    Trigger a banner notification. Default is true. To disable this
    notification set this flag to false.
-s, --speech
    Trigger a speech notification. Optionally, customize the voice with
    NOTI_VOICE.

-i, --hipchat
    Trigger a HipChat notification. Requires NOTI_HIPCHAT_TOK and
    NOTI_HIPCHAT_DEST to be set.
-p, --pushbullet
    Trigger a Pushbullet notification. Requires NOTI_PUSHBULLET_TOK to
    be set.
-o, --pushover
    Trigger a Pushover notification. Requires NOTI_PUSHOVER_TOK and
    NOTI_PUSHOVER_DEST to be set.
-u, --pushsafer
    Trigger a Pushsafer notification. Requires NOTI_PUSHSAFER_KEY
    to be set.
-l, --simplepush
    Trigger a Simplepush notification. Requires NOTI_SIMPLEPUSH_KEY
    to be set. Optionally, customize ringtone and vibration with
    NOTI_SIMPLEPUSH_EVENT.
-k, --slack
    Trigger a Slack notification. Requires NOTI_SLACK_TOK and
    NOTI_SLACK_DEST to be set.
-c, --bearychat
    Trigger a BearyChat notification. Requries NOTI_BC_INCOMING_URI
    to be set.

-v, --version
    Print noti version and exit.
-h, --help
    Display help information and exit.
Environment

You can further configure noti by setting the following environment variables. Some are required for specific notifications. For example, NOTI_PUSHBULLET_TOK must be set to use Pushbullet notifications. Others can be used to optionally change the default behavior, like setting NOTI_VOICE to change the voice used in speech notifications.

NOTI_DEFAULT
    Notification types noti should trigger in a space-delimited list. For
    example, set NOTI_DEFAULT="banner speech pushbullet slack" to enable
    all available notifications to fire sequentially.
NOTI_BC_INCOMING_URI
    BearyChat incoming URI.
NOTI_HIPCHAT_TOK
    HipChat access token. Log into your HipChat account and retrieve a token
    from the Room Notification Tokens page.
NOTI_HIPCHAT_DEST
    HipChat message destination. Can be either a Room name or ID.
NOTI_PUSHBULLET_TOK
    Pushbullet access token. Log into your Pushbullet account and retrieve a
    token from the Account Settings page.
NOTI_PUSHOVER_TOK
    Pushover access token. Log into your Pushover account and create a
    token from the Create New Application/Plugin page.
NOTI_PUSHOVER_DEST
    Pushover message destination. Should be your User Key.
NOTI_PUSHSAFER_KEY
    Pushsafer private or alias key. Log into your Pushsafer account and note
    your private or alias key.
NOTI_SIMPLEPUSH_KEY
    Simplepush key. Install the Simplepush app and retrieve your key there.
NOTI_SLACK_TOK
    Slack access token. Log into your Slack account and retrieve a token
    from the Slack Web API page.
NOTI_SLACK_DEST
    Slack message destination. Can be either a #channel or a @username.
NOTI_VOICE
    Name of voice used for speech notifications.
OS X only
NOTI_SOUND
    Banner success sound. Default is Ping. Possible options are Basso, Blow,
    Bottle, Frog, Funk, Glass, Hero, Morse, Ping, Pop, Purr, Sosumi,
    Submarine, Tink. See /System/Library/Sounds for available sounds.
NOTI_SOUND_FAIL
    Banner failure sound. Default is Basso. Possible options are Basso,
    Blow, Bottle, Frog, Funk, Glass, Hero, Morse, Ping, Pop, Purr, Sosumi,
    Submarine, Tink. See /System/Library/Sounds for available sounds.

Examples

Display a notification when tar finishes compressing files.

noti tar -cjf music.tar.bz2 Music/

You can also add noti after a command, in case you forgot at the beginning.

clang foo.c -Wall -lm -L/usr/X11R6/lib -lX11 -o bizz; noti

If you already started a command, but forgot to use noti, then you can do this to get notified when that process' PID disappears.

noti --pwatch $(pgrep docker-machine)

An easier alternative is to press ctrl+z after you started a process. This will put it in the background. Then, you can bring it back and append noti.

$ dd if=/dev/zero of=foo bs=1M count=2000
^Z
zsh: suspended  dd if=/dev/zero of=foo bs=1M count=2000
$ fg; noti
[1]  + continued  dd if=/dev/zero of=foo bs=1M count=2000
2000+0 records in
2000+0 records out
2097152000 bytes (2.1 GB, 2.0 GiB) copied, 12 s, 175 MB/s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Site string
	Msg  string
}

APIError is an API error that's returned if a notification API request failed.

func (APIError) Error

func (e APIError) Error() string

type ConfigErrror

type ConfigErrror struct {
	Env    string
	Reason string
}

ConfigErrror is a configuration error for noti packages.

func (ConfigErrror) Error

func (e ConfigErrror) Error() string

type EnvGetter

type EnvGetter interface {
	Get(v string) string
}

EnvGetter is something that reads an environment variable. In code, this could read an environment variable from the OS. In tests, this can read variables from a mock.

type MockEnv

type MockEnv map[string]string

MockEnv is an EnvGetter that mocks the OS environment.

func (MockEnv) Get

func (e MockEnv) Get(v string) string

Get looks up a variable from the MockEnv map.

type OSEnv

type OSEnv struct{}

OSEnv is an EnvGetter that reads real OS environment variables.

func (OSEnv) Get

func (e OSEnv) Get(v string) string

Get reads an environment variable from the OS.

type Params

type Params struct {
	Title   string
	Message string

	Failure bool
	API     string
	Config  EnvGetter
}

Params are parameters that are passed to a notification's Notify function.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL