hyprstate -_-
This commit is contained in:
parent
4acb073b7c
commit
fe794f47bd
2 changed files with 15 additions and 16 deletions
|
@ -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 = {
|
let icons = {
|
||||||
"[Running] - Oracle VM VirtualBox": "",
|
"[Running] - Oracle VM VirtualBox": "",
|
||||||
|
@ -12,16 +11,17 @@ let icons = {
|
||||||
"- NVIM": "",
|
"- NVIM": "",
|
||||||
"Alacritty": "",
|
"Alacritty": "",
|
||||||
"- Wezterm": "",
|
"- Wezterm": "",
|
||||||
|
"org.wezfurlong.wezterm":""
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
HyprlandDefect* = Defect
|
HyprlandDefect* = Defect
|
||||||
|
|
||||||
Workspace = object
|
# Workspace = object
|
||||||
id, monitorID, windows: int
|
# id, monitorID, windows: int
|
||||||
name, monitor, lastwindow, lastwindowtitle: string
|
# name, monitor, lastwindow, lastwindowtitle: string
|
||||||
hasfullscreen: bool
|
# hasfullscreen: bool
|
||||||
|
|
||||||
WorkspaceIcon = object
|
WorkspaceIcon = object
|
||||||
id: int
|
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}"))
|
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
|
||||||
result[client.workspace.id - 1].icon &= match
|
result[client.workspace.id - 1].icon &= match
|
||||||
|
|
||||||
|
|
||||||
for ws in result.mitems:
|
for ws in result.mitems:
|
||||||
if ws.icon == "":
|
if ws.icon == "":
|
||||||
ws.icon = ""
|
ws.icon = ""
|
||||||
|
|
||||||
|
proc getActive(m: Monitor): int {.inline.} = m.activeWorkspace.id
|
||||||
|
|
||||||
proc getState(): seq[seq[WorkspaceIcon]] =
|
proc getState(): seq[seq[WorkspaceIcon]] =
|
||||||
let monitors = parseJson(getData("[-j]/monitors")).to(seq[Monitor])
|
let
|
||||||
let workspaces = parseJson(getData("[-j]/workspaces")).to(seq[Workspace])
|
monitors = parseJson(getData("[-j]/monitors")).to(seq[Monitor])
|
||||||
|
defaultWorkspaces = getDefaultWorkspaces()
|
||||||
let defaultWorkspaces = getDefaultWorkspaces()
|
for m in monitors:
|
||||||
for monitor in monitors:
|
|
||||||
result.add defaultWorkspaces
|
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:
|
when isMainModule:
|
||||||
while true:
|
while true:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(defvar rofi-bin "~/.config/rofi/bin")
|
(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 clocktext :interval "10s" "date '+%d %b %I:%M %p'")
|
||||||
(defpoll bluetooth-icon :interval "5s" "bin/bluetooth.sh")
|
(defpoll bluetooth-icon :interval "5s" "bin/bluetooth.sh")
|
||||||
|
|
Loading…
Reference in a new issue