From fe794f47bd00babbdb4441fc01d94da442dd9430 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 22 Jan 2024 17:13:53 -0600 Subject: [PATCH] hyprstate -_- --- home/private_dot_config/eww/bin/hyprstate.nim | 29 +++++++++---------- home/private_dot_config/eww/yuck/vars.yuck | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/home/private_dot_config/eww/bin/hyprstate.nim b/home/private_dot_config/eww/bin/hyprstate.nim index 59e3892..a31250c 100644 --- a/home/private_dot_config/eww/bin/hyprstate.nim +++ b/home/private_dot_config/eww/bin/hyprstate.nim @@ -1,6 +1,5 @@ -import std/[os,net, json, sugar, enumerate, strformat, tables] +import std/[os,net, json, sugar, strformat, tables] -const NUM_WORKSPACES = 8 let icons = { "[Running] - Oracle VM VirtualBox": "", @@ -12,16 +11,17 @@ let icons = { "- NVIM": "", "Alacritty": "", "- Wezterm": "", + "org.wezfurlong.wezterm":"" }.toTable type HyprlandDefect* = Defect - Workspace = object - id, monitorID, windows: int - name, monitor, lastwindow, lastwindowtitle: string - hasfullscreen: bool + # Workspace = object + # id, monitorID, windows: int + # name, monitor, lastwindow, lastwindowtitle: string + # hasfullscreen: bool WorkspaceIcon = object id: int @@ -61,23 +61,22 @@ proc getDefaultWorkspaces(): seq[WorkspaceIcon] = 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,"") + if client.workspace.id < 0: continue result[client.workspace.id - 1].icon &= match - - for ws in result.mitems: if ws.icon == "": ws.icon = "" +proc getActive(m: Monitor): int {.inline.} = m.activeWorkspace.id proc getState(): seq[seq[WorkspaceIcon]] = - let monitors = parseJson(getData("[-j]/monitors")).to(seq[Monitor]) - let workspaces = parseJson(getData("[-j]/workspaces")).to(seq[Workspace]) - - let defaultWorkspaces = getDefaultWorkspaces() - for monitor in monitors: + let + monitors = parseJson(getData("[-j]/monitors")).to(seq[Monitor]) + defaultWorkspaces = getDefaultWorkspaces() + for m in monitors: result.add defaultWorkspaces - result[monitor.id][monitor.activeWorkspace.id - 1].class &= " " & "ws-button-open" - + result[m.id][getActive(m) - 1].class &= + " " & "ws-button-open" when isMainModule: while true: diff --git a/home/private_dot_config/eww/yuck/vars.yuck b/home/private_dot_config/eww/yuck/vars.yuck index 94403dc..9cd92af 100644 --- a/home/private_dot_config/eww/yuck/vars.yuck +++ b/home/private_dot_config/eww/yuck/vars.yuck @@ -1,6 +1,6 @@ (defvar rofi-bin "~/.config/rofi/bin") -(deflisten workspaces "nim c -r bin/hyprstate") +(deflisten workspaces "bin/hyprstate") (defpoll clocktext :interval "10s" "date '+%d %b %I:%M %p'") (defpoll bluetooth-icon :interval "5s" "bin/bluetooth.sh")