Coder Social home page Coder Social logo

jrmann100 / notifwd Goto Github PK

View Code? Open in Web Editor NEW
18.0 4.0 7.0 48 KB

Notification forwarder for macOS. I made this for myself; use at your own risk.

License: MIT License

Python 100.00%
macos python3 notificationcenter prowl prowl-notifications prowlapp push-notifications prowl-api notification-forwarder

notifwd's Introduction

notifwd

Notification forwarder for macOS by Jordan Mann

Purpose: Why did you make this?

I'm glad you asked! Consider these four facts:

  1. I have a Pebble smartwatch that receives notifications from my phone.
  2. At the time of writing, I don't use my iPhone at all, besides to sync with my Pebble. It's old and slow, and I have no dependency on it.
  3. I receive all of my notifications (primarily from iMessages) on my Mac, then.
  4. The app that was used to send (and forward) macOS app notifications, Growl, was replaced by Apple's Notification Center.

I want my macOS notifications to show up on my watch. So I made notifwd, which forwards them to an app on my iPhone that the Pebble can pick up.

Prerequisites: What do I need to install notifwd?

You're very fortunate; you only need this script, a macOS computer, and an iPhone app called Prowl. Prowl is $2.99 at the time of writing this, but I promise it's worth it. Using their API (I cannot vouch for its security), you'll be able to send push notifications to your iPhone, even via email.

You don't need Prowl to use this script. If you want to log notifications or forward them somewhere else, just replace the sending component.

Oh, and this script was written in Python 3.7. You need Python 3. That's important.

Functionality: What does notifwd do?

Notifwd periodically checks macOS' Notification Center database for newly-recorded notifications. (Notifications are recorded after their popups disappear). It parses those notifications, additionally determining the application's name and how long ago the notification was sent, and sends them to the Prowl API.

Installation and Configuration: How do I set up notifwd?

I'm making these instructions non-developer-friendly. At some point I may bundle the script into an application and add a GUI.

Open the macOS Terminal app, located at /Applications/Utilities/ in the Finder.

cd ~/Desktop or wherever you want to download the script to.

git clone https://github.com/jrmann100/notifwd.git to download this repository and cd notifwd.

Run ./notifwd.py in the cloned repository.

Create your Prowl API key by going to Prowl's API Settings page.

Copy the key, and make it visible to the script by running export PROWL_API_KEY=[your key here]

Alternatively pass the key to the script by running ./notifwd.py --api-key [your key here]

Run the script with --silent to disable verbose outputs and that fancy splash screen.

Run the script with --frequency [seconds] to specify how often the script should check for new notifications.

Run the script with --version to get its version. (You can always git pull for the newest version.)

Contributing: I love notifwd, but I have a problem with it!

I'm so sorry, and I hope I can help. Please submit any issues or suggestions you have for this script on GitHub.

I acknowledge my code is not perfect, but it suits my needs. If you think your code is more pretty or efficient, please let me know.

notifwd's People

Contributors

jrmann100 avatar m-zheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

notifwd's Issues

Error - No module named requests

notifwd % ./notifwd.py
Traceback (most recent call last):
File "./notifwd.py", line 13, in
import requests
ModuleNotFoundError: No module named 'requests'

Python 3.7.7 installed. Ventura 13.4 OS

sqlite3.OperationalError: unable to open database file

This is on macOS 10.10; I don't have much experience with sqlite3, but I can help troubleshoot.

seedbox:notifwd gia$ ./notifwd.py

  _   _       _   _ _____             _
 | \ | | ___ | |_(_)  ___|_      ____| |
 |  \| |/ _ \| __| | |_  \ \ /\ / / _` |
 | |\  | (_) | |_| |  _|  \ V  V / (_| |
 |_| \_|\___/ \__|_|_|     \_/\_/ \__,_|

notifwd by Jordan Mann. Starting up... Traceback (most recent call last):
  File "/Users/gia/notifwd/./notifwd.py", line 200, in <module>
    Notification.main(argv)
  File "/Users/gia/notifwd/./notifwd.py", line 78, in main
    Notification.setup(argv)
  File "/Users/gia/notifwd/./notifwd.py", line 65, in setup
    Notification.connection = sqlite3.connect(db_path)
sqlite3.OperationalError: unable to open database file

TypeError: '>=' not supported between instances of 'float' and 'NoneType'

I'm running notifwd on a 2017 iMac with Catalina

MrMuscle:notifwd mnewman$ ./notifwd.py --api-key [my api-key]

  _   _       _   _ _____             _ 
 | \ | | ___ | |_(_)  ___|_      ____| |
 |  \| |/ _ \| __| | |_  \ \ /\ / / _` |
 | |\  | (_) | |_| |  _|  \ V  V / (_| |
 |_| \_|\___/ \__|_|_|     \_/\_/ \__,_|

notifwd by Jordan Mann. Starting up... done.
Starting scheduler. Update frequency is 60 seconds...Traceback (most recent call last):
  File "./notifwd.py", line 191, in <module>
    Notification.main(argv)
  File "./notifwd.py", line 96, in main
    raise(e)
  File "./notifwd.py", line 90, in main
    s.run()
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sched.py", line 151, in run
    action(*argument, **kwargs)
  File "./notifwd.py", line 82, in scheduled_update
    Notification.check()
  File "./notifwd.py", line 147, in check
    while sql_data[0] != Notification.last_id and sql_data[6] >= Notification.last_date:
TypeError: '>=' not supported between instances of 'float' and 'NoneType'

I don't know anything about Python, so all I can do is let you know about the error.

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.