[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [rhel6-branch] set the resolution with resolution= from the cmdline (#594918).



Ack.

On 05/25/2010 02:15 PM, Ales Kozumplik wrote:
tested x86_64 and vmware. note that the xrandr call does nothing if
--dpi=96 is also present, so I didn't use it. The fonts can therefore look
smaller/larger than usual.
---
  anaconda             |   34 ++++++++++++++++++++++++----------
  scripts/upd-instroot |    1 +
  2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/anaconda b/anaconda
index 7be6cc8..1d11887 100755
--- a/anaconda
+++ b/anaconda
@@ -73,7 +73,7 @@ def startAuditDaemon():
      os.waitpid(childpid, 0)

  # function to handle X startup special issues for anaconda
-def doStartupX11Actions(runres="800x600"):
+def doStartupX11Actions():
      global wm_pid

      setupGraphicalLinks()
@@ -89,7 +89,6 @@ def doStartupX11Actions(runres="800x600"):

      if wm_pid is not None:
          import xutils
-        import gtk

          try:
              xutils.setRootResource('Xcursor.size', '24')
@@ -104,6 +103,22 @@ def doStartupX11Actions(runres="800x600"):
              sys.stderr.write("X SERVER STARTED, THEN FAILED");
              raise RuntimeError, "X server failed to start"

+def set_x_resolution(runres):
+    # cant do this if no window manager is running because otherwise when we
+    # open and close an X connection in the xutils calls the X server will exit
+    # since this is the first X connection (if no window manager is running)
+    if runres and opts.display_mode == 'g' and not flags.usevnc and wm_pid :
+        try:
+            log.info("Setting the screen resolution to: %s.", runres)
+            iutil.execWithRedirect("xrandr",
+                                   ["-d", ":1", "-s", runres],
+                                   stdout="/dev/tty5", stderr="/dev/tty5")
+        except RuntimeError as e:
+            log.error("The X resolution not set")
+            iutil.execWithRedirect("xrandr",
+                                   ["-d", ":1", "-q"],
+                                   stdout="/dev/tty5", stderr="/dev/tty5")
+
  def doShutdownX11Actions():
      global wm_pid

@@ -167,8 +182,6 @@ def setupPythonUpdates():
          shutil.copyfile(rule, target)

  def parseOptions():
-    def resolution_cb (option, opt_str, value, parser):
-        parser.values.runres = value

      op = OptionParser()
      # Interface
@@ -198,8 +211,7 @@ def parseOptions():
      # Display
      op.add_option("--headless", dest="isHeadless", action="store_true", default=False)
      op.add_option("--nofb")
-    op.add_option("--resolution", action="callback", callback=resolution_cb, dest="runres",
-                  default="800x600", nargs=1, type="string")
+    op.add_option("--resolution", dest="runres", default=None)
      op.add_option("--serial", action="store_true", default=False)
      op.add_option("--usefbx", dest="xdriver", action="store_const", const="fbdev")
      op.add_option("--virtpconsole")
@@ -961,10 +973,10 @@ if __name__ == "__main__":
              # us SIGUSR1 if it succeeds.  if it fails, catch SIGCHLD and bomb out.

              def sigchld_handler(num, frame):
-                raise OSError
+                raise OSError(0, "SIGCHLD caught when trying to start the X server.")

              def sigusr1_handler(num, frame):
-                pass
+                log.debug("X server has signalled a successful start.")

              def preexec_fn():
                  signal.signal(signal.SIGUSR1, signal.SIG_IGN)
@@ -982,7 +994,7 @@ if __name__ == "__main__":
              signal.pause()

              os.environ["DISPLAY"] = ":1"
-            doStartupX11Actions(opts.runres)
+            doStartupX11Actions()
              xserver_pid = proc.pid
          except (OSError, RuntimeError):
              stdoutLog.warning(" X startup failed, falling back to text mode")
@@ -993,6 +1005,8 @@ if __name__ == "__main__":
              signal.signal(signal.SIGUSR1, old_sigusr1)
              signal.signal(signal.SIGCHLD, old_sigchld)

+    set_x_resolution(opts.runres)
+
      if opts.display_mode == 't' and graphical_failed and not anaconda.isKickstart:
          ret = vnc.askVncWindow()
          if ret != -1:
@@ -1004,7 +1018,7 @@ if __name__ == "__main__":
      # if they want us to use VNC do that now
      if opts.display_mode == 'g' and flags.usevnc:
          runVNC()
-        doStartupX11Actions(opts.runres)
+        doStartupX11Actions()

      anaconda.setInstallInterface(opts.display_mode)

diff --git a/scripts/upd-instroot b/scripts/upd-instroot
index 22b7192..7522db5 100755
--- a/scripts/upd-instroot
+++ b/scripts/upd-instroot
@@ -582,6 +582,7 @@ usr/bin/vncconfig
  usr/bin/vncpasswd
  usr/bin/wget
  usr/bin/xkbcomp
+usr/bin/xrandr
  usr/bin/zenity
  usr/lib/anaconda
  usr/lib/anaconda-runtime


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]