Skip to content

Commit

Permalink
Sway: fix alttab script
Browse files Browse the repository at this point in the history
Quick hack to fix alttab windows navigation.
  • Loading branch information
rkiyanchuk committed Jul 27, 2020
1 parent ec1df4f commit 14a9676
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sway/.config/sway/alttab
Expand Up @@ -8,11 +8,18 @@ direction=bool(sys.argv[1] == 't' or sys.argv[1] == 'T')
swaymsg = subprocess.run(['swaymsg', '-t', 'get_tree'], stdout=subprocess.PIPE)
data = json.loads(swaymsg.stdout)
current = data["nodes"][1]["current_workspace"]
workspace = int(data["nodes"][1]["current_workspace"])-1
roi = data["nodes"][1]["nodes"][workspace]


def getWorkspaceByName(name, nodes):
lookup = {i["name"]: i for i in nodes}
return lookup[name]


roi = getWorkspaceByName(current, data["nodes"][1]["nodes"])
temp = roi
windows = list()


def getNextWindow():
if focus < len(windows) - 1:
return focus+1
Expand All @@ -32,7 +39,7 @@ def makelist(temp):
makelist(temp[nodes][i])
else:
windows.append(temp[nodes][i])

def focused(temp_win):
for i in range(len(temp_win)):
if temp_win[i]["focused"] == True:
Expand All @@ -45,4 +52,3 @@ if str(sys.argv[1]) == 't' or str(sys.argv[1]) == 'T':
print(windows[getNextWindow()]["id"])
else:
print(windows[getPrevWindow()]["id"])

0 comments on commit 14a9676

Please sign in to comment.