Skip to content

Commit

Permalink
📝 Documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorricks committed Jul 26, 2022
1 parent 5dc6ff9 commit 43cca6e
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 34 deletions.
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<a href="https://github.com/Jorricks/macos-notifications"><img src="https://github.com/Jorricks/macos-notifications/raw/main/docs/macos-notifications.png" alt="macos-notifications" width="600px"></a>
<a href="https://github.com/Jorricks/macos-notifications"><img src="https://github.com/Jorricks/macos-notifications/raw/main/docs/img/macos-notifications.png" alt="macos-notifications" width="600px"></a>
</p>
<p align="center">
<a href="https://www.apple.com/mac/" target="_blank">
Expand All @@ -23,6 +23,14 @@

**mac-notification** is a Python library to make it as easy as possible to create interactable notifications.


## Installation

To use macos-notifications, first install it using pip:

pip install macos-notifications


## Features
- 🚀 Easy python interface. It's as simple as '`client.create_notification(title="Meeting starts now!", subtitle="Team Standup")`'
- 💥 Ability to add action buttons with callbacks!
Expand All @@ -31,27 +39,25 @@
- ⏱️ Automatically time out the notification listener.
- 📦 Just `pyobjc` as a dependency.

## Installation

To use macos-notifications, first install it using pip:

pip install macos-notifications

## Example
A simple example. Please look [in the docs](https://jorricks.github.io/macos-notifications/) for more examples.

```python
from pathlib import Path
from mac_notifications import client

client.create_notification(
title="Meeting starts now!",
subtitle="Team Standup",
icon=Path(__file__).parent / "zoom.png",
icon="/Users/jorrick/zoom.png",
action_button_str="Join zoom meeting",
action_button_callback=partial(join_zoom_meeting, conf_number=zoom_conf_number)
)
```
A simple example. Please look [in the docs](https://jorricks.github.io/macos-notifications/) for more examples like this:

<p align="center">
<a href="https://jorricks.github.io/macos-notifications/examples/">
<img src="https://github.com/Jorricks/macos-notifications/raw/main/docs/img/example-run.gif" alt="macos-notifications" width="600px">
</a>
</p>

## Why did you create this library?
I wanted a library that did not depend on any non-python tools (so you had to go around and install that). Instead, I wanted a library where you install the pip packages, and you are done.
Expand Down
7 changes: 6 additions & 1 deletion docs/examples.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Examples
On this page we will list several examples.

On this page we will list several examples. Let's start with a demonstration of the last example of this page.

<p align="center">
<a href="#Multiple notifications"><img src="../img/example-run.gif" alt="macos-notifications" width="800px"></a>
</p>

## Simple notification
```python
Expand Down
11 changes: 11 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@
I wanted a library that did not depend on any non-python tools (so you had to go around and install that). Instead, I wanted a library where you install the pip packages and you are done.
Later I realised how hard it was to integrate correctly with PyOBJC. Also, I had a hard time finding any examples on how to easily integrate this in a non-blocking fashion with my tool.
Hence, I figured I should set it up to be as user-friendly as possible and share it with the world ;)!


???+ "My notifications don't show up with the text I mentioned"

Unfortunately, you first need to allow Python to create notifications. Instructions on this can be found [here](https://www.jetbrains.com/idea/guide/tips/enable-soft-wrap/#:~:text=You%20can%20enable%20soft%20wrap,more%20file%20types%20by%20default.). Check below for an example


Your settings should look similar to this:

![](img/enable-notifications.png)

Binary file added docs/img/enable-notifications.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/example-run.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
26 changes: 16 additions & 10 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mac Notifications
<p align="center">
<a href="https://jorricks.github.io/macos-notifications"><img src="macos-notifications.png" alt="macos-notifications" width="800px"></a>
<a href="https://jorricks.github.io/macos-notifications"><img src="img/macos-notifications.png" alt="macos-notifications" width="800px"></a>
</p>
<p align="center">
<a href="https://www.apple.com/mac/" target="_blank">
Expand All @@ -24,14 +24,6 @@

**mac-notification** is a Python library to make it as easy as possible to create interactable notifications.

## Features
- 🚀 Easy python interface. It's as simple as '`client.create_notification(title="Meeting starts now!", subtitle="Team Standup")`'
- 💥 Ability to add action buttons with callbacks!
- 📝 Ability to reply to notifications!
- ⌚ Delayed notifications.
- ⏱️ Automatically time out the notification listener.
- 📦 Just `pyobjc` as a dependency.


## Installation
To use macos-notifications, first install it using pip:
Expand All @@ -43,8 +35,16 @@ $ pip install macos-notifications
Installed
```

## Features
- 🚀 Easy python interface. It's as simple as '`client.create_notification(title="Meeting starts now!", subtitle="Team Standup")`'
- 💥 Ability to add action buttons with callbacks!
- 📝 Ability to reply to notifications!
- ⌚ Delayed notifications.
- ⏱️ Automatically time out the notification listener.
- 📦 Just `pyobjc` as a dependency.


## Example
A simple example. Please look [in the docs](https://jorricks.github.io/macos-notifications/) for more examples.

```python
from mac_notifications import client
Expand All @@ -57,7 +57,13 @@ client.create_notification(
action_button_callback=partial(join_zoom_meeting, conf_number=zoom_conf_number)
)
```
A simple example. Please look [in the docs](https://jorricks.github.io/macos-notifications/) for more examples like this:

<p align="center">
<a href="https://jorricks.github.io/macos-notifications/examples/">
<img src="img/example-run.gif" alt="macos-notifications" width="600px">
</a>
</p>

## Limitations
- You need to keep your application running while waiting for the callback to happen.
Expand Down
Binary file added examples/img/chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
25 changes: 15 additions & 10 deletions examples/multiple_notifications_with_callbacks.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import time
from pathlib import Path

from mac_notifications import client


if __name__ == "__main__":
print(f"Active number of notifications: {client.get_notification_manager().get_active_running_notifications()}")
print("Sending meeting notification.")
client.create_notification(
title="Action notification",
subtitle="Subtitle of the notification",
action_button_str="Perform an action",
action_callback=lambda: print("Pressed action button"),
title="Meeting starts now.",
subtitle="Standup Data Team",
icon=Path(__file__).parent / "img" / "zoom.png",
action_button_str="Join zoom meeting",
action_callback=lambda: print("Joining zoom meeting now."),
)

time.sleep(1)
time.sleep(5)
print("Sending notification.")
client.create_notification(
title="Reply notification",
subtitle="Subtitle of the notification",
title="Message from Henk",
subtitle="Hey Dude, are we still meeting?",
icon=Path(__file__).parent / "img" / "chat.png",
reply_button_str="Reply to this notification",
reply_callback=lambda reply: print(f"Replied {reply=}"),
reply_callback=lambda reply: print(f"You replied: {reply}"),
)

print("Application will remain active until both notifications have been answered.")
while client.get_notification_manager().get_active_running_notifications() > 0:
time.sleep(1)
print(f"Active number of notifications: {client.get_notification_manager().get_active_running_notifications()}")
client.stop_listening_for_callbacks()
2 changes: 1 addition & 1 deletion examples/notification_with_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def join_a_meeting(conf_number: int | str) -> None:
client.create_notification(
title="Meeting starts now!",
subtitle="Standup. Join please.",
icon=Path(__file__).parent / "zoom.png",
icon=Path(__file__).parent / "img" / "zoom.png",
action_button_str="Join zoom meeting",
action_callback=partial(join_a_meeting, conf_number="12345678"),
)
Expand Down
2 changes: 1 addition & 1 deletion examples/notification_with_reply.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
title="Cool notification",
subtitle="Subtitle of the notification",
text="Hello, I contain info",
icon=Path(__file__).parent / "zoom.png",
icon=Path(__file__).parent / "img" / "chat.png",
delay=timedelta(milliseconds=500),
reply_button_str="Reply to this notification",
reply_callback=lambda reply: print(f"Replied {reply=}"),
Expand Down

0 comments on commit 43cca6e

Please sign in to comment.