So I’ve been playing with ubiquity some more. Because all of the code runs in chrome:// space in firefox, you get to run as a first class citizen on the computer. Unfortunately this means if you want to do anything fun you need to deal with XPCOM.
Tonight I stole some code from developer.mozilla.org and came up with the following (only works/tested on a Mac):
function system(cmd, args) {
// create an nsILocalFile for the executable
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(cmd);
// create an nsIProcess
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);
// Run the process.
// If first param is true, calling thread will be blocked until
// called process terminates.
// Second and third params are used to pass command-line arguments
// to the process.
process.run(false, args, args.length);
}
CmdUtils.CreateCommand({
name: "say",
takes: {"your shout": noun_arb_text},
preview: function( pblock, theShout ) {
pblock.innerHTML = "Will echo: " + theShout.text;
},
execute: function( theShout ) {
system('/usr/bin/say', [theShout.text]);
},
})
This will run text-to-speech on whatever test you input (either via typing or that is selected in the browser) by using the say
command on OSX. The important part though is not what it does, it is what it can do. This opens up all of CPAN to Ubiquity.
I think I’m gonna have some fun now.
Rock on! Thanks
Now the last thing to do is make it so I can highlight text outside of firefox and use ubiquity on it. In the mac world I suppose you'd say I need to allow silverlight to talk to firefox... but I'm not in the mac world.
Let's see.... there is that telnet-into-firefox thingie to start with. Probably a lot of other ways to do this too. hmm...
Re:Ubiquitous Ubiquity
perigrin on 2008-08-30T02:10:38
In the Mac world I'd just say use QuickSilver
;) Re:Ubiquitous Ubiquity
awwaiid on 2008-08-30T03:12:25
What a horrid mis-speak! s/Silverlight/QuickSilver/ of course. ick!