adjusted i3_workspaces to traverse down tree to get all open windows
This commit is contained in:
parent
28319104cd
commit
f93a90d8f9
1 changed files with 18 additions and 7 deletions
|
@ -43,8 +43,12 @@ proc buildString(ws: Workspace): string =
|
|||
else:
|
||||
str &= " "
|
||||
str &= "| " & ws.output & " | "
|
||||
for app in ws.applications:
|
||||
str &= app.class & " " & app.title & " | "
|
||||
if ws.application.class != "":
|
||||
str &= ws.application.class & " " & ws.application.title & " | "
|
||||
else:
|
||||
str = ""
|
||||
# for app in ws.applications:
|
||||
# str &= app.class & " " & app.title & " | "
|
||||
return str
|
||||
|
||||
proc findWorkspace(workspace: string): Workspace =
|
||||
|
@ -75,13 +79,15 @@ proc switchWorkspace(workspace: string) =
|
|||
# apps.add(name)
|
||||
# return (apps, focused)
|
||||
#
|
||||
proc getApplication(node: JsonNode): Application =
|
||||
proc getApplication(node: JsonNode, ws: Workspace = Workspace()): Application =
|
||||
var app = Application()
|
||||
let window = node["window_properties"]
|
||||
app.title = window["title"].getStr()
|
||||
app.class = window["class"].getStr()
|
||||
app.focused = node["focused"].getBool()
|
||||
app.urgent = node["urgent"].getBool()
|
||||
#echo ws.num
|
||||
#echo app.title & " " & app.class
|
||||
return app
|
||||
|
||||
# proc findWorkspaces(node: JsonNode) =
|
||||
|
@ -118,28 +124,33 @@ proc newWorkspace(node: JsonNode): Workspace =
|
|||
output: node["output"].getStr(),
|
||||
)
|
||||
|
||||
proc findWorkspacesTree(node: JsonNode) =
|
||||
proc findWorkspacesTree(node: JsonNode, parent: Workspace = Workspace()) =
|
||||
for channel in node["nodes"].getElems():
|
||||
### move this into for loop if want separate entry per window
|
||||
var ws: Workspace = Workspace()
|
||||
if node{"type"}.getStr() == "workspace":
|
||||
if parent.num > 0:
|
||||
ws = parent
|
||||
elif node{"type"}.getStr() == "workspace":
|
||||
if node["output"].getStr() == "__i3":
|
||||
return
|
||||
ws = newWorkspace(node)
|
||||
###
|
||||
if channel{"window_properties"} != nil:
|
||||
let app = getApplication(channel)
|
||||
let app = getApplication(channel,ws)
|
||||
if ws.name != "":
|
||||
#if app.focused:
|
||||
# ws.focused = true
|
||||
ws.applications.add(app)
|
||||
ws.application = app
|
||||
elif ws.num > 0 and len(channel{"nodes"}) > 0:
|
||||
findWorkspacesTree(channel,ws)
|
||||
else:
|
||||
findWorkspacesTree(channel)
|
||||
### move this into for loop if want separate entry per window
|
||||
if ws.name != "":
|
||||
ws.display_string = ws.buildString()
|
||||
my_workspaces.add(ws)
|
||||
if ws.display_string != "":
|
||||
my_workspaces.add(ws)
|
||||
###
|
||||
return
|
||||
|
||||
|
|
Loading…
Reference in a new issue