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)

wksToMakeVisible = list(set(nxtProjWks) - set(visWks))
예제 #2
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
# -*- 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]]
        "--text=Start a new project with the name:"
    ],
                            stdout=subprocess.PIPE)
    projectName = proc.stdout.read()
    projectName = projectName.decode('utf-8').replace('\n',
                                                      '').replace('\r', '')

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

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

for one_wk in wkList:
    one_wk['project'] = nf.getProjectFromWKName(one_wk['name'])

allOutputs = nf.getListOfOutputs(wkList)
# 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 + ':'