Created
August 19, 2010 07:45
-
-
Save priithaamer/537341 to your computer and use it in GitHub Desktop.
Command line utility to send Prowl notifications to phone
This file contains 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 '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