Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 2ebfa14399d55fa9c5b93c32532e532edcf8b126 0 parents
@secondplanet authored
Showing with 174 additions and 0 deletions.
  1. +3 −0  .gitignore
  2. +37 −0 README.markdown
  3. +90 −0 brew-growl.rb
  4. +44 −0 growlnotifier.rb
3  .gitignore
@@ -0,0 +1,3 @@
+.DS_Store
+._*
+*\~
37 README.markdown
@@ -0,0 +1,37 @@
+# brew-growl
+
+ A simple Homebrew extension adding Growl support.
+
+## Install
+
+Clone the repo into somewhere that's in your PATH.
+
+## Usage
+
+To start using it, type
+
+ brew growl on
+
+Then add this to your `~/.bashrc` or `~/.zshrc`
+
+ source ~/.brew-growl
+
+To stop notifications,
+
+ brew growl off
+
+Write now this is a bit weird and uses `alias` to make it work; but I'm going to make
+some of the things work better in the future.
+
+NOTE: Currently, if you don't have Homebrew in `/usr/local`, you'll have to change
+the value of the `BREW_PREFIX` constant in `brew-growl.rb`
+
+## growlnotifier.rb
+
+This is a simple Growl wrapper I wrote in Ruby that I am using for this.
+It requires `growlnotify` and Growl.
+
+ brew install growlnotify
+
+The usage and details for the script are found at https://gist.github.com/1209632.
+
90 brew-growl.rb
@@ -0,0 +1,90 @@
+require 'formula'
+require 'growlnotifier'
+
+APPLICATION = 'Homebrew'
+BREW_PREFIX = '/usr/local'
+package = ""
+
+
+ready_notifier = GrowlNotifier.new(
+ :title => 'brew-growl',
+ :name => APPLICATION,
+ :message => 'Started.'
+ )
+
+stop_notifier = GrowlNotifier.new(
+ :title => 'brew-growl',
+ :name => APPLICATION,
+ :message => 'Stopped.'
+ )
+
+install_notifier = GrowlNotifier.new(
+ :title => package,
+ :name => APPLICATION,
+ :message => 'Installed.'
+ )
+
+upgrade_notifier = GrowlNotifier.new(
+ :title => APPLICATION,
+ :name => APPLICATION,
+ :message => 'Upgrade complete.'
+ )
+
+uninstall_notifier = GrowlNotifier.new(
+ :title => package,
+ :name => APPLICATION,
+ :message => 'Uninstalled.'
+ )
+
+update_notifier = GrowlNotifier.new(
+ :title => APPLICATION,
+ :name => APPLICATION,
+ :message => "Updated."
+ )
+
+error_notifier = GrowlNotifier.new(
+ :title => package,
+ :name => APPLICATION,
+ :message => 'Error; read ~/Library/Logs/Homebrew/config.log for details.'
+ )
+
+case ARGV.first
+ when 'install'
+ package = ARGV[1..ARGV.length].join(", ")
+ system "#{BREW_PREFIX}/bin/brew install #{ARGV[1..ARGV.length].join(" ")} 2>&1"
+ if $?.exitstatus == 0
+ install_notifier.notify!
+ else
+ error_notifier.notify!
+ end
+ when 'uninstall'
+ package = ARGV[1..ARGV.length].join(", ")
+ system "#{BREW_PREFIX}/bin/brew uninstall #{ARGV[1..ARGV.length].join(" ")} 2>&1"
+ if $?.exitstatus == 0
+ uninstall_notifier.notify!
+ else
+ error_notifier.notify!
+ end
+ when 'update'
+ system "#{BREW_PREFIX}/bin/brew update 2>&1"
+ if $?.exitstatus == 0
+ update_notifier.notify!
+ else
+ error_notifier.notify!
+ end
+ when 'upgrade'
+ system "#{BREW_PREFIX}/bin/brew upgrade 2>&1"
+ if $?.exitstatus == 0
+ update_notifier.notify!
+ else
+ error_notifier.notify!
+ end
+ when 'on'
+ system "echo alias \"brew='brew growl'\" > ~/.brew-growl"
+ ready_notifier.notify!
+ when 'off'
+ system "rm ~/.brew-growl"
+ stop_notifier.notify!
+ else
+ system "#{BREW_PREFIX}/bin/brew #{ARGV.join(" ")}"
+end
44 growlnotifier.rb
@@ -0,0 +1,44 @@
+class GrowlNotifier
+ def initialize(options={})
+ @command = "growlnotify "
+ @valid_args = [:title, :name, :appicon, :message, :icon, :iconpath, :image, :priority, :identifier,
+ :wait, :host, :password, :upd, :port, :auth, :progress]
+ options.each do |k, v|
+ if @valid_args.include? k
+ @command += "--#{k.to_s} \"#{v}\" "
+ end
+ end
+ end
+
+ def sticky!
+ @command += '--sticky '
+ end
+
+ def crypt!
+ @command += '--crypt '
+ end
+
+ def notify!
+ system @command
+ end
+
+ def sticky?
+ @command.inlude? ' --sticky'
+ end
+
+ def crypt?
+ @command.include? ' --crypt'
+ end
+
+ class << self
+ def growl_version
+ `growlnotify -v`[12..16]
+ end
+
+ def growl_exists?
+ `growlnotify --version 2>&1`
+ $?.exitstatus == 0
+ end
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.