Created
December 15, 2012 08:54
-
-
Save phyous/4292223 to your computer and use it in GitHub Desktop.
A bash function that uses the pushover api(https://pushover.net/) to send push notifications to your 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
############################ | |
# Push notifications script | |
############################ | |
read -d '' String <<"EOF" | |
require "net/https" | |
require "socket" | |
url = URI.parse("https://api.pushover.net/1/messages.json") | |
req = Net::HTTP::Post.new(url.path) | |
req.set_form_data({ | |
:token => "APPLICATION-TOKEN-HERE", | |
:user => "USER-KEY-HERE", | |
:message => "#{ARGV[0]}", | |
:title => "#{Socket.gethostname}", | |
:priority => 1, | |
:sound => "pianobar", | |
:timestamp => Time.now.to_i | |
}) | |
res = Net::HTTP.new(url.host, url.port) | |
res.use_ssl = true | |
res.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
res.start {|http| http.request(req) } | |
EOF | |
notify() {(ruby -e $String "$@" &) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment