Skip to content

Instantly share code, notes, and snippets.

@nwg-piotr
Last active January 16, 2020 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwg-piotr/e5ec2733740d80fa12b4aee5a893932e to your computer and use it in GitHub Desktop.
Save nwg-piotr/e5ec2733740d80fa12b4aee5a893932e to your computer and use it in GitHub Desktop.
This snippet uses i3ipc python module to print dimensions of just focused container
#!/usr/bin/env python3
from i3ipc import Connection, Event
i3 = Connection()
def print_dimensions(i3, e):
try:
con = i3.get_tree().find_focused()
rect = con.rect
print("width: {}, height: {}".format(rect.width, rect.height))
except Exception as e:
print('Error: {}'.format(e))
def main():
i3.on(Event.WINDOW_FOCUS, print_dimensions)
i3.main()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment