Example #1
0
def focus_num(switch_to_num):
    parent = i3.parent(i3.filter(focused=True)[0]['id'])

    print(parent)
    if len(parent['nodes']) >= switch_to_num:
        switch_to_cont = parent['nodes'][switch_to_num]
        i3.focus(con_id=switch_to_cont['id'])
        while i3.focus('child')[0]:
            pass
Example #2
0
def focus_num(switch_to_num):
    parent = i3.parent(i3.filter(focused=True)[0]['id'])

    print(parent)
    if len(parent['nodes']) >= switch_to_num:
        switch_to_cont = parent['nodes'][switch_to_num]
        i3.focus(con_id=switch_to_cont['id'])
        while i3.focus('child')[0]:
            pass
Example #3
0
def get_top_parent_of(container):
    max_iter = 20
    for _ in range(max_iter):
        parent = i3.parent(container['id'])
        container = parent
        if container['layout'] == 'tabbed': 
            return container
        if parent is None:
            return None

    return None
Example #4
0
#/usr/bin/env python
# $mod+Enter, $mod+Enter, $mod+h, $mod+Enter, ctrl-D: produces a container with only one node

import i3
import time
import pprint
pp = pprint.PrettyPrinter(indent=4)

currentWindow = i3.filter(focused=True)[0]
scanContainer = currentWindow
workspace_name = ''
while True:
    if scanContainer['type'] == 'workspace':
        workspace_name = scanContainer['name']
        break
    scanContainer = i3.parent(scanContainer['id'])
#print([node['name'] for node in scanContainer['nodes']])
#pp.pprint(scanContainer['nodes'])
pp.pprint(scanContainer)

exit()
print(currentWindow['name'])
parent = i3.parent(currentWindow['id'])
parent = i3.parent(parent['id'])
print(currentWindow['type'])
print(parent['type'])
print(parent['name'])
# this_id = currentWindow['id']
# i3.focus(con_id=this_id)
# i3.move('scratchpad')
# i3.focus(con_id=this_id)
Example #5
0
def get_container_idx_in_parent(parent, container):
    all_tab_ids = [node['id'] for node in parent['nodes']]
    while container['id'] not in all_tab_ids:
        container = i3.parent(container['id'])
    return all_tab_ids.index(container['id'])
Example #6
0
def get_workspace(container):
    if container['type'] == 'workspace':
        return container
    return get_workspace(i3.parent(container['id']))
Example #7
0
#! /usr/bin/python
import i3
import sys

current_node = i3.filter(focused=True)[0]
node = current_node
while node.get('type') != 4:
    node = i3.parent(node['id'])

all_windows = i3.filter(type=2, tree=node, nodes=[])

if not all_windows:
    sys.exit(0)

for num, window in enumerate(all_windows):
    if window['id'] == current_node['id']:
        break

if sys.argv[1] == 'next':
    try:
        new_focus = all_windows[num + 1]
    except IndexError:
        new_focus = all_windows[0]
elif sys.argv[1] == 'prev':
    try:
        new_focus = all_windows[num - 1]
    except IndexError:
        new_focus = all_windows[-1]
else:
    sys.exit(1)
Example #8
0
#!/usr/bin/env python
# https://faq.i3wm.org/question/3189/how-can-i-sort-windows-inside-a-container-automatically/

import i3

currentWindow = i3.filter(focused=True)[0]

parentContainer = i3.parent(currentWindow['id'])
if parentContainer['layout'] in ['splitv', 'stacked']:
    direction = 'down'
else:
    direction = 'right'

nodes = parentContainer['nodes']

snodes = sorted(nodes, key=lambda n:n['name'])

for node in snodes[1:]:
    i3.focus(con_id=node['id'])
    i3.move('scratchpad')

i3.focus(con_id=nodes[0]['id'])

for node in snodes[1:]:
    i3.focus(con_id=node['id'])
    i3.floating('disable')

i3.focus(con_id=currentWindow['id'])