Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#bytesObject

get the current number of bytes in and bytes out



4
5
6
7
8
# File 'bin/network', line 4

def bytes
  b_in = %x(netstat -ib | grep -e "en1" -m 1 | awk '{print $7}').chomp.to_i
  b_out = %x(netstat -ib | grep -e "en1" -m 1 | awk '{print $10}').chomp.to_i
  bytes = [b_in, b_out]
end

#growl(opts) ⇒ Object

Send message



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'bin/growl', line 52

def growl opts
  script = <<-EOD
  tell application "GrowlHelperApp"
     -- Make a list of all the notification types that this script will ever send:
     set the allNotificationsList to {"#{opts[:application]}"}

     -- Make a list of the notifications that will be enabled by default.      
     -- Those not enabled by default can be enabled later in the 'Applications'
     -- tab of the growl prefpane.
     set the enabledNotificationsList to {"#{opts[:application]}"}

     -- Register our script with growl.  You can optionally (as here) set a
     -- default icon for this script's notifications.
     register as application "#{opts[:application]}" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "#{opts[:icon]}"

     -- Send a Notification...
     notify with name "#{opts[:application]}" title "#{opts[:title]}" description "#{opts[:message]}" application name "#{opts[:application]}" sticky #{opts[:sticky]} priority #{opts[:priority]}

  end tell
  EOD

  %x(/usr/bin/osascript <<-GROWL\n#{script}\nGROWL)
end