Last active
April 4, 2021 04:42
-
-
Save FichteFoll/a157454c4d41b9eb034d5d0d22e1274d to your computer and use it in GitHub Desktop.
FireGestures script that opens a link or the current url in mpv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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