Beispiel #1
0
def mv_workspace(new_ws):
	# retrieve only active outputs
	outputs = filter(lambda output: output['active'], i3.get_outputs())

	workspace_names = [w['name'] for w in i3.get_workspaces()]
	pprint.pprint(i3.get_workspaces())

	visible_workspaces = [w['name'] for w in i3.get_workspaces() if w['visible'] == True]
	current_ws = [w['name'] for w in i3.get_workspaces() if w['focused'] == True][0]
	temp_name = 'temporary'
	cmds = []

	print "Moving ", current_ws, " to ", new_ws

	if new_ws in workspace_names:
		
		# Exit if it's the same workspace
		if new_ws == current_ws:
			return

		cmds.append(rename_a_to_b(current_ws, temp_name))
		cmds.append(rename_a_to_b(new_ws, current_ws))	
	cmds.append(rename_a_to_b(temp_name, new_ws))
		
	else:
def get_active_output_name(win):
    if win is None:
        return None
    outputs = i3.get_outputs()
    for i in outputs:
        if i['active'] and i['current_workspace'] == win['workspace']:
            return i['name']
    return None
Beispiel #3
0
def main(args):
    outputs = filter(lambda x: x['active'], i3.get_outputs())

    if len(outputs) < 2:
        raise ValueError("The second monitor hasn't been detected. Is it on?")
    #laptop_out, ext_out = outputs if outputs[0]['primary'] else reversed(outputs)
    excludes = args['<exclude>']
    if args['left']:
        migrate(*outputs, exclude=excludes)
    else:
        migrate(*reversed(outputs), exclude=excludes)
Beispiel #4
0
def main():
    outputs = i3.get_outputs()
    workspaces = i3.get_workspaces()

    active_workspaces = [o['current_workspace'] for o in outputs if o['active'] is True]

    if len(active_workspaces) != 2:
        return

    focused_workspace = [w['num'] for w in workspaces if w['focused'] is True]
    active_workspaces.remove(str(focused_workspace[0]))
    i3.command('workspace', active_workspaces[0])
Beispiel #5
0
def cycle():
    # get workspace focused on each screen
    workspace_per_screen = i3.get_outputs()
    # get currently focused windows
    current = i3.filter(nodes=[], focused=True)
    # get unfocused windows
    other = i3.filter(nodes=[], focused=False)
    # focus each previously unfocused window for 0.5 seconds
    for window in other:
        i3.focus(con_id=window['id'])
        time.sleep(0.5)
    # focus the old workspace on each screen
    for wks in workspace_per_screen:
        i3.workspace(wks['current_workspace'])
    # focus the original windows
    for window in current:
        i3.focus(con_id=window['id'])
Beispiel #6
0
def cycle():
    # get workspace focused on each screen
    workspace_per_screen = i3.get_outputs()
    # get currently focused windows
    current = i3.filter(nodes=[], focused=True)
    # get unfocused windows
    other = i3.filter(nodes=[], focused=False)
    # focus each previously unfocused window for 0.5 seconds
    for window in other:
        i3.focus(con_id=window['id'])
        time.sleep(0.5)
    # focus the old workspace on each screen
    for wks in workspace_per_screen:
        i3.workspace(wks['current_workspace'])
    # focus the original windows
    for window in current:
        i3.focus(con_id=window['id'])
Beispiel #7
0
    def _calc_metadata(self) -> (DisplayMap, dict):
        self.displays = i3.get_outputs()
        # Widths * Lengths (seperated to retain composition for children)
        total_size = {}
        monitor_cnt = 0
        for display in self.displays:
            if display["name"].startswith("xroot"):
                continue
            display_screen_location = Location(
                width=display["rect"]["width"],
                height=display["rect"]["height"])
            total_size[monitor_cnt] = display_screen_location
            monitor_cnt += 1

        self.all_outputs = i3.get_workspaces()
        active = [i for i in self.all_outputs if i["focused"]][0]
        self.active_output = active["output"]
        return total_size, active
def main(projectName):
    print(projectName)
    if (projectName is None) or (len(projectName) == 0):
        sys.exit(0)

    new_workspaces = []
    for output in i3.filter(tree=i3.get_outputs(), active=True):
        current_workspace_name = output['current_workspace']
        print(current_workspace_name)
        current_workspace = i3.filter(tree=i3.get_workspaces(),
                                      name=current_workspace_name)

        if not current_workspace[0]['focused']:
            print("Current workspace, {}, not focussed".format(
                current_workspace_name))
            i3.workspace(current_workspace_name)

        i3.workspace(projectName + '-' + output['name'])

    subprocess.call(['startWorkOn', projectName])
