Skip to content

Instantly share code, notes, and snippets.

@ruthlessfish
Created September 12, 2011 23:03
Show Gist options
  • Save ruthlessfish/1212724 to your computer and use it in GitHub Desktop.
Save ruthlessfish/1212724 to your computer and use it in GitHub Desktop.
Growl notifications in php
<?php
class Growl {
private $_command;
private $_valid_args = array('title', 'name', 'appicon', 'message', 'icon', 'iconpath', 'image', 'priority', 'identifier', 'wait', 'host', 'password', 'upd', 'port', 'auth', 'progress');
public function __construct($options = array())
{
if( ! empty($options))
{
$this->initialize($options);
}
}
public function initialize($options)
{
$this->_command = 'growlnotify';
foreach($options as $k=>$v)
{
if(in_array($k, $this->_valid_args))
{
$this->_command .= " --$k \"$v\"";
}
}
}
public function notify()
{
if($this->exists())
{
$cmd = $this->_command;
`$cmd`;
}
}
public function version()
{
return substr(`growlnotify -v`, 12, 5);
}
public function exists()
{
return (`which growlnotify` != '');
}
}
$growl = new Growl(array('message'=>'HELLO WORLD'));
$growl->notify();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment