Archive for the 'Software' Category

MythGrowl 0.4.1 Released

Sunday, March 18th, 2007

MythGrowl

For those of you watching the blog for a new release of MythGrowl, it’s finally here. I have moved the project to Sourceforge, got it a website, checked the code into SVN etc.

The new version has Sparkle support and some new features you will hopefully like. I could go on about how great I think the new version is but the easiest thing is probably just for you to head over to:

http://mythgrowl.sourceforge.net

Download it, and try it for yourself. The site also has details on obtaining the source code, reporting bugs etc.

Major credits goto Paul William for thinking up great new ideas for features to add to improve MythGrowl.

A number of people have emailed me and said that my so called universal binary doesn’t actually work on PPC Macs. I am looking into this and will hopefully release a version shortly that works on both PPC and Intel.

Have fun!

Enabling keyboard shortcuts with NSStatusItems

Thursday, January 4th, 2007

It all started when a friend who has been helping me out with testing and ideas for improving MythGrowl noticed that it was not possible to paste into either the ‘MythTV Server IP/Hostname’ or ‘MythTV Port’ box which are both NSTextFields. When you push APPLE+V the system would just make it’s standard ‘ding’ noise and whatever was on the clipboard wouldn’t appear, I imagined that changing some property of the NSTextFields would fix the problem right up.

As it happened I couldn’t have been more wrong and a seemingly simple problem took me an entire morning to solve. The next thing I noticed was that if you right clicked in the field and clicked paste from the menu then whatever text that was currently on the clipboard would appear in the text field just fine. Strange, copy and pasting is working fine, but the shortcuts aren’t working at all. After some more reading and fiddling around I figured out that modifier key shortcuts (Apple+whatever, Option+whatever, Ctrl+whatever) are handled a long time before they get to an NSTextField.

OK, fine, so why aren’t they being handled and why aren’t the blasted shortcuts working?

The one major thing different about my application (and any application with only an NSStatusItem) is that it has no main application menu with an ‘Application’, ‘File’ and ‘Edit’ etc. menu showing along the top. Now, the application ‘Edit’ menu is the one with the ‘Copy’ and ‘Paste’ operations and corresponding key shortcuts. If your application has no ‘Edit’ menu with the operations you need under it then, believe it or not, the keyboard shortcuts won’t work anywhere in your application.

So, I tried dragging an ‘Edit’ menu onto my MythGrowl status item menu using the interface builder and then tried running my app and copying and pasting into the boxes. And it works! But now I have a problem, I don’t want my app to have an ugly, unneeded ‘Edit’ menu, I just want to enable the keyboard shortcuts. So, I created a ‘dummy’ menu with an ‘Edit’ menu in it and added it as an outlet, now I just needed to figure out a way to tell my application that my ‘dummy’ menu will be taking over the role of my main application menu. After some more messing around I found that you can do this with [NSApp setMainMenu:yourDummyMenuName]; which I called when setting up my NSStatusItem.

I recompiled and to my absolute joy all the keyboard shortcuts worked. I could copy and paste in and out of the NSTextfields using the keyboard to my hearts content. Problem solved. The dummy menu seems a but of hack, but I really cannot see how it is to be avoided if you don’t want a visible ‘Edit’ menu.

I imagined that this must be a problem that other Cocoa developers using an NSStatusItem would have had and surely there would be a better way to fix this somehow. Expecting some enlightenment I checked to see if I was able to copy the text in the about boxes of Jumpcut and Alarm Clock 2 (two of my favorite OS X applications) to the clipboard using only the keyboard shortcuts. To my amazement I heard the familiar ‘ding’ noise and the text wouldn’t copy, I right clicked and copied some text to the clipboard using the mouse and it worked just fine. So it would seem I’m not the only developer who has had this problem. The creators of both Jumpcut and Alarm Clock 2 either:

1) Didn’t notice the problem or
2) Didn’t think it was enough of a problem to fix (I have to agree) given that both Alarm Clock 2 and Jumpcut hardly use any NSTextFields and copying text from the about boxes is not something a lot of people would need to do

How many other applications with an NSStatusItem have this problem I wonder? Was I really the first to find it? All of this sure seems totally insane to make something so trivial as copy and pasting from a couple of text fields work.

So, next time you open the preferences window of MythGrowl, be sure to copy and paste in out of the fields a couple of times, it will make all my efforts that much more worth while :-) and I sure hope this post saves some other Cocoa developer a lot of pain.

MythTV Symlinking Script

Tuesday, January 2nd, 2007

Here’s a really handy script one of my friends wrote that creates a directory of symlinks in your MythTV recordings directory with the show name and date. It is great for when you want to take a copy of some shows on the road with you or give them to someone who missed an episode of something. This may explain what it does better:

root@myserver:/mnt/mythtv-recordings/symlinks# ls -lh

5th Gear - 2006-11-12 14:25 - 15:07.nuv -> ../1001_20061112142500.nuv
5th Gear - 2006-11-19 14:20 - 15:07.nuv -> ../1001_20061119142000.nuv
5th Gear - 2006-11-26 14:20 - 15:07.nuv -> ../1001_20061126142000.nuv
5th Gear - 2006-12-10 14:20 - 15:07.nuv -> ../1001_20061210142000.nuv

You can download it here, just put in your mysql server username and password, MythTV database name and recordings directory at the top and run it. It should do the rest for you, you should set it up to run under a cron job every hour or so and it will keep the symlinks directory updated for you.

MythGrowl Bugfixes

Sunday, December 31st, 2006

I found a couple of problems with MythGrowl, it would often crash after being run for more that 3 hours due to some very hard to debug multi-threading problems. I have it all sorted now, so if you downloaded and were running MythGrowl 0.1 or 0.2 be sure to upgrade and run 0.3 which is available at the same download link as before in the post below.

For those interested, I was using the curl library for Cocoa to retrieve the Mythbackend status page in its own thread. Turns out the use of libcurl was totally unnecessary as versions of MAC OS X greater than 10.2 support the NSURLConnection API which provides a much more clean and simple way to retrieve data from a URL. So I have also been able to reduce the size of the application and source by removing the threading library I was using and eliminating libcurl.

Overall a very satisfactory fix.

MythGrowl Released

Wednesday, December 27th, 2006

I’ve just finished writing MythGrowl - a fairly simple MAC OS X application that generates Growl notifications when your MythTV backend starts and stops recording or watching a show. You simply specify the IP address or hostname of your MythTV backend server and it will start notifying you. The application (universal binary) is available below.

Update: This is no longer the place to download MythGrowl. It has moved to http://mythgrowl.sourceforge.net/ Download the latest version there!

Download now
 

Complete source code can be downloaded here
I’m releasing MythGrowl under the GPL.

You have to promise to check for regular updates and report any bugs. I plan to implement the Sparkle update system in the next release.

Screenshots:

Gmail Notifier in Ubuntu Breezy

Tuesday, January 17th, 2006

Gmail Notifier

About a year ago I wrote a Linux alternative in Python to the Gmail Notifier released by Google using the libgmail library. It took off rather well for a while but Google kept changing things about the way Gmail worked meaning I had to constantly update the libgmail library. Since then many others have got involved with the project and recently Juan Grande re-wrote most of the code to use the Gmail Atom library meaning the project has become fairly stable and reliable as a day to day tool. The greatest part now though is that someone has built a Gmail Notifier package for Ubuntu Breezy that can be apt-get installed if you have the universe source package line in your sources.list uncommented. So if you run Ubutu Breezy, try:

sudo apt-get install gmail-notify

The Gmail notifier project site can be found here
and the Ubuntu package page for the app can be found here