dotfiles/de/home/.config/eww/modules/bar/workspaces.yuck
2025-07-25 16:00:07 -07:00

102 lines
3.9 KiB
Text

(deflisten activeWorkspace :initial '1'
'scripts/bar/active-workspace')
(deflisten workspacesArray :initial '[{"name": "placeholder","focused":true,"num":0}]'
'scripts/bar/workspaces')
(defvar wsreveal false)
(defwidget workspaces [array]
(box :class "bar-module"
:space-evenly false
(button :class "profile"
:onclick 'sp-profiles next'
(label :text '${active_profile}'))
(box :class "chevron"
(transform :rotate 12.5
:translate-x '-35%'
:translate-y '30%'
:transform-origin-x '50%'
:transform-origin-y '50%'
(image :image-width 22
:image-height 22
:path 'icons/red_square.png')))
(eventbox
:onhover "${EWW_CMD} update wsreveal=true"
:onhoverlost "${EWW_CMD} update wsreveal=false"
(box :class "workspaces"
:orientation "h"
:space-evenly false
:halign "start"
(revealer
:class "ws-left"
:reveal wsreveal
:transition "slideleft"
:duration "500ms"
(box
(for entry in array
(literal
:visible {((entry.num <= activeWorkspace) && !entry.focused) ? true : false}
:content {((entry.num <= activeWorkspace) && !entry.focused) ? "(workspace :ws entry :side 'left')" : "(box :visible false)"}))))
(box
(for entry in array
(literal
:visible {entry.focused ? true : false}
:content {entry.focused ? "(workspace :ws entry :side 'center')" : "(box :visible false)"})))
(revealer
:class "ws-right"
:reveal wsreveal
:transition "slideright"
:duration "500ms"
(box
(for entry in array
(literal
:visible {((entry.num >= activeWorkspace) && !entry.focused) ? true : false}
:content {((entry.num >= activeWorkspace) && !entry.focused) ? "(workspace :ws entry :side 'right')" : "(box :visible false)"}))))))))
; (for entry in array
; {entry.focused ? (workspace :ws entry) : ""})))
; (for ws in {}
; (box
; (literal
; :visible {(entry.num < jq(array, '.. | select(.type?) | select(.focused==true).num', 'r')) ? true : false}
; :content {(entry.num < jq(array, '.. | select(.type?) | select(.focused==true).num', 'r')) ? "(workspace :ws entry)" : "(box :visible false)"})
; (literal
; :visible {entry.focused ? true : false}
; :content {entry.focused ? "(workspace :ws entry)" : "(box :visible false)"})
; (literal
; :visible {(entry.num > jq(array, '.. | select(.type?) | select(.focused==true).num')) ? true : false}
; :content {(entry.num > jq(array, '.. | select(.type?) | select(.focused==true).num')) ? "(workspace :ws entry)" : "(box :visible false)"})))))
;; {entry.focused ? "${entry.num}" : ""})))
; (button :onclick `swaymsg workspace "${entry.name}"`
; :class {entry.focused ? "focused" : ""}
; (box
; '${replace(entry.name,".*:","")}'
; (label
; :class "workspace-number"
; :text {jq(captures(entry.num, '[0-9]$'),'.[].[]','r')}))))))
(defwidget workspace [ws side]
(button :onclick `swaymsg workspace "${ws.name}"`
; :class {ws.focused ? "focused" : ""}
:class side
(box
'${replace(ws.name,".*:","")}'
(label
:class "workspace-number"
:text {jq(captures(ws.num, '[0-9]$'),'.[].[]','r')}))))
;(defwidget workspaces [array]
;(box :class "workspaces"
; :orientation "h"
; :space-evenly false
; :halign "start"
;
; (for entry in array
; (button :onclick `swaymsg workspace "${entry.name}"`
; :class {entry.focused ? "focused" : ""}
; (box
; '${replace(entry.name,".*:","")}'
; (label
; :class "workspace-number"
; :text {jq(captures(entry.num, '[0-9]$'),'.[].[]','r')}))))))