Posts Tagged ‘xrandr’

With Ubuntu 14.04, by default there are no options to modify the brightness of the system. However there is an app for same called brightness controller. But I had problems setting up the brightness for the boot time itself. So I decided to find out how did the Brightness Controller work. I downloaded the source code from the git page and found out that internally it uses the Xrandr . So I added the Xrandr command to my bashrc file and now I don’t have to set the brightness every time.
jkapil@jkapil-desktop:~$ xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 32767 x 32767
VGA1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
1366x768       60.0*+
1024x768       75.1     70.1     60.0
800x600        72.2     75.0     60.3
640x480        75.0     72.8     60.0
720x400        70.1
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

This gives you the output names associated with your display. In my case its VGA1. To set the brightness,

$xrandr --output VGA1 --brightness 0.7

–brightness value is in between 0 and 1 and is a fraction. First execute in terminal to find out the brightness value soothing to your eye and then put that value with the above command in your .bashrc file in home directory.

Few days back,some rightmost part of my laptop screen got dead. Though I am still looking for a fully fledged solution but in the process I learnt about this very cool utility “xrandr” from xorg. Having the problems with refresh rate, needs custom resolution not available in your GUI application, need to setup another screen for your PC,all these question can be answered by this utility. in earlier releases of Ubuntu, xorg used to supply an xorg.conf file inside /etc/X11 directory which had all these options to configure your system but from 11.10, they have configured the X server to autodetect the configurations for your system though you still can create your custom configuration by creating this file in /etc/X11 but for that you need to dig a lot for different configuration options. xrandr does a lot of that for you. For e.g. to change your system’s resolution to lets say 1072X800, follow the following steps :
jkapil@jkapil-pc:~$ xrandr
Screen 0: minimum 320 x 200, current 1280 x 800, maximum 8192 x 8192
LVDS1 connected 1280x800+0+0 (normal left inverted right x axis y axis) 303mm x 190mm
1280x800 60.0*+
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
jkapil@jkapil-pc:~$ cvt 1072 800
# 1072x800 59.83 Hz (CVT) hsync: 49.72 kHz; pclk: 70.00 MHz
Modeline "1072x800_60.00" 70.00 1072 1136 1240 1408 800 803 813 831 -hsync +vsync
jkapil@jkapil-pc:~$ xrandr --newmode "1072x800_60.00" 70.00 1072 1136 1240 1408 800 803 813 831 -hsync +vsync
jkapil@jkapil-pc:~$ xrandr --addmode LVDS1 1072x800_60.00
jkapil@jkapil-pc:~$ xrandr --output LVDS1 --mode 1072x800_60.00
jkapil@jkapil-pc:~$ xrandr -s 0

first command gives the details of available output displays and the resolution modes available (read already configured) for your system. It also reports the physical size of your screen. There is another utility “xdpyinfo” which also reports the detailed info. about your displays and some information reported may differ from xrandr output but I found the xrandr output as accurate.
next command reports the modeline for the resolution you want.
Next command uses the modeline reported in previous command to add another resolution configuration for your system. Next command associates this configuration to the particular display output. In my case its “LVDS1” which is generally the laptop screen. You can specify the other outputs also. In second last command we switch to that mode by specifying its name. last command brings back the first resolution on the array of resolutions configured (see first output). You can specify either the resolution mode name or the serial no. of the resolution mode in last command.
For multi monitor configuration, specifying the rotation technique, monitors positions w.r.t. each other etc. can also be configured using this. You can use manpage of xrandr to browse through the vast scope of the xrandr.
https://wiki.archlinux.org/index.php/Xrandr is a very good link to understand the various functionality of xrandr.
If you face any problems, you can anyways write to xorg here about your problems.