Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Mac OS notifications from Python

License

NotificationsYou must be signed in to change notification settings

knowsuchagency/klaxon

Repository files navigation

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

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

Similar to theterminal-notifier ruby gem,but posix-compliant and able to send notifications viathenotifiers library.

hello-klaxon

Installation

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

pipx install klaxon

Naturally, klaxon can also be pip-installed.

pip install klaxon

Usage

terminal

# blank notificationklaxon# with custom messageklaxon --message"this is the message body"# pipe message from other programecho"this is the message body"| klaxon --

python

fromklaxonimportklaxon,klaxonify# send a notificationklaxon(title='hello, klaxon',subtitle='hola',message='it me')# we can decorate our functions to have# them send notifications at termination@klaxonifydefhello(name='world'):returnf'hello,{name}'@klaxonify(title='oh hai',output_as_message=True)deffoo():return"This will be the message body."

Non-MacOS Notifications

i.e. mobile | email | slack

You'll need to install klaxon with thenotifiers extra.

pipx install klaxon[notifiers]

You will need a~/.config/klaxon/config.toml orpyproject.toml file with thetool.klaxon namespace configured at the top level. Values from the latter willoverride values in the former.

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

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

For example:

~/.config/klaxon/config.toml

enable-notifiers =true[[notifiers]]name ='slack'# see https://api.slack.com/incoming-webhooks#getting-startedwebhook_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 git@github.com:knowsuchagency/klaxon.gitcd klaxon# create a virtualenv and activate itpython3 -m venv .venvsource .venv/bin/activate# install poetry and use it to install project dependenciespip install -U pippip install poetrypoetry install# this will install `invoke` which will let you use the tasks defined in `tasks.py`# install pre-commit hooksinv 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

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp