Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a very basic Windows notification service. #160

Closed
wants to merge 2 commits into from
Closed

Add a very basic Windows notification service. #160

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 8, 2015

Spawns an icon and "balloontip" in the notification area of the Windows desktop.

Includes an MQTT icon from mqtt.org that is used for the notification area icon.
Includes two example screenshots of the end result while using - an ideal, and an example of what
happens if there are too many messages (lots of icons you can not read the message from).

Spawns an icon and "balloontip" in the notification area.
There are limitations to this method (see the powershell script file), but
it meets my needs.

Python script that calls the powershell script using python's subprocess module.
There may be a better way to do this, but it works so far!

Includes an MQTT icon from mqtt.org that is used for the notification area
icon.
Includes two example screenshots of the end result while using - an ideal, and an example of what
happens if there are too many messages (lots of icons you can not read the message from).
@sumnerboy12
Copy link
Collaborator

Hi Mach, thanks for your contribution. Unfortunately I am unable to test as all my servers are Debian based.

However I do use the following for Windows/client notifications from mqttwarn (https://chrome.google.com/webstore/detail/mqtt2chrome/jfcmchhmjkddfoekjbkljcfpdjnpailh?hl=en) which I thought you might be interested in. It obviously requires you to run Chrome as your browser tho.

I personally would not want a notification service that required every notification to be clicked/mouse-overed, especially since I use mqttwarn extensively for home automation notifications!

@ghost
Copy link
Author

ghost commented Dec 8, 2015

Yes, it's certainly not an ideal general Windows notification service. I wrote it as a quick way to get limited functionality that doesn't seem to otherwise exist without many heavy dependencies. So it meets my needs - others, maybe not so much, depending on what they're looking for.
Thanks for the tip towards mqtt2chrome, it looks like it would likely meet my needs - unfortunately I'm a Firefox user.

I was (still am, really) looking for an equivalent to dunst (lightweight notification daemon) but on Windows. Writing this plugin looked like the quickest way to get the functionality I wanted most. It looks like Windows 8 and onwards have a very cloudy-mobile notifications capability, but I'm still running Windows 7.

ETA: Wow. Trying to get mqttwarn running on login, and have it use this plugin? As far as I can tell, impossible. Icons/balloontips don't show up unless there is a visible terminal window, period. Will revisit later, but meanwhile I'm closing this pull request. Sorry!

@ghost ghost closed this Dec 8, 2015
@jpmens
Copy link
Collaborator

jpmens commented Dec 9, 2015

@mach327 You've gone to a lot of work with this, which I appreciate, and the idea is pretty good actually even though the implementation suffers from a few issues (I love the screenshot you made of the multiple notification icons ... 😄 )

If you think you can improve on that issue, I'll take this.

@matbor
Copy link
Contributor

matbor commented Dec 9, 2015

@mach327 thx for the inspiration, just knocked up something in python that will display mqtt messages in the windows.

https://github.com/matbor/mqtt2win10notify

balloon

@jpmens
Copy link
Collaborator

jpmens commented Dec 10, 2015

Does that suffer from the same limitations as the original code? i.e. needs hover to dismis the icon?

@ghost
Copy link
Author

ghost commented Dec 10, 2015

Currently, on Windows 7, yes. Actually, slightly worse, as the icons persist until the mqtt_notification process disappears. However, it seems to run properly in the background! 😄 I didn't realize there was a win32api module, but not only that - there's a "pythonnet" module! Basically the interface the powershell script was using, but in python, which looks like it should solve the can't-background issue.

I think I may have a solution for the hover-to-dismiss issue, too. NotifyIcon objects have a "Visible" property that seems to control whether the icon is in the taskbar. I'm testing now.

ETA: Holy cow, it works. I'm going to push to my fork and continue testing before I re-open the pull request, but it looks promising.
ETA2: Smaller problems that are definitely solvable now.

Does it make sense to only ever have one icon that displays multiple balloontips? One icon per topic? Or have each balloontip spawn a new icon and then clean them up after a timeout?

ETA3: I went with a single icon. Problem now is that if it's hovered over, it disappears and I haven't yet figured out how to detect this to spawn a new one, or prevent it from disappearing.

ETA4: Persistent icon won't work as a plugin for MQTTWarn, I guess. So my master branch now checks for and deletes old icons every time it makes a new notification. Best method that came to mind. This solves the previous limitations, and seems to work pretty well! Gif below shows it in use.

Imgur
(The disappearing appearance is because the gif is looping)

@ghost ghost reopened this Dec 10, 2015
@ghost ghost closed this Jan 6, 2016
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants