Skip to content

Commit

Permalink
Added support for libnotify (but it requires libnotify-bin to be inst…
Browse files Browse the repository at this point in the history
…alled; which might not be installed by default on some systems).
  • Loading branch information
abi committed Jul 26, 2009
1 parent 7e064e7 commit 9923c77
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README
@@ -1 +1 @@
Yip is a Firefox extension that ports the Fluid and Prism notification APIs over to Firefox so you can receive Growl notifications (or plain Firefox notifications if you're on Windows or Linux) from web applications. For more information, head over to http://abcdefu.wordpress.com
Yip is a Firefox extension that ports the Fluid and Prism notification APIs over to Firefox so you can receive Growl notifications (or plain Firefox notifications if you're on Windows or Linux) from web applications. For more information, head over to http://www.yipyip.com
26 changes: 25 additions & 1 deletion components/yip.js
Expand Up @@ -47,7 +47,13 @@ Yip.prototype = {
var osString = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime).OS;
var msgSent = false;

var id = "yip@foyrek.com";
var extension = Cc["@mozilla.org/extensions/manager;1"]
.getService(Ci.nsIExtensionManager)
.getInstallLocation(id)
.getItemLocation(id);
var iconPath = "";

if(osString == "WINNT"){
// open the interface to Snarl
const cid = "@tlhan-ghun.de/snarlInterface;5";
Expand All @@ -67,6 +73,24 @@ Yip.prototype = {
}
}else if(osString == "Linux"){
//Use libnotify
iconPath = extension.path + "/content/images/icon.png";
try {

var file = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsILocalFile);
file.initWithPath("/usr/bin/notify-send");

var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);
var args = [utf8.encode(title), utf8.encode(text), "-i", iconPath];
process.run(false, args, args.length);
msgSent = true;

}catch(e){
msgSent = false;
}

}

if(!msgSent){
Expand Down

0 comments on commit 9923c77

Please sign in to comment.