blob: 0637b12f62e6447ddaa103250ca2358a4e1dbdfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#! /usr/bin/env python3
import array
import fcntl
import termios
import os
def get_term_res():
buf = array.array('H', [0, 0, 0, 0])
fcntl.ioctl(1, termios.TIOCGWINSZ, buf)
return buf[2], buf[3]
def get_term_dimensions():
return os.get_terminal_size()
x_px, y_px = get_term_res()
size = get_term_dimensions()
x_cell, y_cell = size.columns, size.lines
print('width : {}, height: {}'.format(x_px / float(x_cell), y_px / float(y_cell)))
|