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 = {
|
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?")
|
raise newException(HyprlandDefect, "Could not connect to Hyprland IPC UNIX path; is Hyprland running?")
|
||||||
|
|
||||||
socket.send(data)
|
socket.send(data)
|
||||||
let response = socket.recv(4096)
|
var recvData: seq[string]
|
||||||
|
while true:
|
||||||
|
let response = socket.recv(4096)
|
||||||
|
if response == "":
|
||||||
|
break
|
||||||
|
recvData.add response
|
||||||
socket.close() # is this necessary?
|
socket.close() # is this necessary?
|
||||||
return response
|
return recvData.join("")
|
||||||
|
|
||||||
|
|
||||||
proc getDefaultWorkspaces(): seq[WorkspaceIcon] =
|
proc getDefaultWorkspaces(): seq[WorkspaceIcon] =
|
||||||
let clients = parseJson(getData("[-j]/clients")).to(seq[Client])
|
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}"))
|
result = collect(for i in 1..9: WorkspaceIcon(id: i, icon:"",class:fmt"ws-button-{i - 1}"))
|
||||||
for client in clients:
|
for client in clients:
|
||||||
let match = icons.getOrDefault(client.class,"")
|
let match = icons.getOrDefault($(client.class),"")
|
||||||
if client.workspace.id < 0: continue
|
if client.workspace.id < 0: continue
|
||||||
result[client.workspace.id - 1].icon &= match
|
result[client.workspace.id - 1].icon &= match
|
||||||
for ws in result.mitems:
|
for ws in result.mitems:
|
||||||
|
@ -84,5 +88,5 @@ when isMainModule:
|
||||||
sleep 500
|
sleep 500
|
||||||
try:
|
try:
|
||||||
echo (%* getState())
|
echo (%* getState())
|
||||||
except JsonParsingError:
|
except JsonParsingError as e:
|
||||||
discard
|
writeLine(stderr, e.msg)
|
||||||
|
|
Loading…
Reference in a new issue