Discover and Change Resolution

Discovering the current resolution

xdpyinfo  | grep 'dimensions:'

or

xrandr | grep '*'

Changing the resolution

Without any configuration, my Awesome assigned bad resolutions to the monitor of my notebook (LVDS1) and the TV connected to 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

To fix it, I used the following command:

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

Since I don’t need to use the notebook monitor, I can turn it off using:

xrandr - -output LVDS1 - -off

Scripts

xrandir

Save the following script in ~/Scripts/monitors and add it to .xinitrc:

#!/bin/bash

EXTERNAL_OUTPUT="HDMI1"
INTERNAL_OUTPUT="LVDS1"
# EXTERNAL_LOCATION may be one of: left, right, above, or 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

Another way is to edit /etc/X11/xorg.conf. However, for some reason, the second screen ends up with the wrong resolution:

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

Julio Batista Silva
Julio Batista Silva
Data Engineer

I’m a computer engineer passionate about science, technology, photography, and languages. Currently working as a Data Engineer in Germany.

comments powered by Disqus