Add magic "js " prefix to runDialog to run arbitrary JavaScript

This is useful for debugging things; e.g. you can "js Meta.quit(0)"
to exit the WM, "js Shell.Global.get().<whatever>..." etc.
This commit is contained in:
Colin Walters 2009-07-08 17:30:09 -04:00
parent 3b603ef7e0
commit 1cb6fc004b

View File

@ -79,7 +79,22 @@ RunDialog.prototype = {
},
_run : function(command) {
if (command == 'restart') {
if (command.slice(0, 3) == 'js ') {
let commandHeader = "const Clutter = imports.gi.Clutter; " +
"const GLib = imports.gi.GLib; " +
"const Gtk = imports.gi.Gtk; " +
"const Mainloop = imports.mainloop; " +
"const Meta = imports.gi.Meta; " +
"const Shell = imports.gi.Shell; " +
"const Main = imports.ui.main; ";
let cmd = commandHeader + command.substring(2);
try {
let result = eval(cmd);
log("" + result);
} catch (e) {
log(e);
}
} else if (command == 'restart') {
let global = Shell.Global.get();
global.reexec_self();
} else if (command) {