(defwindow mainbar :monitor 0 :geometry (geometry :x "0%" :y "0%" :width "100%" :height "30px" :anchor "top center") :stacking "fg" :exclusive false :focusable false (bar)) (defvar time-extended false) ; for :run-while property of below variable ; when this turns true, the polling starts and ; var gets updated with given interval (defpoll ptime :interval "1s" :run-while !time-extended `date +%H:%M`) (defpoll petimea :interval "1s" :run-while time-extended `date "+%A, %d %B %Y "`) (defpoll petimeb :interval "1s" :run-while time-extended `date "+:%S"`) (deflisten ltitle "./scripts/title.sh") (defwidget bar [] (eventbox :onscroll "./scripts/scroll.sh {}" (centerbox :orientation "h" :class "bar" (workspaces) (title) (time)))) (deflisten workspaces :initial "[]" "./scripts/workspaces.sh") (deflisten current_workspace :initial "1" "./scripts/active-workspace.sh") (defwidget workspaces [] (box :class "widget workspaces" :halign "start" :valign "center" :vexpand true :hexpand true (for workspace in workspaces (eventbox :cursor "hand" (button :class "${workspace.id == current_workspace ? "focused" : (workspace.windows > 0 ? "occupied" : "empty")}" :onclick "hyprctl dispatch workspace ${workspace.id}" "${workspace.id == current_workspace ? "" : (workspace.windows > 0 ? "" : "")}"))))) (defwidget title [] (literal :content ltitle)) (defwidget time_extension [text] (label :text text :class "extension")) (defwidget time [] (button :onclick `eww update time-extended=${time-extended ? "false" : "true"}` (box :orientation "horizontal" :space-evenly false :halign "end" :class "widget time" (time_extension :text {time-extended ? petimea : ""}) (label :text ptime :class "base") (time_extension :text {time-extended ? petimeb : ""}))))