Add gnome-shell --eval-file

Convenience utility function for evaluating an arbitrary
JavaScript file.
This commit is contained in:
Colin Walters 2009-11-12 18:18:34 -05:00
parent 7c796b2d2a
commit 8c05003acf

View File

@ -212,6 +212,8 @@ parser.add_option("", "--geometry", metavar="GEOMETRY",
default="1024x768");
parser.add_option("-w", "--wide", action="store_true",
help="Use widescreen (1280x800) with Xephyr")
parser.add_option("", "--eval-file", metavar="EVAL_FILE",
help="Evaluate the contents of the given JavaScript file")
options, args = parser.parse_args()
@ -219,6 +221,20 @@ if args:
parser.print_usage()
sys.exit(1)
if options.eval_file:
import dbus
f = open(options.eval_file)
contents = f.read()
f.close()
session = dbus.SessionBus()
shell = session.get_object('org.gnome.Shell', '/org/gnome/Shell')
shell = dbus.Interface(shell, 'org.gnome.Shell')
result = shell.Eval(contents)
print result
sys.exit(0)
if options.debug_command:
options.debug = True
elif options.debug: