Tuesday, March 10, 2015

Windows Phone as "notification screen"

I recently bought a low-end windows phone from a coworker for $10, not really having any particular plan for it, but thinking I might be able to do something cool with it. Well, for the past couple weeks, it's just been sitting on my desk collecting dust.

Until a couple days ago, I decided I wanted to try to use it as a sort of 3rd screen at work, where notifications could be shown. I've got a few things (pidgin chat windows, emails, linux desktop notifications) that I want to be aware of, but I sometimes miss. My icon for pidgin changes color when I have a new message, but sometimes it's a hassle to pop it up to the top if it's not important (and it's hard to know if it's important without seeing it!) Thunderbird shows a desktop notification on new email arrival, but that only lasts for a couple seconds; I often miss it, and then I have to go click on it to see if there's mail.  1st world problems, yes. And I'm not sure I really need to fix them. But really, I have a solution (this phone) in search of a problem, so I decided to play with it!

Catching thunderbird messages was the easy part -- there's a great thunderbird extension (Unread Count) that automatically generates a text file that contains information about how many unread messages you have in each mailbox.

For desktop notifications, I did some reading, and it looks like I needed to hook into DBus, linux's inter-process communication channel. Reading through tutorials about how to hook into it, it looked like somewhat of a hassle. So I took the easy route, and used the dbus-monitor command, which generates a text stream of all the information flowing through dbus, and piped it through a python script that just looked for libnotify notifications, and wrote the details I was interested in to a separate file.

While playing with dbus, I noticed that all pidgin messages traveled through it as well, which made it really easy to catch the sender name and text content of the latest message, and write it to a file as well.

Then I have a simple php web script that pulls the info from all these files, and builds a not-too-ugly notification page out of it.

I originally planned to just point the phone's browser to it, and have a meta-refresh on the page, but the windows phone browser kept the status/url bar open the whole time, which was ugly and wasted space. So I ended up writing a windows phone app that was merely a wrapper over a webView that reloaded the page repeatedly. Moving the refresh logic to the phone app also allows for it to keep refreshing even if the web server temporarily dies, which is handy.

So here's the finished product. Who knows if I'll actually ever look at it, or find it remotely useful. That's not really the point here, is it?





Side note: currently I have a private git repo on bitbucket where I keep all my misc rinky-dink projects. Maybe I should just make it public instead, so things like this are available to anyone that wants to look at them. I'll have to think about that. (It would mean I'd be more afraid of my hackish little quick code being judged as terrible, so I'd be nervous about throwing stuff on there willy-nilly)

No comments:

NES Anguna

Well, I had a little bit of time still, while Frankengraphics is finishing up her game Project Blue, to have a little downtime on Halcyon, s...