Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Improve app notifications/alerts #39

Open
1 of 3 tasks
mre opened this issue Feb 4, 2020 · 2 comments
Open
1 of 3 tasks

Improve app notifications/alerts #39

mre opened this issue Feb 4, 2020 · 2 comments

Comments

@mre
Copy link
Owner

mre commented Feb 4, 2020

Feature Request Type

  • Core functionality
  • Alteration (enhancement/optimization) of existing feature(s)
  • New behavior

Description

At the moment, we use a custom function to show a notification (e.g. when a recording was started or stopped). Here is the code:
https://github.com/mre/timelapse/blob/master/timelapse/notify.py
This has some limitations:

  • When clicking on the notification, the Apple Script Editor opens, which is not very helpful. It would be much better if we could configure the action when clicking on the notification. E.g. we could open the path to the final recording once it is finished.
  • We cannot have a custom icon next to the notification. 🎨

It would be nice if we could use a library for showing proper notification instead.
Not sure if there already exists a native Python library to do that on macOS.
Does anybody know of such a library? If not, we could build one based on the discussion here.

@cmangla
Copy link
Collaborator

cmangla commented Feb 4, 2020

I think we can start by creating a UI class, so that all notifications and other outputs go through it, and then it can handle them appropriately, and in the future use a different notify implementation.

For example, we might have methods called ui.error, ui.info, ui.debug. Then we could replace, for example,

notify("Timelapse", f"Creating timelapse. This might take a while")
print(' '.join(command))

with

ui.info("Timelapse", f"Creating timelapse. This might take a while")
ui.debug(' '.join(command))

and then, for now, the ui.info implementation can call notify while the ui.debug can call print. In the future, we'll be able to update the implementations with better notifications and logging, etc.

@mre
Copy link
Owner Author

mre commented Feb 4, 2020

I like your idea.
If this was an external library, I'd expect a builder pattern like this:

notification = Notify.create()
      .title("Title Text")
      .text("Hello World!")
      .icon('example.png');

notification.show()

This is similar to dorkbox/Notify.
The advantage would be, that we could customize our notification once and use the same style throughout the app.
notify() would then become a wrapper around the builder, that we could maintain inside timelapse. The rest would probably be in a separate library to improve re-usability and avoid close coupling between the components - but this could be done in a next step. 😉

So if you want to work on this and refactor the code a bit, please be welcome to do so.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants