ntfy icon indicating copy to clipboard operation
ntfy copied to clipboard

different behavior on cmd and use as library in python

Open bjoernh opened this issue 7 years ago • 1 comments

There is a difference depending on running nfty inside a Python shell (call notify.notification() ) and run ntfy from commandline. I think the reason is a different default config file location. In my case, I have created a config file under ~/.ntfy.yml and ntfy use that config when i run it from console (it sends notification via pushover). But when i try to send a notification from a interactive Python shell, only the Linux Desktop notification works. I can fix that behavior by creating a sym link ~/.config/ntfy.yml point to ~/.ntfy.yml

bjoernh avatar Dec 19 '17 08:12 bjoernh

Yeah, that's doesn't surprise me. Usage as a library wasn't my primary usecase, but seeing as people are interested I should probably shore that up or document the differences.

The main difference here that you've stumbled upon is that the CLI does more thorough config finding & loading, where as ntfy.notify() only loads the default config location. You could also fix your problem with:

from ntfy import notify
from ntfy.config import load_config
ntfy.notify('msg', 'title', config=load_config('/home/bjoernh/.ntfy'))

dschep avatar Dec 19 '17 13:12 dschep