Skip to content

Instantly share code, notes, and snippets.

@priithaamer
Created August 19, 2010 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save priithaamer/537341 to your computer and use it in GitHub Desktop.
Save priithaamer/537341 to your computer and use it in GitHub Desktop.
Command line utility to send Prowl notifications to phone
#!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
require 'prowl'
require 'readline'
config_file = File.join(ENV['HOME'], '.prowl')
if File.exist?(config_file)
config = YAML.load_file(config_file)
else
api_key = Readline.readline('Enter Prowl API key: ', true)
File.open(config_file, 'w') { |f| f.write({:api_key => api_key}.to_yaml) }
config = YAML.load_file(config_file)
end
input = if STDIN.tty? then ARGV.first else STDIN.first end
prowl = Prowl.new(:apikey => config[:api_key], :application => "Console")
if prowl.valid?
prowl.add(:event => "", :description => input)
else
puts 'Invalid Prowl configuration, try to remove ~/.prowl file.'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment