Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/autonome/Quickfire. Firefox add-on for launching Mac applications from the URL bar.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162const { Cc, Ci, Cm, Cu, Cr, components } = require("chrome");
let apps = [];
function getAppsFromDirectory(aDir) { var dirs = [aDir]; while (dirs.length) { var dir = dirs.shift(); var entries = dir.directoryEntries; while (entries.hasMoreElements()) { var entry = entries.getNext(); entry.QueryInterface(Ci.nsIFile); if (/\.app$/.test(entry.path)) yield entry; else if (entry.isDirectory()) dirs.push(entry) } }}
function getAppList(callback) { let apps = []; ["LocApp", "UsrApp"].forEach(function(aDir) { var dirFile = Cc["@mozilla.org/file/directory_service;1"]. getService(Ci.nsIProperties).get(aDir, Ci.nsIFile);
var appGetter = getAppsFromDirectory(dirFile);
for (var app in appGetter) { if (/\.app$/.test(app.path)) apps.push(app); } }); callback(apps);}
getAppList(function(theApps) { apps = theApps;});
exports.search = function(searchString, callback) { apps.forEach(function(app) { if (app.path.toLowerCase().indexOf(searchString.toLowerCase()) != -1) callback({ leafName: app.leafName, path: app.path }); });};
function launchApp(aPath) { if (!apps.some(function(app) app.path == aPath)) return; var binFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); binFile.initWithPath(aPath); binFile.launch();}
exports.launch = launchApp;