rulururu

post Custom refresh of NetNewsWire with AppleScript

January 16th, 2008

Filed under: Coding, mac — zedr0n @ 5:00 pm

I’ve switched to mac just recently and haven’t yet found the alternatives for all the windows tools. I’ve been trying Newsfire for some time and I’ve been somewhat satisfied with its performance. But since I’ve discovered Wilmott Forums RSS feeds I was having problems with Newsfire - it doesn’t change status, nor in any other way acknowledge small item updates. And as Wilmott goes with the one-item-per-thread model, so that the item just contains the date of the last post, it was more or less useless for with Newsfire.

Then NetNewsWire went freeware, so I decided to give it a try. It has a useful feature - “mark updated items as unread” while also sorting the items by the last update time, which is more or less what I need. Although, I need to say that it doesn’t mark items as unread after tiny updates - as on Wilmott, so it’s not ideal. One other problem with NetNewsWire is that the minimum refresh time is set to 30 minutes. While it might be acceptable to most feeds so as to not get distracted all the time, I want to get faster wilmott updates. Well, when there’s a will, there’s a way. And this way is called AppleScript.

Skip down for new beta of custom refresh app

The first, and by far simpler, way is to use a script. It’s pretty straightforward - just open up Script Editor and insert

repeat
  tell application "NetNewsWire" to refreshAll
  delay 300
end repeat

I’ve settled on 300 seconds for delay time, but whatever one wants. Now, running the script manually, looks like a chore and it still shows up as a window. So, to improve it, we can do File->Save As->application bundle. Still not much improvement so far, we can’t even quit the app. But we don’t really need it if we hide it. And it can be easily achieved by adding to /NameOfApp.app/Contents/Info.plist

<key>LSUIElement</key>
<string>1</string>

This key tells the app to work in background/dockless mode, which is precisely what we need. The cpu usage is quite modest indeed, so we can just add it as a Login item and all’s done. The NetNewsWire now refreshes as fast as we want it too.

The second way is for those who just need to be able to stop refreshing without resorting to Force Quit. It’s a bit harder, and involves using XCode.
The standard way to automate actions in Os X so far seems to use Automator, and NetNewsWire is no exception. Unfortunately, the number of actions available is rather limited, and no refresh/refreshAll action available. But we can create a new action on our own. To do this, simply do
XCode->New Projects->New AppleScript Application. Now the files we need are main.applescript, Info.plist, InfoPlist.strings. The script is just

on run {input, parameters}
    tell application "NetNewsWire" to refreshAll
    return input
end run

Now, if we switch to Release mode and build the app, the only thing left to install the action is to copy from project directory to either /Library/Automator or ~/Library/Automator. It will show up in Automator but as a separate action unrelated to NetNewsWire, it will work, but it does annoy a bit. That’s why we’ll need Info.plist - we change AMApplication key to

<key>AMApplication</key>
<string>NetNewsWire</string>

And that’s all we need to do for the app to show under NetNewsWire. To clean up things a bit, we can also edit InfoPlist.strings

AMName = "RefreshFeeds";
/*  AMDescription localized strings  */
AMDSummary = "Refresh all feeds";

Everything else there is irrelevant for our purpose.

The only thing left is just to create an Automator workflow of the format:

  • NetNewsWire-> _our new action to refreshAll in NetNewsWire_
  • Automator->Pause
  • Automator->RunWorkflow

Now we can save the workflow as application and apply the same trick with LSUielement. The only difference is on the menu bar
Menu Bar refresh

We can stop it at any time by pressing the red button. The disadvantages with this approach is 5-10 times bigger cpu usage(well, under 1% still) and clutter on the menu bar - but whatever one prefers…
You can download both apps here - script RefreshRSS and Automator RefreshFeeds

Thanks to a request from Theodora I’ve tried to improve the script a bit to allow for custom subscription refresh. It’s beta for now, so any comments are highly welcome, though it should work ;) So, what’s in the Refresher.app? It’s still just a script as RefreshRSS but with a few tweaks. Upon launch you’ll get a dialog in NetNewsWire asking

netnewswire001.jpg

If you click yes, then you’ll get a list of all your subscriptions where you need to choose the one you wish to set/change the refresh rate, it looks smth like this
netnewswire002.png

If you select the subscription you haven’t previously set the refresh rate for you’ll just get a dialog box
netnewswire003.png

The default value is 5 minutes; pressing ok will bring you again to the dialog box asking if you want to add another refresh rate.

If for whatever reason you want to change the refresh rate for subscription you just select it from the list and get a dialog box like
netnewswire005.png

That’s pretty much it. For technically oriented, this is pure AppleScript, all the details of your subscriptions are stored in ~/Library/Preferences/Refresher.info in format “Subscription:refresh time” on every line.

You can get it here : Refresher.zip

p.s. If you are getting error message “file Macintosh HD: … is already open” then this means that app crashed earlier and you’ll have to reboot to close it properly. Anybody knows how to close file opened with open for access under applescript for that matter?

17 Comments »

  1. Not familiar with scripts and automator, but am interested in the functionality this provides.

    Downloaded both RefreshRSS and Auomator RefreshFeeds both don’t know which one to use, or both?

    Looking for the ability to pause the refresh rate in the menu bar, like pictured above, but that option doesn’t appear to me when opening the apps.

    I probably missed something, help would be appreciated.

    Thanks

    Comment by Jelle — February 24, 2008 @ 11:25 pm

  2. If you use RefreshRss then you only need to launch it, it will refresh it in the background, nothing else needs to be done.

    If you are looking for the ability to pause the refresh rate, you should download just RefreshFeeds.
    Sorry, it’s my fault, you also need the to copy RefreshFeed.action to ~/Library/Automator before it starts working, I haven’t checked it. I’ve uploaded the new archive which contains RefreshFeed.action. Can you check it again?

    Comment by zedr0n — February 24, 2008 @ 11:40 pm

  3. Thanks for the quick reply. I downloaded the new zip package. Both the files were there. Had to create the Automator folder myself, strange. I installed the RefreshFeed.action file by opening it, guess that was necessary…?

    When opening NetNewsWIre the menu bar item appears briefly during start up, after which it disappears again. Don’t know what the problem is…

    Comment by Jelle — February 25, 2008 @ 12:54 am

  4. This means that the action hasn’t been registered, try copying it again to your ~/Library/Automator instead of just opening it

    Comment by zedr0n — February 27, 2008 @ 10:09 pm

  5. I’ve copied it to my user/library/automator folder

    nothing happens

    when opening the workflow in automator, automator crashes

    ?

    Comment by Jelle — February 28, 2008 @ 10:00 pm

  6. Interesting, are you on Tiger or Leopard?

    Can you please open Automator and check if there is RefreshFeeds action in NetNewsWire item?

    Comment by zedr0n — February 28, 2008 @ 10:36 pm

  7. I’d also like to refresh feeds more often and cant find any other good feed reader but I like the ability to have different refresh rates for groups.. Do you think it is possible to only change the “default refresh rate” to something short? It would be great. There are news I want to get asap and other feeds I only want to see once in a day.. Thank you.

    Comment by teodora — June 5, 2008 @ 10:15 am

  8. Teodora, out of top my head I think this will require adding a gui. Because NetNewsWire doesn’t provide custom refresh schedule through applescript so I can’t simply use the values in hours and treat them as minutes, as I supposed to.

    I’ll think about it, try out a few things, maybe it’ll work out

    Comment by zedr0n — June 5, 2008 @ 10:50 am

  9. ok, first beta out. Judging by the amount of problems with automator solution, I think I’ll remove it.

    Comment by zedr0n — June 5, 2008 @ 2:43 pm

  10. This is cool. I’m just getting into AppleScript, and every little thing helps.

    One thought on NetNewsWire, which I just started using today, is that since the refresh rate is saved as a preference within the application settings, doesn’t that mean the variable has to be written to the disk somewhere? If so, couldn’t that value just be hacked manually to 5 minutes, which seems a better idea than running another background process to refresh.

    I thought it might be a plist value, but I didn’t see anything in ~Library/ApplicationSupport/NetNewsWire or any of it’s subfolders. Nothing within the NetNewsWire.app pacakge either. Gonna dig around some more, but in the meanwhile, your script will work nicely. Thanks.

    Comment by Dave — June 11, 2008 @ 9:56 pm

  11. glad that you like it :)

    the plist file is in ~/Library/Preferences/com.ranchero.NetNewsWire.plist but it’s binary and I don’t feel like reverse engineering it. Moreover, it may have a custom value for each feed, so I’m not sure where it can be held or how it is used anyway. It can also have error-checking so it would need rewriting the value dynamically. AppleScript seems an easier solution for now :)

    Comment by zedr0n — June 11, 2008 @ 10:09 pm

  12. LOL. Color me stupid, or at least caffeine-deprived, this afternoon. Why I failed to look in the Preferences folder is beyond me.

    Okay, I have a binary plist editor, and yes, as suspected there’s an item in there called autoRefresh, but the key values are simply single digit numbers representing the selected refresh rate from the preference’s pulldown menu (ie., manual = 0, 30 minutes = 1, etc).

    So, no simple hack there. As you say, AppleScript is easier for now. ;-)

    Comment by Dave — June 11, 2008 @ 10:27 pm

  13. Honi soit the dazzlingly buy cytotec meat steamed held.

    Comment by Pwhndvve — August 9, 2008 @ 5:18 pm

  14. Wait wait wait… I’m sorry but I am just really confused….

    If I want to just refresh the feeds every 5 minutes or so, what do I need to do? It seems there are 4 ways to do it, and I’m not sure what one I’m supposed to use! I want to refresh feeds for Black Friday feeds. So I just want to refresh 5 minutes so I stay updated.

    Thanks!

    Comment by Jason Grier — November 11, 2008 @ 6:33 pm

  15. SEO ZONE is a search engine optimization(seo) firm, provides seo, seo article, seo tools,seo news and seo related informations,helping companies leverage the internet to increase revenues and profits.

    Comment by RIsEoben — December 5, 2008 @ 6:12 am

  16. hi, sorry for being late, I just found and tried it and it works great!! many thanks!

    (a minor thing: it would be great to choose more than one feed at once (with the cmd button) to set)

    Comment by teodora — December 7, 2008 @ 2:43 pm

  17. just two more quesitons: the refresh setting stays even if I quit the refresher app process, right? and how can someone set it all back to default?

    Comment by teodora — December 7, 2008 @ 2:53 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

ruldrurd
© quant0r.com , Designed by Stealth Settings
Entries (RSS) and Comments (RSS)