fix: fetch full message
This commit is contained in:
parent
b09816b7b7
commit
44633f082f
1 changed files with 11 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
|||
import std/[os,net, json, sugar, strformat, tables]
|
||||
import std/[os,net, json, sugar, strformat, strutils, tables]
|
||||
|
||||
|
||||
const icons = {
|
||||
|
@ -52,16 +52,20 @@ proc getData(data: string): string =
|
|||
raise newException(HyprlandDefect, "Could not connect to Hyprland IPC UNIX path; is Hyprland running?")
|
||||
|
||||
socket.send(data)
|
||||
var recvData: seq[string]
|
||||
while true:
|
||||
let response = socket.recv(4096)
|
||||
if response == "":
|
||||
break
|
||||
recvData.add response
|
||||
socket.close() # is this necessary?
|
||||
return response
|
||||
|
||||
return recvData.join("")
|
||||
|
||||
proc getDefaultWorkspaces(): seq[WorkspaceIcon] =
|
||||
let clients = parseJson(getData("[-j]/clients")).to(seq[Client])
|
||||
result = collect(for i in 1..9: WorkspaceIcon(id: i, icon:"",class:fmt"ws-button-{i - 1}"))
|
||||
for client in clients:
|
||||
let match = icons.getOrDefault(client.class,"")
|
||||
let match = icons.getOrDefault($(client.class),"")
|
||||
if client.workspace.id < 0: continue
|
||||
result[client.workspace.id - 1].icon &= match
|
||||
for ws in result.mitems:
|
||||
|
@ -84,5 +88,5 @@ when isMainModule:
|
|||
sleep 500
|
||||
try:
|
||||
echo (%* getState())
|
||||
except JsonParsingError:
|
||||
discard
|
||||
except JsonParsingError as e:
|
||||
writeLine(stderr, e.msg)
|
||||
|
|
Loading…
Reference in a new issue