Last active
August 29, 2015 14:26
-
-
Save dkam/780b4e5e72bfc163c612 to your computer and use it in GitHub Desktop.
Desktop notifications for RSS stuff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>com.ozbargains</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>/Users/{username}/bin/ozb.rb</string> | |
| </array> | |
| <key>StartInterval</key> | |
| <integer>300</integer> | |
| <key>RunAtLoad</key> | |
| <true/> | |
| <key>StandardErrorPath</key> | |
| <string>/tmp/ozb.err</string> | |
| <key>StandardOutPath</key> | |
| <string>/tmp/ozb.out</string> | |
| </dict> | |
| </plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'feedjira' ## For fetching and parse RSS | |
| require 'yaml/store' ## For storing viewed items | |
| require 'terminal-notifier' ## For sending a desktop notification | |
| # require 'httpclient' ## For sending notification to Pushover app on iOS | |
| # We'll use a YAML file to record which items have been sent. | |
| store = YAML::Store.new(File.join( ENV['HOME'] , '.ozb.yaml')) | |
| # Get all entries, select the entries whose id's aren't in the yaml file. | |
| Feedjira::Feed.fetch_and_parse('https://www.ozbargain.com.au/feed').entries.select {|e| store.transaction { store[e.id] }.nil?}.each do |entry| | |
| TerminalNotifier.notify(entry.title, title: "OzBargains", open: entry.url) | |
| #res = HTTPClient.new.post('https://api.pushover.net/1/messages.json', { token: '<Your Pushover App Token>', user: '<Your Pushover User Token>', html: 1, message: "<a href='#{entry.url}'>#{entry.title}</a>"}) | |
| # Save the ID and URL in the YAML file. | |
| store.transaction { store[entry.id] = entry.url } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The desktop notification one works well. Pretty unobtrusive.
