Skip to content

Instantly share code, notes, and snippets.

@dkam
Last active August 29, 2015 14:26
Show Gist options
  • Save dkam/780b4e5e72bfc163c612 to your computer and use it in GitHub Desktop.
Save dkam/780b4e5e72bfc163c612 to your computer and use it in GitHub Desktop.
Desktop notifications for RSS stuff.
<?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>
#!/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
@dkam
Copy link
Author

dkam commented Aug 1, 2015

The desktop notification one works well. Pretty unobtrusive.
ozb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment