[gnome-shell] Add magic "js " prefix to runDialog to run arbitrary JavaScript
- From: Colin Walters <walters src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-shell] Add magic "js " prefix to runDialog to run arbitrary JavaScript
- Date: Wed, 8 Jul 2009 21:31:06 +0000 (UTC)
commit 1cb6fc004b5c8752b73e5258db8ac9c71bde71e3
Author: Colin Walters <walters verbum org>
Date: Wed Jul 8 17:30:09 2009 -0400
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.
js/ui/runDialog.js | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js
index eafdaef..fc5493a 100644
--- a/js/ui/runDialog.js
+++ b/js/ui/runDialog.js
@@ -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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]