Beispiel #9
0
def main():
    outputs = i3.get_outputs()
    workspaces = i3.get_workspaces()

    # Only include outputs with active: True
    workspaces = [
        o['current_workspace'] for o in outputs if o['active'] is True
    ]

    if len(workspaces) == 2:
        i3.command('workspace', workspaces[0])
        i3.command('move', 'workspace to output down')

        # Hacky fix for race condition
        time.sleep(0.01)

        i3.command('workspace', workspaces[1])
        i3.command('move', 'workspace to output up')
    elif len(outputs) < 2:
        print('Not enough outputs')
    else:
        print('Too many outputs')
Beispiel #10
0
def outputs():
    puts = i3.get_outputs()
    act = [item for item in puts if item['active']]
    s = sorted(act, key=lambda x: x['rect']['x'])
    return s
Beispiel #11
0
config_path = os.path.expanduser("~")+"/.pybar"
if os.path.exists(config_path+"/config.py"):
    sys.path.append(config_path)
    from config import *
else:
    if not os.path.exists(config_path):
        os.mkdir(config_path)
    os.system("touch "+config_path+"/config.py")
    c = open(config_path+"/config.py","w")
    c.write(default_config)
    c.close()
    exec default_config



for a in i3.get_outputs():
    if a['name'] == "LVDS":
        screen_width = a['rect']['width']



# TODO: external ip
# TODO: i3 mode
# TODO: vim mode
# TODO: vimperator mode
# TODO: disk io
# TODO: kernel name/version
# TODO: cpu, gpu temp

# DONE: network io
# DONE: uptime
Beispiel #12
0
def get_active_outputs():
    """Returns outputs (monitors) that are active"""
    return [outp for outp in i3.get_outputs() if outp['active']]
Beispiel #13
0
#!/usr/bin/env python3
#

import i3
import sys

active_outputs = [o for o in i3.get_outputs() if o['active']]

if len(active_outputs) < 2:
    print("Too few outputs. Exiting.")
    sys.exit(0)
else:
    i3.workspace(active_outputs[0]['current_workspace'])
    i3.command('move', 'workspace to output right')
    i3.workspace(active_outputs[1]['current_workspace'])
    i3.command('move', 'workspace to output right')

# vim:fenc=utf-8 tabstop=8 expandtab shiftwidth=4 softtabstop=4
Beispiel #14
0
def get_active_outputs():
    return sorted(
        [outp['name'] for outp in i3.get_outputs() if outp['active']])
Beispiel #15
0
#!/usr/bin/python2.7

import i3
# retrieve only active outputs
outputs = filter(lambda output: output['active'], i3.get_outputs())

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

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

# rinse and repeat
i3.workspace(outputs[1]['current_workspace'])
i3.command('move', 'workspace to output right')
Beispiel #16
0
def get_active_screens():
    screens = i3.get_outputs()
    return filter(lambda x: x['active'], screens)
Beispiel #17
0
def get_active_outputs():
    """Returns outputs (monitors) that are active"""
    return [outp for outp in i3.get_outputs() if outp['active']]
Beispiel #18
0
def changeToPreferredOutput(session, targetWorkspace):
    availableOutputs = [output["name"] for output in i3.get_outputs()]
    for (output, workspaces) in config.outputMap.items():
        if output in availableOutputs and targetWorkspace.rawName in workspaces:
            print("Changing to {}".format(output))
            i3Utils.i3ChangeOutput(output)
Beispiel #19
0
#!/usr/bin/python2.7

import i3
outputs = i3.get_outputs()

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

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

# rinse and repeat
i3.workspace(outputs[1]['current_workspace'])
i3.command('move', 'workspace to output right')
Beispiel #20
0
#!/usr/bin/env python

# cycle-workspace
#   Moves the currently active workspace to the next active display
#   Depends on i3-py (`pip install i3-py`)

import i3

# figure out what is on, and what is currently on your screen.
focused_workspace = list(filter(lambda s: s['focused'],
                                i3.get_workspaces()))[0]
outputs = list(filter(lambda s: s['active'], i3.get_outputs()))

# find the index of the currently focused workspace
currentIndex = 0
for i, output in enumerate(outputs):
    if output['name'] == focused_workspace['output']:
        currentIndex = i
        break

# find the next workspace
nextIndex = currentIndex + 1
if nextIndex >= len(outputs):
    nextIndex = 0
other_workspace = outputs[nextIndex]
this_workspace = outputs[currentIndex]

# send current to the no-active one
i3.command('move', 'workspace to output ' + other_workspace['name'])
# i3.command('move', 'workspace to output '+this_workspace['name'])
Beispiel #21
0
#!/usr/bin/env python3

import i3

# Unfortunatelly this doesn't seem to be reliable

outputs = sorted((out for out in i3.get_outputs() if out["active"]), key=lambda o: o["rect"]["x"])
outputs.append(outputs[0])

for left, right in zip(outputs, outputs[1:]):
	i3.workspace(left["current_workspace"])
	i3.move("workspace to output {}".format(right["name"]))
	
