Giter VIP home page Giter VIP logo

klaxon's Introduction

klaxon

Send Mac OS (or notifiers) notifications from the terminal or Python programs.

This is especially useful for when you want a push notification for some long-running background task.

Similar to the terminal-notifier ruby gem, but posix-compliant and able to send notifications via the notifiers library.

hello-klaxon

Installation

For command-line use, the recommended method of installation is through pipx.

pipx install klaxon

Naturally, klaxon can also be pip-installed.

pip install klaxon

Usage

terminal

# blank notification
klaxon
# with custom message
klaxon --message "this is the message body"
# pipe message from other program
echo "this is the message body" | klaxon --

python

from klaxon import klaxon, klaxonify

# send a notification

klaxon(
    title='hello, klaxon',
    subtitle='hola',
    message='it me'
)

# we can decorate our functions to have
# them send notifications at termination

@klaxonify
def hello(name='world'):
    return f'hello, {name}'


@klaxonify(title='oh hai', output_as_message=True)
def foo():
    return "This will be the message body."

Non-MacOS Notifications

i.e. mobile | email | slack

You'll need to install klaxon with the notifiers extra.

pipx install klaxon[notifiers]

You will need a ~/.config/klaxon/config.toml or pyproject.toml file with the tool.klaxon namespace configured at the top level. Values from the latter will override values in the former.

enable-notifiers will need to be set to true and you will need a [[notifiers]] key.

The latter will determine the parameters passed to the notifiers.notify method.

For example:

~/.config/klaxon/config.toml

enable-notifiers = true

[[notifiers]]
name = 'slack'
# see https://api.slack.com/incoming-webhooks#getting-started
webhook_url = {{your webhook url}}

[[notifiers]]
name = 'pushover'
user = {{your user token}}
token = {{your application token}}

Voila! Now messages sent from klaxon will be pushed to slack and pushover.

Development

git clone [email protected]:knowsuchagency/klaxon.git

cd klaxon

# create a virtualenv and activate it

python3 -m venv .venv
source .venv/bin/activate

# install poetry and use it to install project dependencies

pip install -U pip
pip install poetry
poetry install

# this will install `invoke` which will let you use the tasks defined in `tasks.py`

# install pre-commit hooks

inv install-hooks

# from now on, as you make changes to the project, the pre-commit hooks and
# github workflows will help make sure code is formatted properly and tests
# are invoked as you commit, push, and submit pull requests

klaxon's People

Contributors

knowsuchagency avatar

Watchers

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