summaryrefslogtreecommitdiff
path: root/scripts/term-font-size
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2024-11-12 22:26:02 -0500
committerAndrew Opalach <andrew@akon.city> 2024-11-12 22:36:49 -0500
commit53a0a5473f45d37027af9663638adbf56667e4ca (patch)
tree05c6c39678a9005f95c00e0fdf31193657bd4d3d /scripts/term-font-size
downloaddotfiles-53a0a5473f45d37027af9663638adbf56667e4ca.tar.gz
dotfiles-53a0a5473f45d37027af9663638adbf56667e4ca.tar.bz2
dotfiles-53a0a5473f45d37027af9663638adbf56667e4ca.zip
Hopefully no leaks
Diffstat (limited to 'scripts/term-font-size')
-rwxr-xr-xscripts/term-font-size20
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/term-font-size b/scripts/term-font-size
new file mode 100755
index 0000000..0637b12
--- /dev/null
+++ b/scripts/term-font-size
@@ -0,0 +1,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)))