Beispiel #22
0
import i3

outputs = [output for output in i3.get_outputs() if output['active']]

workspaces = i3.get_workspaces()

if len(outputs) == 2:
    for workspace in workspaces:
        print(workspace['name'])
        i3.workspace(workspace['name'])
        i3.command('move', 'workspace to output right')
Beispiel #23
0
#!/usr/bin/python2.7
# Swap workspaces on two monitors
import i3

# collect active outputs
to_be_swapped = [output for output in i3.get_outputs() if output['active']]
# only swap when there are two active outputs
if len(to_be_swapped) == 2:
    for output in to_be_swapped:
        i3.workspace(output['current_workspace'])
        i3.command('move', 'workspace to output right')
Beispiel #24
0
#!/usr/bin/python3

import i3

# retrieve only active outputs
outputs = list(filter(lambda output: output["active"], i3.get_outputs()))

current_ws = i3.filter(i3.get_workspaces(), focused=True)[0]["name"]

for output in outputs:
    # set current workspace to the one active on that output
    i3.workspace(output["current_workspace"])
    # ..and move it to the output to the right.
    # outputs wrap, so the right of the right is left ;)
    i3.command("move", "workspace to output right")

i3.workspace(current_ws)
#!/usr/bin/python3

import i3
# retrieve only active outputs
outputs = list(filter(lambda output: output['active'], i3.get_outputs()))

current_ws = i3.filter(i3.get_workspaces(), focused=True)[0]['name']

for output in outputs:
  # set current workspace to the one active on that output
  i3.workspace(output['current_workspace'])
  # ..and move it to the output to the right.
  # outputs wrap, so the right of the right is left ;)
  i3.command('move', 'workspace to output right')

i3.workspace(current_ws)

Beispiel #26
0
def outputs():
    puts = i3.get_outputs()
    act = [item for item in puts if item['active']]
    s = sorted(act, key=lambda x: x['rect']['x'])
    return s
Beispiel #27
0
#! /usr/bin/env python

import i3
import re
import sys
import subprocess

workspaces = i3.get_workspaces()
ws_list = []

for workspace in workspaces:
    ws_list.append(workspace['name'])

current_ws = i3.get_outputs()[0]['current_workspace']

try:
    ws_num = re.findall(r'\d+', current_ws)[0]
except:
    pass


def prev_ws():
    if current_ws == ws_list[0]:
        if current_ws == '0':
            return current_ws
        else:
            if 'ws_num' in globals():
                return str(int(ws_num) - 1)
            else:
                cmd = "i3-input -F 'echo %s' -P 'New workspace name: ' | grep 'output = ' | cut -c 10-"
                return subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0][:-1].decode('UTF-8')
Beispiel #28
0
def get_current_ws():
    for o in i3.get_outputs():
        if o['active']:
            return o['current_workspace']
Beispiel #29
0
#!/usr/bin/python3
import i3

current_output_name = [ws for ws in i3.get_workspaces()
                       if ws["focused"]][0]["output"]
output_names = [
    output["name"] for output in i3.get_outputs()
    if output["current_workspace"] != None
]

index = output_names.index(current_output_name)
next_output_index = (index + 1) % len(output_names)
next_output_name = output_names[next_output_index]

i3.move(f"workspace to {next_output_name}")
Beispiel #30
0
#!/usr/bin/python

import i3

outputs = list(filter(lambda o: o['active'], i3.get_outputs()))

i3.workspace(outputs[0]['current_workspace'])
i3.command('move', 'workspace to output right')

i3.workspace(outputs[1]['current_workspace'])
i3.command('move', 'workspace to output right')
Beispiel #31
0
#!/usr/bin/python2.7

import i3
outputs = i3.get_outputs()

# Move all workspace to the right, if output is active
for i in range(len(outputs)):
    if (outputs[i]['active'] == True):
        i3.workspace(outputs[i]['current_workspace'])
        i3.command('move workspace to output right')


Beispiel #32
0
#!/bin/env python
import sys
import os
import time
import i3

TEMP_WORKSPACE = "swap_outputs.py"

active_outputs = [out for out in i3.get_outputs() if out['active']]

# Do nothing if there aren't more than one active ouput
if len(active_outputs) < 2:
    sys.exit()

a, b = active_outputs[:2]
print("{} <-> {}".format(a['current_workspace'], b['current_workspace']))

a_workspace = a['current_workspace']
i3.workspace(a_workspace)
time.sleep(0.025)
i3.move('workspace to output right')
time.sleep(0.025)
i3.workspace(a_workspace)
time.sleep(0.025)
i3.rename('workspace to', TEMP_WORKSPACE)
time.sleep(0.025)

b_workspace = b['current_workspace']
i3.workspace(b_workspace)
time.sleep(0.025)
i3.move('workspace to output right')