OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Virtual Me2Me implementation. This script runs and manages the processes | 6 # Virtual Me2Me implementation. This script runs and manages the processes |
7 # required for a Virtual Me2Me desktop, which are: X server, X desktop | 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop |
8 # session, and Host process. | 8 # session, and Host process. |
9 # This script is intended to run continuously as a background daemon | 9 # This script is intended to run continuously as a background daemon |
10 # process, running under an ordinary (non-root) user account. | 10 # process, running under an ordinary (non-root) user account. |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 if retcode != 0: | 322 if retcode != 0: |
323 logging.error("Failed to set XKB to 'evdev'") | 323 logging.error("Failed to set XKB to 'evdev'") |
324 | 324 |
325 # Register the screen sizes if the X server's RANDR extension supports it. | 325 # Register the screen sizes if the X server's RANDR extension supports it. |
326 # Errors here are non-fatal; the X server will continue to run with the | 326 # Errors here are non-fatal; the X server will continue to run with the |
327 # dimensions from the "-screen" option. | 327 # dimensions from the "-screen" option. |
328 for width, height in self.sizes: | 328 for width, height in self.sizes: |
329 label = "%dx%d" % (width, height) | 329 label = "%dx%d" % (width, height) |
330 args = ["xrandr", "--newmode", label, "0", str(width), "0", "0", "0", | 330 args = ["xrandr", "--newmode", label, "0", str(width), "0", "0", "0", |
331 str(height), "0", "0", "0"] | 331 str(height), "0", "0", "0"] |
332 proc = subprocess.Popen(args, env=self.child_env, stdout=devnull, | 332 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull) |
333 stderr=devnull) | |
334 proc.wait() | |
335 args = ["xrandr", "--addmode", "screen", label] | 333 args = ["xrandr", "--addmode", "screen", label] |
336 proc = subprocess.Popen(args, env=self.child_env, stdout=devnull, | 334 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull) |
337 stderr=devnull) | |
338 proc.wait() | |
339 | 335 |
340 # Set the initial mode to the first size specified, otherwise the X server | 336 # Set the initial mode to the first size specified, otherwise the X server |
341 # would default to (max_width, max_height), which might not even be in the | 337 # would default to (max_width, max_height), which might not even be in the |
342 # list. | 338 # list. |
343 label = "%dx%d" % self.sizes[0] | 339 label = "%dx%d" % self.sizes[0] |
344 args = ["xrandr", "-s", label] | 340 args = ["xrandr", "-s", label] |
345 proc = subprocess.Popen(args, env=self.child_env, stdout=devnull, | 341 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull) |
346 stderr=devnull) | 342 |
347 proc.wait() | 343 # Set the physical size of the display so that the initial mode is running |
| 344 # at approximately 96 DPI, since some desktops require the DPI to be set to |
| 345 # something realistic. |
| 346 args = ["xrandr", "--dpi", "96"] |
| 347 subprocess.call(args, env=self.child_env, stdout=devnull, stderr=devnull) |
348 | 348 |
349 devnull.close() | 349 devnull.close() |
350 | 350 |
351 def _launch_x_session(self): | 351 def _launch_x_session(self): |
352 # Start desktop session | 352 # Start desktop session |
353 # The /dev/null input redirection is necessary to prevent the X session | 353 # The /dev/null input redirection is necessary to prevent the X session |
354 # reading from stdin. If this code runs as a shell background job in a | 354 # reading from stdin. If this code runs as a shell background job in a |
355 # terminal, any reading from stdin causes the job to be suspended. | 355 # terminal, any reading from stdin causes the job to be suspended. |
356 # Daemonization would solve this problem by separating the process from the | 356 # Daemonization would solve this problem by separating the process from the |
357 # controlling terminal. | 357 # controlling terminal. |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 host_config.clear_auth() | 1050 host_config.clear_auth() |
1051 host_config.clear_host_info() | 1051 host_config.clear_host_info() |
1052 host_config.save() | 1052 host_config.save() |
1053 return 0 | 1053 return 0 |
1054 | 1054 |
1055 | 1055 |
1056 if __name__ == "__main__": | 1056 if __name__ == "__main__": |
1057 logging.basicConfig(level=logging.DEBUG, | 1057 logging.basicConfig(level=logging.DEBUG, |
1058 format="%(asctime)s:%(levelname)s:%(message)s") | 1058 format="%(asctime)s:%(levelname)s:%(message)s") |
1059 sys.exit(main()) | 1059 sys.exit(main()) |
OLD | NEW |