Skip to content

Instantly share code, notes, and snippets.

@FichteFoll
Last active April 4, 2021 04:42
Show Gist options
  • Save FichteFoll/a157454c4d41b9eb034d5d0d22e1274d to your computer and use it in GitHub Desktop.
Save FichteFoll/a157454c4d41b9eb034d5d0d22e1274d to your computer and use it in GitHub Desktop.
FireGestures script that opens a link or the current url in mpv
var mpv_exec = "/usr/bin/mpv";
function runCMD(cmd, args) {
// debug
console.log("executing: '" + cmd + "' with arguments " + args.toString());
// see: https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIProcess
// create an nsIFile for the executable
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
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);
}
var url = FireGestures.getLinkURL() || FireGestures.sourceNode.ownerDocument.location.href;
if (url) {
runCMD(mpv_exec, ["--player-operation-mode=pseudo-gui", url]);
}
else {
console.log("unable to find url");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment