コード例 #1
0
ファイル: utils.py プロジェクト: sergiogbr/config.mac
def set_window_mark_callback(event, data, subscription):
    ''' Callback to automatically set a mark on a created window. '''
    obj = 'container'
    con_id = None
    name = None
    window = None
    if event.setdefault(obj, None):
        con_id = event[obj].setdefault('id', None)
        name = event[obj].setdefault('name', None)
        window = event[obj].setdefault('window', None)
    if window:
        dpy = display.Display()
        xwin = dpy.create_resource_object('window', window)
        name, _ = xwin.get_wm_class()
    cnames = i3.msg('get_marks')
    if name in cnames:
        i = 1
        bname = name
        name = '{0}-{1}'.format(bname, i)
        while name in cnames:
            i += 1
            name = '{0}-{1}'.format(bname, i)
    if con_id and name:
        i3.msg('command', '[con_id={0}] mark "{1}"'.format(con_id, name))
    thread.interrupt_main()
コード例 #2
0
def rename_workspace(old, new_number):
    '''Rename a given workspace.'''
    m = workspace_number_re.match(old)
    if not m:
        return
    new = '%d%s' % (new_number, m.group('name'))
    return i3.msg(0, "rename workspace {} to {}".format(old, new))
コード例 #3
0
def rename_workspace(old, new_number):
    """Rename a given workspace."""
    m = workspace_number_re.match(old)
    if not m:
        return
    new = "%d%s" % (new_number, m.group("name"))
    return i3.msg(0, "rename workspace {} to {}".format(old, new))
コード例 #4
0
def rename_workspace(old, new_number):
    '''Rename a given workspace.'''
    m = workspace_number_re.match(old)
    if not m:
        return
    new = '%d%s' % (new_number, m.group('name'))
    return i3.msg(0, "rename workspace {} to {}".format(old, new))
コード例 #5
0
ファイル: cur_output.py プロジェクト: syl20bnr/i3ci
def get_current_output():
    workspaces = i3.msg('get_workspaces')
    workspace = i3.filter(tree=workspaces, focused=True)
    if workspace:
        return workspace[0]['output']
    else:
        return None
コード例 #6
0
def get_current_workspace():
    ''' Returns the current workspace '''
    workspaces = i3.msg('get_workspaces')
    workspace = i3.filter(tree=workspaces, focused=True)
    if workspace:
        return workspace[0]['name']
    return ''
コード例 #7
0
def rename_workspace(old, new_number):
    """Rename a given workspace."""
    m = workspace_number_re.match(old)
    if not m:
        return
    new = "%d%s" % (new_number, m.group("name"))
    return i3.msg(0, "rename workspace {} to {}".format(old, new))
コード例 #8
0
ファイル: utils.py プロジェクト: sergiogbr/config.mac
def get_current_workspace(mon='all'):
    ''' Returns the current workspace name. '''
    workspaces = i3.msg('get_workspaces')
    if mon == 'all' or mon == get_current_output():
        return i3.filter(tree=workspaces, focused=True)[0]['name']
    else:
        return i3.filter(tree=workspaces, output=mon, visible=True)[0]['name']
コード例 #9
0
ファイル: utils.py プロジェクト: sergiogbr/config.mac
def get_current_output():
    ''' Returns the current output name (the output with focus) '''
    workspaces = i3.msg('get_workspaces')
    workspace = i3.filter(tree=workspaces, focused=True)
    if workspace:
        return workspace[0]['output']
    else:
        return None
コード例 #10
0
def get_free_workspaces():
    ''' Returns the free workspaces (the workspace with focus) '''
    res = []
    all_workspaces = workspaces.get_workspaces_no_prefix()
    used_workspaces = i3.msg('get_workspaces')
    for w in all_workspaces:
        if not i3.filter(tree=used_workspaces, name=w):
            res.append(w)
    return res
コード例 #11
0
ファイル: outputs.py プロジェクト: plankiton/i3ci
def get_outputs_dictionary():
    ''' Returns a dictionary where key is a natural output name
    like "monitor 1" and value is the low level name like
    "xinerama-0"'''
    res = {}
    outputs = i3.msg('get_outputs')
    for i, o in enumerate(outputs):
        res['monitor {0}'.format(i + 1)] = o['name']
    return res
コード例 #12
0
ファイル: utils.py プロジェクト: sergiogbr/config.mac
def get_free_workspaces():
    ''' Returns the free workspace names as a list '''
    res = []
    all_workspaces = get_workspace_name_catalog()
    used_workspaces = i3.msg('get_workspaces')
    for wks in all_workspaces:
        if not i3.filter(tree=used_workspaces, name=wks):
            res.append(wks)
    return res
コード例 #13
0
ファイル: outputs.py プロジェクト: syl20bnr/i3ci
def get_outputs_dictionary():
    ''' Returns a dictionary where key is a natural output name
    like "monitor 1" and value is the low level name like
    "xinerama-0"'''
    res = {}
    outputs = i3.msg('get_outputs')
    for i, o in enumerate(outputs):
        res['monitor {0}'.format(i+1)] = o['name']
    return res
コード例 #14
0
ファイル: utils.py プロジェクト: sergiogbr/config.mac
def get_workspaces(mon='all'):
    ''' Returns a structure containing all the opened workspaces. '''
    used = []
    ws_tree = i3.msg('get_workspaces')
    outs = get_outputs_dictionary()
    for o in outs.itervalues():
        if mon == 'all' or mon == o:
            for ws in get_workspace_name_catalog():
                if i3.filter(tree=ws_tree, output=o, name=ws):
                    used.append(ws)
    used.append('`')
    return sorted(used)
コード例 #15
0
ファイル: utils.py プロジェクト: sergiogbr/config.mac
def get_current_workspaces(mon='all'):
    ''' Returns a list of the names of all currently used workspaces on the
    specified output. '''
    all_ws = get_workspace_name_catalog()
    used = []
    ws_tree = i3.msg('get_workspaces')
    outs = get_outputs_dictionary()
    for o in outs.itervalues():
        if mon == 'all' or mon == o:
            for ws in all_ws:
                if i3.filter(tree=ws_tree, output=o, name=ws):
                    used.append(ws)
    return sorted(used)
コード例 #16
0
ファイル: cur_workspaces.py プロジェクト: plankiton/i3ci
def get_cur_workspaces(output='all'):
    ''' Return a list of all currently used workspaces on the specified
    output.
    '''
    all_ws = workspaces.get_workspaces_no_prefix()
    used = []
    ws_tree = i3.msg('get_workspaces')
    outs = outputs.get_outputs_dictionary()
    for o in outs.itervalues():
        if output == 'all' or output == o:
            for ws in all_ws:
                if i3.filter(tree=ws_tree, output=o, name=ws):
                    used.append(ws)
    used.append('`')
    return sorted(used)
コード例 #17
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
def main(socket, type, timeout, message):
    """
    Excepts arguments and evaluates them.
    """
    if not socket:
        socket = i3.get_socket_path()
        if not socket:
            print("Couldn't get socket path. Are you sure i3 is running?")
            return False
    # Initializes default socket with given path and timeout
    try:
        i3.default_socket(i3.Socket(path=socket, timeout=timeout))
    except i3.ConnectionError:
        print("Couldn't connect to socket at '%s'." % socket)
        return False
    # Format input
    if type in i3.EVENT_TYPES:
        event_type = type
        event = message
        type = 'subscribe'
    elif type == 'subscribe':
        message = message.split(' ')
        message_len = len(message)
        if message_len >= 1:
            event_type = message[0]
            if message_len >= 2:
                event = ' '.join(message[1:])
            else:
                event = ''
        else:
            # Let if fail
            event_type = ''
    try:
        if type == 'subscribe':
            i3.subscribe(event_type, event)
        else:
            output = i3.msg(type, message)
            print(output)
    except i3.i3Exception as i3error:
        print(i3error)
コード例 #18
0
def main(socket, type, timeout, message):
    """
    Excepts arguments and evaluates them.
    """
    if not socket:
        socket = i3.get_socket_path()
        if not socket:
            print("Couldn't get socket path. Are you sure i3 is running?")
            return False
    # Initializes default socket with given path and timeout
    try:
        i3.default_socket(i3.Socket(path=socket, timeout=timeout))
    except i3.ConnectionError:
        print("Couldn't connect to socket at '%s'." % socket)
        return False
    # Format input
    if type in i3.EVENT_TYPES:
        event_type = type
        event = message
        type = 'subscribe'
    elif type == 'subscribe':
        message = message.split(' ')
        message_len = len(message)
        if message_len >= 1:
            event_type = message[0]
            if message_len >= 2:
                event = ' '.join(message[1:])
            else:
                event = ''
        else:
            # Let if fail
            event_type = ''
    try:
        if type == 'subscribe':
            i3.subscribe(event_type, event)
        else:
            output = i3.msg(type, message)
            print(output)
    except i3.i3Exception as i3error:
        print(i3error)
コード例 #19
0
def load():
    try:
        workspace_mapping = pickle.load(open(PATH, "rb"))
    except Exception:
        print("Can't find existing mappings...")
        sys.exit(1)

    for workspace in workspace_mapping:
        i3.msg(
            'command',
            f"workspace {workspace['name']}",
        )
        i3.msg(
            'command',
            f"move workspace to output workspace['output']",
        )
    for workspace in filter(lambda w: w['visible'], workspace_mapping):
        i3.msg(
            'command',
            f"workspace workspace['name']",
        )
コード例 #20
0
def get_current_workspace(output='all'):
    workspaces = i3.msg('get_workspaces')
    if output == 'all' or output == cur_output.feed():
        return i3.filter(tree=workspaces, focused=True)
    else:
        return i3.filter(tree=workspaces, output=output, visible=True)
コード例 #21
0
ファイル: snippet.py プロジェクト: szabo92/gistable
        if workspace['visible']:
            return workspace['name']

if __name__ == '__main__':
    if len(sys.argv) < 2:
        showHelp()
        sys.exit(1)

    if sys.argv[1] == 'save':
        print("Storing...")
        workspace_mapping = {}
        for workspace in i3.get_workspaces():
            workspace_mapping[workspace['name']] = workspace['output']
        pickle.dump(workspace_mapping, open("%s/.i3/workspace_mapping" % os.path.expanduser("~"), "wb"))
    elif sys.argv[1] == 'restore':
        print("Restoring")
        try:
            workspace_mapping = pickle.load(open("%s/.i3/workspace_mapping" % os.path.expanduser("~"), "rb"))
        except Exception:
            print("Can't find existing mappings...")
            sys.exit(1)
        current_workspace = get_visible_workspace()
        for workspace in i3.get_workspaces():
            if workspace['name'] in workspace_mapping:
                i3.msg('command', 'workspace %s' % workspace['name'])
                i3.msg('command', 'move workspace to output %s' % workspace_mapping[workspace['name']])
        i3.msg('command', 'workspace %s' % current_workspace)
    else:
        showHelp()
        sys.exit(1)
コード例 #22
0
def move_container_to_workspace(workspace):
    return i3.msg(0, "move container to workspace number {}".format(workspace))
コード例 #23
0
ファイル: quickswitch.py プロジェクト: nriitala/conf
def move_window_here(window):
    """Does `move workspace current` on the specified window."""
    return i3.msg(0, "%s move workspace current" % i3.container(id=window))
コード例 #24
0
def move_container_to_workspace(workspace):
    """Moves the current container to the selected workspace"""
    return i3.msg(0, "move container to workspace {}".format(workspace))
コード例 #25
0
def goto_workspace(workspace):
    return i3.msg(0, "workspace {}".format(workspace))
コード例 #26
0
import i3, sys
# get a list of workspaces

for workspace in i3.get_workspaces():
    # get the workspace tree data
    workspace_tree = i3.filter(num=workspace.get('num'))
    # get a list of existing leaf windows in that workspace
    for window in i3.filter(workspace_tree, nodes=[]):
        # do something useful here
        if window.get('name').startswith(sys.argv[1]):
            i3.msg('command', '[con_id="{}"] focus'.format(window.get('id')))
            print("1")
            sys.exit(1)
print("0")
sys.exit(0)
コード例 #27
0
ファイル: action.py プロジェクト: syl20bnr/i3ci
 def process(self):
     i3.msg('command', ','.join(self._actions))
コード例 #28
0
def move_window_here(window):
    '''Does `move workspace current` on the specified window.'''
    return i3.msg(0,
                  "{} move workspace current".format(i3.container(id=window)))
コード例 #29
0
 def process(self):
     i3.msg('command', ','.join(self._actions))
コード例 #30
0
def move_container_to_workspace(workspace):
    """Moves the current container to the selected workspace"""
    ret = i3.msg(0, "move container to workspace {}".format(workspace))
    if follow or (follow_if_empty and is_current_workspace_empty()):
        goto_workspace(workspace)
    return ret
コード例 #31
0
ファイル: down.py プロジェクト: nacnudus/dotfiles
#!/usr/bin/python
import i3

outputs = i3.get_outputs()
output0 = outputs[0]
output1 = outputs[1]

for workspace in i3.get_workspaces():
    if workspace['output'] == output1['name']:
        i3.msg('command', 'workspace %s' % workspace['name'])
        i3.msg('command', 'move workspace to output %s' % output0['name'])

コード例 #32
0
def move_container_to_workspace(workspace):
    '''Moves the current container to the selected workspace'''
    return i3.msg(0, "move container to workspace {}".format(workspace))
コード例 #33
0
ファイル: switch.py プロジェクト: ombr/.dotfiles
#!/usr/bin/python
import i3
outputs = i3.get_outputs()

# set current workspace to output 0
i3.workspace(outputs[0]['current_workspace'])

i3.msg('command', 'move workspace to output right')
# ..and move it to the other output.
# outputs wrap, so the right of the right is left ;)

# rinse and repeat
i3.workspace(outputs[2]['current_workspace'])
i3.msg('command', 'move workspace to output left')
コード例 #34
0
ファイル: quickswitch.py プロジェクト: Lompik/dotfiles
def move_window_here(window):
    '''Does `move workspace current` on the specified window.'''
    return i3.msg(0, "{} move workspace current".format(
        i3.container(id=window)))
コード例 #35
0
def rename_workspace(old, new):
    '''Rename a given workspace.'''
    return i3.msg(0, "rename workspace {} to {}".format(old, new))
コード例 #36
0
ファイル: winmenu.py プロジェクト: CaMyPau/env-setup
import sys
import subprocess
import i3

def workspaces():
    reply = i3.msg( 'get_workspaces' )
    return [ w[ 'name' ] for w in reply ]

def win_menu( clients ):
    """
    Displays a window menu using dmenu. Returns window id.
    """

    command = [ '/usr/bin/dmenu' ]
    command += sys.argv[ 1 : ]

    dmenu = subprocess.Popen( command
                            , stdin  = subprocess.PIPE
                            , stdout = subprocess.PIPE )

    menu_str = '\n'.join( sorted( clients ) )
    # Popen.communicate returns a tuple stdout, stderr
    win_str = dmenu.communicate( menu_str.encode( 'utf-8' ) )[ 0 ].decode( 'utf-8' ).rstrip()
    return win_str

if __name__ == '__main__':
    clients = workspaces()
    ws_name = win_menu( clients )
    if ws_name:
        i3.msg( 'command', 'workspace ' + ws_name )
コード例 #37
0
Vim�UnDo�S���Sfya]�i�ؚ�[�JG^62�>.Ej5
	Z���
_�3)����Z���26j)                new_layout = 'horizontal'5�_�5����Z��	�45            sys.5�_�4����Z�� �35k5�_�4����Z��"�36k    5�_�5����Z��;�24k)                new_layout = 'horizontal'�35l            �46l            i3.5�_�4����Z��R�35j5�_�3)����Z��Y�26j)                new_layout = 'horizontal'5�_�	5����Z��p�45            i3.parse_msg_type5�_�
	5����Z��q
�45            5�_�	
����Z����j	import i3�k5�_�
3)����Z����24j)                new_layout = 'horizontal'                i3.fil5�_�
4����Z����355�_�
3)����Z����24j)                new_layout = 'horizontal'                5�_�
6����Z��=�57k!            #i3.split(new_layout)5�_�5����Z��@�46k            os.5�_�5����Z��F�46k            5�_�5����Z��j�46k             os.system('i3 split'5�_�5����Z��|�46k!            os.system('i3 split '5�_�5!����Z��}	�46k.            os.system('i3 split '+ new_layout)5�_�5����Z����465�_�5����Z����46j             i3.split(new_layout)5�_�
4����Z����355�_�5����Z��9�46j"   //         i3.split(new_layout)5�_�5����Z���46j            i3.5�_�5����Z���46j            i3.msg()5�_�5����Z���46j            i3.msg()5�_�5����Z��$�46j            i3.5�_�5����Z��$�46j            i3.5�_�5����Z��1�46j            5��
コード例 #38
0
ファイル: winmenu.py プロジェクト: CaMyPau/env-setup
def workspaces():
    reply = i3.msg( 'get_workspaces' )
    return [ w[ 'name' ] for w in reply ]
コード例 #39
0
ファイル: quickswitch.py プロジェクト: Lompik/dotfiles
def rename_workspace(old, new):
    '''Rename a given workspace.'''
    return i3.msg(0, "rename workspace {} to {}".format(old, new))
コード例 #40
0
def move_container_to_workspace(workspace):
    """Moves the current container to the selected workspace"""
    ret = i3.msg(0, "move container to workspace {}".format(workspace))
    if follow or (follow_if_empty and is_current_workspace_empty()):
        goto_workspace(workspace)
    return ret