From a06df8995da36e9160626896834dfc341d3b2c86 Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@member.fsf.org>
Date: Sat, 26 Sep 2009 18:33:49 +0000
Subject: sugar-emulator starts sugar out of Xephyr #1432
---
bin/sugar-emulator | 17 +++++++++--------
bin/sugar.in | 33 ++++++++++++++++++++++++++++++++-
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/bin/sugar-emulator b/bin/sugar-emulator
index 7f06609..99856dc 100644
a
|
b
|
def _start_xephyr(dpi, dimensions, fullscreen): |
73 | 73 | # FIXME evil workaround until F10 Xephyr is fixed |
74 | 74 | if os.path.exists('/etc/fedora-release'): |
75 | 75 | if open('/etc/fedora-release').read().startswith('Fedora release 10'): |
76 | | _run_xephyr(random.randint(100, 500), dpi, dimensions, fullscreen) |
77 | | return |
| 76 | display = random.randint(100, 500) |
| 77 | _run_xephyr(display, dpi, dimensions, fullscreen) |
| 78 | return display |
78 | 79 | |
79 | 80 | for display in range(100, 110): |
80 | 81 | if not _check_xephyr(display): |
… |
… |
def _start_xephyr(dpi, dimensions, fullscreen): |
83 | 84 | tries = 10 |
84 | 85 | while tries > 0: |
85 | 86 | if _check_xephyr(display): |
86 | | return |
| 87 | return display |
87 | 88 | else: |
88 | 89 | tries -= 1 |
89 | 90 | time.sleep(0.1) |
90 | 91 | |
91 | | def _start_window_manager(): |
| 92 | def _start_window_manager(display): |
92 | 93 | cmd = ['metacity'] |
93 | 94 | |
94 | | cmd.extend(['--no-force-fullscreen']) |
| 95 | cmd.extend(['--no-force-fullscreen', '-d', ':%d' % display]) |
95 | 96 | |
96 | 97 | gobject.spawn_async(cmd, flags=gobject.SPAWN_SEARCH_PATH) |
97 | 98 | |
… |
… |
def main(): |
146 | 147 | |
147 | 148 | _setup_env() |
148 | 149 | |
149 | | _start_xephyr(options.dpi, options.dimensions, options.fullscreen) |
| 150 | display = _start_xephyr(options.dpi, options.dimensions, options.fullscreen) |
150 | 151 | |
151 | 152 | if options.scaling: |
152 | 153 | os.environ['SUGAR_SCALING'] = options.scaling |
… |
… |
def main(): |
154 | 155 | command = ['dbus-launch', 'dbus-launch', '--exit-with-session'] |
155 | 156 | |
156 | 157 | if not args: |
157 | | command.append('sugar') |
| 158 | command.extend(['sugar', '-d', ':%d' % display]) |
158 | 159 | else: |
159 | | _start_window_manager() |
| 160 | _start_window_manager(display) |
160 | 161 | |
161 | 162 | if args[0].endswith('.py'): |
162 | 163 | command.append('python') |
diff --git a/bin/sugar.in b/bin/sugar.in
index 1c29a12..0cc97ca 100644
a
|
b
|
|
1 | 1 | #!/bin/sh |
2 | 2 | |
| 3 | usage() { |
| 4 | cat <<EOF |
| 5 | Usage: sugar [OPTION].. |
| 6 | |
| 7 | Start Sugar window manager. |
| 8 | |
| 9 | Optional arguments. |
| 10 | -d, --display DISPLAY Display to start sugar |
| 11 | -s, --scaling SCALING Scale Sugar theme |
| 12 | Supported values: 72, 100 |
| 13 | EOF |
| 14 | exit 0 |
| 15 | } |
| 16 | |
| 17 | while [ $# -ne 0 ] ; do |
| 18 | case "$1" in |
| 19 | -d | --display) |
| 20 | shift |
| 21 | export DISPLAY="$1" |
| 22 | ;; |
| 23 | -s | --scaling) |
| 24 | shift |
| 25 | export SUGAR_SCALING="$1" |
| 26 | ;; |
| 27 | -h | --help) |
| 28 | usage |
| 29 | ;; |
| 30 | esac |
| 31 | shift |
| 32 | done |
| 33 | |
3 | 34 | if test -z "$SUGAR_SCALING"; then |
4 | 35 | export SUGAR_SCALING=72 |
5 | 36 | fi |
… |
… |
if [ -f ~/.sugar/debug ]; then |
19 | 50 | . ~/.sugar/debug |
20 | 51 | fi |
21 | 52 | |
22 | | metacity --no-force-fullscreen & |
| 53 | metacity --no-force-fullscreen -d $DISPLAY & |
23 | 54 | |
24 | 55 | exec sugar-session |