USBView on Linux


You can list your USB devices using lsusb. However, the USB subsystem of controllers, hubs and devices connected to them has the structure of a tree and it would be most convenient to view as such. USBView is a small GTK tool written by kernel developer Greg Kroah-Hartman that shows the topography of the devices connected to your USB subsystem in this tree format.

  • Installing USBView is easy:
$ sudo apt install usbview
  • This tool parses the information available from /sys/kernel/debug/usb/devices and presents it nicely. Reading this file needs superuser permissions. You can read this information manually too:
$ sudo cat /sys/kernel/debug/usb/devices
  • To invoke USBView:
$ sudo usbview
  • In the tree presented by USBView, click on the controllers, hubs and devices connected to them to view information about them.

  • Some of the information I typically look for:

    • Manufacturer
    • Serial Number
    • Speed
    • USB version (2 or 3)
    • Device class
    • Power needed (in mA)

Tried with: USBView 2.0, Linux 3.13.0-52-generic and Ubuntu 14.04

How to change DPI in Matplotlib

Matplotlib can be used to output plot to PNG image files. To render for this bitmap format, Matplotlib uses a default DPI of 100. This is a surprisingly low DPI for plots. Thankfully, the DPI can be changed easily.

  • You can specify the DPI when you save a plot to a file:
using matplotlib.pyplot as mplot
mplot.savefig("foo.png", dpi=300)
  • If you want this DPI to be used for all output by Matplotlib, then set this line in your matplotlibrc file:
savefig.dpi: 300

Tried with: Matplotlib 1.4.3, Python 2.7.6 and Ubuntu 14.04

How to remove padding around plot in Matplotlib

The plot generated by Matplotlib typically has a lot of padding around it. This is useful if you are viewing or displaying the plot in isolation. However, when the plot is embedded inside another document, typically extra padding is added around and makes the plot look tiny. The solution is to reduce or remove the padding around the plot generated by Matplotlib.

This can be done by configuring the bounding box used for the plot while saving it to disk:

import matplotlib.pyplot as mplot
mplot.savefig("foo.pdf", bbox_inches="tight")

This makes the bounding box tight around the plot, while still giving enough space for the text or lines on the plot periphery.

If you want a plot with zero padding around it:

import matplotlib.pyplot as mplot
mplot.savefig("foo.pdf", bbox_inches="tight", pad_inches=0)

Personally, I find this too tight, but it might be useful in some situations.

Tried with: Matplotlib 1.4.3, Python 2.7.3 and Ubuntu 14.04

How to customize Matplotlib using matplotlibrc

If you find yourself using Matplotlib a lot, then it might be worth your while to customize its default configuration. This is best done using a matplotlibrc file.

  • You can find the global configuration file at /etc/matplotlibrc.

  • If you installed Matplotlib using pip, there is another global configuration file inside your Python installation that overrides the one in /etc. On my system, this path was /usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/matplotlibrc.

  • The best way to keep your Matplotlib customizations is to maintain it in your home directory at: ~/.config/matplotlib/matplotlibrc. You can have a look at the default configurations in the global files (above) and only set those you want to change in your home file.

Matplotlib will pick up these settings whenever it is executed.

Tried with: Matplotlib 1.4.3, Python 2.7.6 and Ubuntu 14.04

How to update LibreOffice

Adding a Dash entry for LibreOffice Writer

Adding a Dash entry for LibreOffice Writer

LibreOffice is under active development and the version that is maintained by Ubuntu can be pretty ancient. It is easy to remove that and update to the latest LibreOffice.

  • Remove the old LibreOffice:
$ sudo apt-get remove --purge libreoffice*
  • Download the .deb of the latest LibreOffice from here.

  • Unzip the downloaded .tar.gz file. You will find a DEBS directory. Install all the .deb packages in it:

$ sudo dpkg -i *.deb
  • You can launch the programs of LibreOffice from the shell as explained here. LibreOffice downloaded from their website has a binary that has the version in it. For example, libreoffice-4.4. Use this instead of libreoffice.

  • You might notice that LibreOffice does not add any entries to the Dash. You need to add them manually. An easy method to do this is by using the Main Menu (aka AlaCarte) tool as explained here. Icons for the LibreOffice programs can be found at /usr/share/icons/hicolor/128x128/apps/.

  • You might also want to associate the new LibreOffice programs for their filetypes. Thankfully, LibreOffice entries corresponding to the version you installed will appear in the Open With dialog.

Tried with: LibreOffice and Ubuntu 14.04

How to view man pages in color in Fish

Man pages in color

Man pages in color

When you open a man page you are confronted with a wall of white-on-black text. You may have noticed that man pages have some formatting information. This can be used to render the formatted elements in various colors. This can make reading and searching for information in a man page a pleasant affair.

To render man pages with colors in the Fish shell, add these lines to ~/.config/fish/

set -x LESS_TERMCAP_mb (printf "33[01;31m")  
set -x LESS_TERMCAP_md (printf "33[01;31m")  
set -x LESS_TERMCAP_me (printf "33[0m")  
set -x LESS_TERMCAP_se (printf "33[0m")  
set -x LESS_TERMCAP_so (printf "33[01;44;33m")  
set -x LESS_TERMCAP_ue (printf "33[0m")  
set -x LESS_TERMCAP_us (printf "33[01;32m")

Tried with: Fish 2.2b1 and Ubuntu 14.04

AttributeError with Python Enum


I had code that had worked correctly with Python 2.7 and that used the old enum module. Recently it started throwing this error:

$ ./ 
Traceback (most recent call last):
  File "./", line 146, in <module>
  File "./", line 100, in draw_plot
    if PlotType.Line == plot_type:
  File "/usr/local/lib/python2.7/dist-packages/enum/", line 373, in __getattr__
    raise AttributeError(name)
AttributeError: Line


This error is caused when the enum34 module has been installed alongside the old enum module. enum34 is the backport for Python 2.x of the standard enum in Python 3.4. Many packages have started to use it and so it will be installed implicitly while installing another package. enum34 overrides the old enum files and causes this error.

You could remove enum34 and get rid of this error. But since Python 3.x has already adapted a new enum type, it might be wiser to uninstall the old enum and rewrite your code to use enum34. Its syntax is shown in this example.

Tried with: Python 2.7.6 and Ubuntu 14.04