Coder Social home page Coder Social logo

alerter's Introduction

Alerter

alerter is a command-line tool to send Mac OS X User Alerts (Notifications), which are available in Mac OS X 10.8 and higher. the program ends when the alerter is activated or closed, writing a the activated value to output (stdout), or a json object to describe the alert event.

Alerts are OS X notifications that stay on screen unless dismissed.

2 kinds of alert notification can be triggered : "Reply Alert" or "Actions Alert"

Reply alert

Open a notification in the top-right corner of your screen and display a "Reply" button, which opens a text input.

Actions alert

Open a notification in the top-right corner of your screen and display one or more actions to click on.

Features

  • set alert's icon, title, subtitle, image.
  • capture text typed by user in the reply type alert.
  • timeout : automatically close the alert notification after a delay.
  • change the close button label.
  • change the actions dropdown label.
  • play a sound while delivering the alert notification.
  • value or json output on alert's event (closed, timeout, replied, activated...)
  • close the alert notification on SIGINT, SIGTERM.

Download

Prebuilt binaries are available from the releases section.

Usage

$ ./alerter -[message|group|list] [VALUE|ID|ID] [options]

Some examples are:

Display piped data with a sound

$ echo 'Piped Message Data!' | alerter -sound default

Display piped data with a sound

Multiple actions and custom dropdown list

./alerter -message "Deploy now on UAT ?" -actions Now,"Later today","Tomorrow" -dropdownLabel "When ?"

Multiple actions and custom dropdown list

Yes or No ?

./alerter -title ProjectX -subtitle "new tag detected" -message "Deploy now on UAT ?" -closeLabel No -actions Yes -appIcon http://vjeantet.fr/images/logo.png

Yes or No

What is the name of this release ?

./alerter -reply -message "What is the name of this release ?" -title "Deploy in progress..."

What is the name of this release

Options

At a minimum, you have to specify either the -message , the -remove or the -list option.


-message VALUE [required]

The message body of the notification.

Note that if this option is omitted and data is piped to the application, that data will be used instead.


-reply

The notification will be displayed as a reply type alert.


-actions VALUE1,VALUE2,"VALUE 3"

The notification actions available. When you provide more than one value, a dropdown will be displayed. You can customize this dropdown label with the next option. Does not work when -reply is used.


-dropdownLabel VALUE

The notification actions dropdown title (only when multiples -actions values are provided). Does not work when -reply is used.


-closeLabel VALUE

The notification "Close" button label.


-title VALUE

The title of the notification. This defaults to ‘Terminal’.


-subtitle VALUE

The subtitle of the notification.


-timeout NUMBER

Auto close the alert notification after NUMBER seconds.


-sound NAME

The name of a sound to play when the notification appears. The names are listed in Sound Preferences. Use 'default' for the default notification sound.


-json

Alerter will output a json struct to describe what happened to the alert.


-group ID

Specifies the ‘group’ a notification belongs to. For any ‘group’ only one notification will ever be shown, replacing previously posted notifications.

A notification can be explicitly removed with the -remove option, described below.

Examples are:

  • The sender’s name to scope the notifications by tool.
  • The sender’s process ID to scope the notifications by a unique process.
  • The current working directory to scope notifications by project.

-remove ID [required]

Removes a notification that was previously sent with the specified ‘group’ ID, if one exists. If used with the special group "ALL", all message are removed.


-list ID [required]

Lists details about the specified ‘group’ ID. If used with the special group "ALL", details about all currently active messages are displayed.

The output of this command is a json array of alert notifications.


-sender ID

Specifying this will make it appear as if the notification was send by that application instead, including using its icon.

Using this option fakes the sender application, so that the notification system will launch that application when the notification is clicked. Because of this it is important to note that you cannot combine this with options like -execute, -open, and -activate which depend on the sender of the notification to be ‘alerter’ to perform its work.

For information on the ID see the -activate option.


-appIcon PATH [10.9+ only]

Specifies The PATH or URL of an image to display instead of the application icon.

WARNING: This option is subject to change since it relies on a private method.


-contentImage PATH [10.9+ only]

Specifies The PATH or URL of an image to display attached inside the notification.

WARNING: This option is subject to change since it relies on a private method.


Example usage with shell script

ANSWER="$(./alerter -message 'Start now ?' -closeLabel No -actions YES,MAYBE,'one more action' -timeout 10)"
case $ANSWER in
    "@TIMEOUT") echo "Timeout man, sorry" ;;
    "@CLOSED") echo "You clicked on the default alert' close button" ;;
    "@CONTENTCLICKED") echo "You clicked the alert's content !" ;;
    "@ACTIONCLICKED") echo "You clicked the alert default action button" ;;
    "MAYBE") echo "Action MAYBE" ;;
    "NO") echo "Action NO" ;;
    "YES") echo "Action YES" ;;
    **) echo "? --> $ANSWER" ;;
esac

Source code

This project is based on a fork of terminal notifier by @JulienXX.

License

All the works are available under the MIT license.

Copyright (C) 2012-2015 Valère Jeantet [email protected], Eloy Durán [email protected], Julien Blanchard [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

alerter's People

Contributors

vjeantet avatar homebysix avatar j450h1 avatar

Watchers

James Cloos avatar  avatar  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.