Sha256: c198da85bb6c2ee794944b680dea78cd2365e8679b271ddcd222a1a2726a2244
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
#!/usr/bin/ruby # -*- mode: ruby -*- # vi: set ft=ruby : # This is the wrapper around Ubuntu's notify-send that connects to the host machine # when sending notifications require 'rubygems' require 'socket' require 'optparse' require 'fileutils' options = {} OptionParser.new do |opts| opts.banner = "Usage: notify-send.rb [options]" opts.on('-u', '--urgency LEVEL') { |v| options[:u] = v } opts.on('-t', '--expire-time TIME') { |v| options[:t] = v } opts.on('-a', '--app-name APP_NAME') { |v| options[:a] = v } opts.on('-i', '--icon ICON[,ICON...]') { |v| options[:i] = v } opts.on('-c', '--category TYPE[,TYPE...]') { |v| options[:c] = v } opts.on('-h', '--hint TYPE:NAME:VALUE') { |v| options[:h] = v } opts.on('-v', '--version') { |v| options[:v] = v } end.parse! if options[:i] new_filename = options[:i].gsub('/', '-') FileUtils.cp options[:i], "<%= shared_folder %>/#{new_filename}" options[:i] = new_filename end cmd = options.map do |key, value| "-#{key} '#{value}'" end.join(' ') # TODO: Need to escape values unless ARGV.empty? cmd << ARGV.map{|a| " '#{a}'"}.join(' ') end client_ip = `ip route|grep default|awk '{print $3}'` TCPSocket.open client_ip, <%= host_port %> do |s| s.send cmd, 0 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-notify-0.5.0 | files/notify-send.erb |