bspwm/.config/bspwm/bspwm_auto_padding.py
def auto_pad(*, vpad_scale, hpad_scale):
    '''Auto-pad bspwm desktops with only one node

    Parameters:
        (h/v)pad_scale: size of padding as a fraction of screen width/height
    '''
    bspwm_state = bspwm.get_state()
    focused_desktop_ids = (mon['focusedDesktopId']
                           for mon in bspwm_state['monitors'])

    focused_desktops_first = sorted(
        get_all_desktops(bspwm_state),
        key=lambda desktop: desktop['id'] in focused_desktop_ids,
        reverse=True
    )

    for desktop in focused_desktops_first:
        # Get all clients (open windows) on the desktop.
        # NOTE: Sometimes there are null-valued clients. Why?
        clients = find_keys(desktop, 'client')

        # Count the number of windows in the desktop that are tiled.
        # (i.e. Ignore floating windows, etc.)
        # Using timeit,
        # len(list(<generator>)) was slightly faster than
        # len(tuple(<generator>)) and much faster than
        # sum(1 for _ in <generator>)
        num_tiled_clients = len(list(1 for c in clients
                                     if c and c['state'] == 'tiled'))
        padding = None
        if num_tiled_clients == 1:
            if desktop['padding']['left'] == 0:
                hpad_size = int(desktop['root']['rectangle']['width']
                                * hpad_scale)
                vpad_size = int(desktop['root']['rectangle']['height']
                                * vpad_scale)
                padding = {'top_padding':    vpad_size,
                           'bottom_padding': vpad_size,
                           'left_padding':   hpad_size,
                           'right_padding':  hpad_size}
        else:
            padding = {'top_padding':    0,
                       'bottom_padding': 0,
                       'left_padding':   0,
                       'right_padding':  0}
        if padding:
            bspwm_set_padding(desktop['id'], padding)
Auto-pad bspwm desktops with only one node

    Parameters:
        (h/v)pad_scale: size of padding as a fraction of screen width/height
    
Auto-pad bspwm desktops with only one node
Auto - pad bspwm desktops with only one node
def auto_pad(*, vpad_scale, hpad_scale):
    bspwm_state = bspwm.get_state()
    focused_desktop_ids = (mon['focusedDesktopId']
                           for mon in bspwm_state['monitors'])
    focused_desktops_first = sorted(
        get_all_desktops(bspwm_state),
        key=lambda desktop: desktop['id'] in focused_desktop_ids,
        reverse=True
    )
    for desktop in focused_desktops_first:
        clients = find_keys(desktop, 'client')
        num_tiled_clients = len(list(1 for c in clients
                                     if c and c['state'] == 'tiled'))
        padding = None
        if num_tiled_clients == 1:
            if desktop['padding']['left'] == 0:
                hpad_size = int(desktop['root']['rectangle']['width']
                                * hpad_scale)
                vpad_size = int(desktop['root']['rectangle']['height']
                                * vpad_scale)
                padding = {'top_padding':    vpad_size,
                           'bottom_padding': vpad_size,
                           'left_padding':   hpad_size,
                           'right_padding':  hpad_size}
        else:
            padding = {'top_padding':    0,
                       'bottom_padding': 0,
                       'left_padding':   0,
                       'right_padding':  0}
        if padding:
            bspwm_set_padding(desktop['id'], padding)
def auto_pad ( * , vpad_scale , hpad_scale ) : bspwm_state = bspwm . get_state ( ) focused_desktop_ids = ( mon [ 'focusedDesktopId' ] for mon in bspwm_state [ 'monitors' ] ) focused_desktops_first = sorted ( get_all_desktops ( bspwm_state ) , key = lambda desktop : desktop [ 'id' ] in focused_desktop_ids , reverse = True ) for desktop in focused_desktops_first : clients = find_keys ( desktop , 'client' ) num_tiled_clients = len ( list ( 1 for c in clients if c and c [ 'state' ] == 'tiled' ) ) padding = None if num_tiled_clients == 1 : if desktop [ 'padding' ] [ 'left' ] == 0 : hpad_size = int ( desktop [ 'root' ] [ 'rectangle' ] [ 'width' ] * hpad_scale ) vpad_size = int ( desktop [ 'root' ] [ 'rectangle' ] [ 'height' ] * vpad_scale ) padding = { 'top_padding' : vpad_size , 'bottom_padding' : vpad_size , 'left_padding' : hpad_size , 'right_padding' : hpad_size } else : padding = { 'top_padding' : 0 , 'bottom_padding' : 0 , 'left_padding' : 0 , 'right_padding' : 0 } if padding : bspwm_set_padding ( desktop [ 'id' ] , padding )
Auto-pad bspwm desktops with only one node
Auto - pad bspwm desktops with only one node
'''Auto-pad bspwm desktops with only one node

    Parameters:
        (h/v)pad_scale: size of padding as a fraction of screen width/height
    ''' # Get all clients (open windows) on the desktop. # NOTE: Sometimes there are null-valued clients. Why? # Count the number of windows in the desktop that are tiled. # (i.e. Ignore floating windows, etc.) # Using timeit, # len(list(<generator>)) was slightly faster than # len(tuple(<generator>)) and much faster than # sum(1 for _ in <generator>)
vpad_scale
hpad_scale
(h/v)pad_scale
size of padding as a fraction of screen width/height
size of padding as a fraction of screen width / height