diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-10-30 12:26:15 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-10-30 12:26:15 (GMT) |
commit | 8ae611b1c9f6ccc4b65e493924fd075b102780f0 (patch) | |
tree | d5a09c6315538a9f5d0622b38dad0478bc67518b | |
parent | 0e4aaf0ad7bf1fe2173349c6618be9b0f2a2e6d9 (diff) |
remove external dependency
-rw-r--r-- | util.py | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -79,17 +79,10 @@ def dimensions_mm(dpi, w, h): def calc_dpi(): - '''Looking for 'dimensions' line in xdpyinfo - dimensions: 1280x800 pixels (339x212 millimeters)''' - (status, output) = commands.getstatusoutput('/usr/bin/xdpyinfo') - if status == 0: - strings = output[find(output, 'dimensions:'):].split() - w = int(strings[1].split('x')[0]) # e.g., 1280x800 - mm = int(strings[3][1:].split('x')[0]) # e.g., (339x212) - return int((w * 25.4 / mm) + 0.5), True - else: - # just in case the above fails - return 96, False + ''' Return screen DPI ''' + xft_dpi = gtk.settings_get_default().get_property('gtk-xft-dpi') + dpi = float(xft_dpi / 1024) + return dpi, True # |