Skip to content

Instantly share code, notes, and snippets.

@co3k
Created December 13, 2009 04:18
Show Gist options
  • Save co3k/255274 to your computer and use it in GitHub Desktop.
Save co3k/255274 to your computer and use it in GitHub Desktop.
growl に通知するやつ(暫定)
#!/usr/bin/php
<?php
/**
* Copyright 2009 Kousuke Ebihara
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$password = (!empty($_SERVER['NOTIFIER_PHP_PASSWORD'])) ? $_SERVER['NOTIFIER_PHP_PASSWORD'] : '';
$hostname = (!empty($_SERVER['NOTIFIER_PHP_HOSTNAME'])) ? $_SERVER['NOTIFIER_PHP_HOSTNAME'] : 'localhost';
$current = getcwd();
chdir(dirname(__FILE__));
require_once 'Net/Growl.php';
if (!isset($argv[0]) || __FILE__ !== realpath($argv[0])) {
exit('Notify must be executed from cli.'.PHP_EOL);
}
if ($argc <= 1) {
exit('You must specifiy some command.');
}
$_argv = $argv;
array_shift($_argv);
$command = implode(' ', $_argv);
$application = new Net_Growl_Application('notify', array('Start', 'End'), $password);
$growl = new Net_Growl($application, array(), '', array(
'host' => $hostname,
));
chdir($current);
$growl->notify('Start', 'Start Command', $command);
passthru($command);
$growl->notify('End', 'End Command', $command);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment