Fix display size on libvirt/Qemu guest

Lot of times I find myself of VM that does not correctly resize the screen display and that is literally nuisance. So, here is quick and dirty fix for this.

First you need to find out information about your display with following command:

xrandr -q

And you will see output like this:

Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
Virtual-0 connected primary 1920×1080+0+0 0mm x 0mm
1024×768      59.92 +
1920×1200     59.88
1920×1080     59.96*
1600×1200     59.87
1680×1050     59.95
1400×1050     59.98
1280×1024     59.89
1440×900      59.89
1280×960      59.94
1280×854      59.89
1280×800      59.81
1280×720      59.86
1152×768      59.78
800×600       59.86
848×480       59.66
720×480       59.71
640×480       59.38
Virtual-1 disconnected
Virtual-2 disconnected
Virtual-3 disconnected

This tells you the currently configured screens and the resolutions. In my case, the only connected screen as seen above is “Virtual-0“. Now, time to do the magic.

You just need to set the correct display/screen size with following command:

xrandr --output Virtual-0 --mode 1920x1200

Also, if you need to add a new resolution, first you need to create a modeline with following command:

cvt 1200 1024

You will get output like :

# 1200×1024 59.82 Hz (CVT) hsync: 63.59 kHz; pclk: 101.75 MHz
Modeline “1200x1024_60.00”  101.75  1200 1280 1400 1600  1024 1027 1037 1063 -hsync +vsync


and then set that with:

xrandr --output Virtual-0 --mode 1200x1024

Hope this helps you do away with some really pathetic display sizes in VM 🙂

Flowers near office

from Instagram:

Fix weird flux menu

Some distro’s just add all the items under single menu and thus the menu itself becomes unusable because of the number of items in the submenu and this I did not like and hence ceated this simply python script to fix that. For using the script, back up you “menu” file, redirect the output of this script to ‘menu’ file again.



F = open("~/.fluxbox/menu", "r")

for line in F:
    print line.rstrip()

    if '[submenu]' in line.lower() and started == 1:
        print '[end]'

    if '[end]'  in line.lower():
        if started > 0:
             # print "Count is {}".format(count)
             # print "Started is {}".format(started)
             print '[end]'
    if '[exec]'  in line.lower():
        if count > 15 :
            if started > 0:
                print '[end]'
                # print "Count is {}".format(count)
                # print "Started is {}".format(started)
            print '[submenu] ({})'.format(mkc)
        # print count