Descubrir y cambiar la resolución

mar. 5, 2011·
Julio Batista Silva
Julio Batista Silva
· 2 min de lectura

Descubrir la resolución actual

xdpyinfo  | grep 'dimensions:'

o

xrandr | grep '*'

Cambiar la resolución

Sin ninguna configuración, mi Awesome asignaba resoluciones malas al monitor de mi portátil (LVDS1) y a la TV conectada por HDMI:

julio@julio-acer ~> xrandr -q
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
LVDS1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 293mm x 164mm
   1366x768       60.0 +
   1024x768       60.0*
   800x600        60.3     56.2
   640x480        59.9
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 160mm x 90mm
   1920x1080      60.0 +   60.0
   1280x1024      60.0
   1280x720       60.0
   1024x768       60.0*
   800x600        60.3
   640x480        60.0     59.9
   720x400        70.1
DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
TV1 unknown connection (normal left inverted right x axis y axis)
   848x480        30.0 +
   640x480        30.0 +
   1024x768       30.0
   800x600        30.0

Para corregirlo, utilicé el siguiente comando:

julio@julio-acer ~> xrandr --output HDMI1 --auto
julio@julio-acer ~> xrandr --output LVDS1 --auto

Como no necesito usar el monitor del portátil, puedo apagarlo usando:

xrandr --output LVDS1 --off

Scripts

xrandir

Guarda el siguiente script en ~/Scripts/monitores y añádelo a .xinitrc:

#!/bin/bash

EXTERNAL_OUTPUT="HDMI1"
INTERNAL_OUTPUT="LVDS1"
# EXTERNAL_LOCATION puede ser: left, right, above o below
EXTERNAL_LOCATION="right"

case "$EXTERNAL_LOCATION" in
       left|LEFT)
               EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
               ;;
       right|RIGHT)
               EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"
               ;;
       top|TOP|above|ABOVE)
               EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"
               ;;
       bottom|BOTTOM|below|BELOW)
               EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"
               ;;
       *)
               EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
               ;;
esac

xrandr |grep $EXTERNAL_OUTPUT | grep " connected "
if [ $? -eq 0 ]; then
    xrandr --output $INTERNAL_OUTPUT --off --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION
else
    xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off
fi

#END

Xorg

Otro modo es editar /etc/X11/xorg.conf. Solo que por algún motivo la segunda pantalla queda con resolución incorrecta:

Section "Device"
    Identifier  "Card0"
    Driver      "intel"
    BusID       "PCI:0:2:0"
    Screen       0
EndSection

Section "Device"
    Identifier  "Card1"
    Driver      "intel"
    BusID       "PCI:0:2:0"
    Screen       1
EndSection

Section "Monitor"
    Identifier   "Televisao"
    Option       "Enable"    "true"
EndSection

Section "Monitor"
    Identifier   "Notebook"
    Option       "Enable"    "true"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device     "Card0"
    Monitor    "Televisao"
    DefaultDepth 24

    SubSectionSub "Display"
        Depth     24
        Modes    "1920x1080"
    EndSubSection
EndSection

Section "Screen"
    Identifier "Screen1"
    Device     "Card1"
    Monitor    "Notebook"
    DefaultDepth 24

    SubSectionSub "Display"
        Depth     24
        Modes    "1366x768"
    EndSubSection
EndSection

Section "ServerLayout"
    Identifier     "By Julio"
    Screen      0  "Screen0"
    Screen      1  "Screen1"
    Option    "Xinerama" "true"
EndSection

Enlaces

Julio Batista Silva
Autores
Senior Cloud Developer
comments powered by Disqus