# -*- coding: utf-8 -*-
import subprocess
import json
import sys
import necessaryFuncs as nf

proc_out = subprocess.run(['swaymsg', '-t', 'get_workspaces'],
                          stdout=subprocess.PIPE)
wkList = json.loads(proc_out.stdout.decode('utf-8'))

focWkName = nf.getFocusedWK(wkList)
allProjectNames = nf.getListOfProjects(wkList)

if (len(allProjectNames) == 0) or (allProjectNames is None):
    sys.exit(1)

currentProjName = nf.getProjectFromWKName(focWkName)

if currentProjName is None:
    nextProjIndex = 0
else:
    nextProjIndex = allProjectNames.index(currentProjName)
    if nextProjIndex == (len(allProjectNames) - 1):
        nextProjIndex = 0
    else:
        nextProjIndex = nextProjIndex + 1

nxtProjWks = nf.getWKNamesFromProj(wkList, allProjectNames[nextProjIndex])

visWks = nf.getVisibleWKs(wkList)
# -*- coding: utf-8 -*-
import subprocess
import json
import sys
import necessaryFuncs as nf

proc_out = subprocess.run(['swaymsg', '-t', 'get_workspaces'], stdout=subprocess.PIPE)
wkList = json.loads(proc_out.stdout.decode('utf-8'))

allWKNames = nf.getWKNames(wkList)

currentWK = nf.getFocusedWK(wkList)

currentProj = nf.getProjectFromWKName(currentWK)

if currentProj is None:
    sys.exit(1)

currentProjWKs = nf.getWKNamesFromProj(wkList, currentProj)

if len(currentProjWKs) < 2:
    sys.exit(1)

thisWKPos = currentProjWKs.index(currentWK)

newWKPos = thisWKPos + 1
if newWKPos == len(currentProjWKs):
    newWKPos = 0

commandToRun = ['swaymsg', 'move container to workspace ' + currentProjWKs[newWKPos]]
Ejemplo n.º 3
0
def mk_cmd(i, x):
    ans = ''
    if (i != 0) or (currentProjWKs[i] != nf.getFocusedWK(wkList)):
        ans = ans + 'workspace ' + currentProjWKs[i] + '; '
    ans = ans + 'move workspace to output ' + newOutputs[i] + '; '
    return ans
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
import subprocess
import json
import sys
import necessaryFuncs as nf

proc_out = subprocess.run(['swaymsg', '-t', 'get_workspaces'],
                          stdout=subprocess.PIPE)
wkList = json.loads(proc_out.stdout.decode('utf-8'))

allWKNames = nf.getWKNames(wkList)

fcsWK = nf.getFocusedWK(wkList)

currentProj = nf.getProjectFromWKName(fcsWK)

if (currentProj is None) or (len(currentProj) == 0):
    sys.exit(1)

currentProjWKs = nf.getWKNamesFromProj(wkList, currentProj)

currentProjWKOutputs = [nf.getOutputForWK(wkList, x) for x in currentProjWKs]

newOutputPos = range(1, len(currentProjWKs) + 1)


def newOutputPosFn(x):
    if (x == len(currentProjWKOutputs)):
        x = 0
    return x
# Outputs where this project is already present
outputs_to_remove = [
    x['output'] for x in wkList if x['project'] == projectName
]
# Remaining outputs
allOutputs = list(set(allOutputs).difference(set(outputs_to_remove)))

newWorkspaceNums = nf.getValidWorkspaceNums(wkList, len(allOutputs))

commandToRun = ''

wkNameProjectPart = ':' + projectName + ':'

for i in range(1, len(allOutputs) + 1):
    # 1. find a workspace which is on this output
    # 2. switch to it if it is already not focused
    # 3. create the new workspace
    currentWKName = str(
        newWorkspaceNums[i - 1]) + ':' + wkNameProjectPart + str(i)

    currentOutputWK = nf.getWorkspacesOnOutput(wkList, allOutputs[i - 1])[0]

    if (i != 1) or (currentOutputWK != nf.getFocusedWK(wkList)):
        commandToRun = commandToRun + 'workspace ' + currentOutputWK + '; '

    commandToRun = commandToRun + 'workspace ' + currentWKName + '; '

commandToRunArray = ['i3-msg', commandToRun]

subprocess.call(commandToRunArray)
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-
import subprocess
import json
import necessaryFuncs as nf

proc_out = subprocess.run(['swaymsg', '-t', 'get_workspaces'],
                          stdout=subprocess.PIPE)
wkList = json.loads(proc_out.stdout.decode('utf-8'))

displays = list(sorted(nf.getListOfOutputs(wkList)))
current_display = nf.getOutputForWK(wkList, nf.getFocusedWK(wkList))
current_display_i = [
    i for i, x in enumerate(displays) if x == current_display
][0]

if current_display_i + 1 >= len(displays):
    next_display = displays[0]
else:
    next_display = displays[current_display_i + 1]

commandToRun = ["swaymsg", 'focus output ' + next_display]
subprocess.call(commandToRun)