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:
|
else:
|
||||||
str &= " "
|
str &= " "
|
||||||
str &= "| " & ws.output & " | "
|
str &= "| " & ws.output & " | "
|
||||||
for app in ws.applications:
|
if ws.application.class != "":
|
||||||
str &= app.class & " " & app.title & " | "
|
str &= ws.application.class & " " & ws.application.title & " | "
|
||||||
|
else:
|
||||||
|
str = ""
|
||||||
|
# for app in ws.applications:
|
||||||
|
# str &= app.class & " " & app.title & " | "
|
||||||
return str
|
return str
|
||||||
|
|
||||||
proc findWorkspace(workspace: string): Workspace =
|
proc findWorkspace(workspace: string): Workspace =
|
||||||
|
@ -75,13 +79,15 @@ proc switchWorkspace(workspace: string) =
|
||||||
# apps.add(name)
|
# apps.add(name)
|
||||||
# return (apps, focused)
|
# return (apps, focused)
|
||||||
#
|
#
|
||||||
proc getApplication(node: JsonNode): Application =
|
proc getApplication(node: JsonNode, ws: Workspace = Workspace()): Application =
|
||||||
var app = Application()
|
var app = Application()
|
||||||
let window = node["window_properties"]
|
let window = node["window_properties"]
|
||||||
app.title = window["title"].getStr()
|
app.title = window["title"].getStr()
|
||||||
app.class = window["class"].getStr()
|
app.class = window["class"].getStr()
|
||||||
app.focused = node["focused"].getBool()
|
app.focused = node["focused"].getBool()
|
||||||
app.urgent = node["urgent"].getBool()
|
app.urgent = node["urgent"].getBool()
|
||||||
|
#echo ws.num
|
||||||
|
#echo app.title & " " & app.class
|
||||||
return app
|
return app
|
||||||
|
|
||||||
# proc findWorkspaces(node: JsonNode) =
|
# proc findWorkspaces(node: JsonNode) =
|
||||||
|
@ -118,27 +124,32 @@ proc newWorkspace(node: JsonNode): Workspace =
|
||||||
output: node["output"].getStr(),
|
output: node["output"].getStr(),
|
||||||
)
|
)
|
||||||
|
|
||||||
proc findWorkspacesTree(node: JsonNode) =
|
proc findWorkspacesTree(node: JsonNode, parent: Workspace = Workspace()) =
|
||||||
for channel in node["nodes"].getElems():
|
for channel in node["nodes"].getElems():
|
||||||
### move this into for loop if want separate entry per window
|
### move this into for loop if want separate entry per window
|
||||||
var ws: Workspace = Workspace()
|
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":
|
if node["output"].getStr() == "__i3":
|
||||||
return
|
return
|
||||||
ws = newWorkspace(node)
|
ws = newWorkspace(node)
|
||||||
###
|
###
|
||||||
if channel{"window_properties"} != nil:
|
if channel{"window_properties"} != nil:
|
||||||
let app = getApplication(channel)
|
let app = getApplication(channel,ws)
|
||||||
if ws.name != "":
|
if ws.name != "":
|
||||||
#if app.focused:
|
#if app.focused:
|
||||||
# ws.focused = true
|
# ws.focused = true
|
||||||
ws.applications.add(app)
|
ws.applications.add(app)
|
||||||
ws.application = app
|
ws.application = app
|
||||||
|
elif ws.num > 0 and len(channel{"nodes"}) > 0:
|
||||||
|
findWorkspacesTree(channel,ws)
|
||||||
else:
|
else:
|
||||||
findWorkspacesTree(channel)
|
findWorkspacesTree(channel)
|
||||||
### move this into for loop if want separate entry per window
|
### move this into for loop if want separate entry per window
|
||||||
if ws.name != "":
|
if ws.name != "":
|
||||||
ws.display_string = ws.buildString()
|
ws.display_string = ws.buildString()
|
||||||
|
if ws.display_string != "":
|
||||||
my_workspaces.add(ws)
|
my_workspaces.add(ws)
|
||||||
###
|
###
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue