(defvar battery_rev false) (defvar brightness_rev false) (defvar emails_rev false) (defvar keymap_rev false) (defvar user_rev false) (defvar volume_rev false) (defvar wireless_rev false) ;; Listeners (deflisten active-workspace `stdbuf -oL scripts/active-workspace-listener`) (deflisten workspace-list :initial '[[1]]' `stdbuf -oL scripts/workspace-list-listener`) (deflisten datetime `stdbuf -oL scripts/datetime-listener`) (deflisten brightness `stdbuf -oL scripts/backlight-listener`) (deflisten volume :initial '{"icon":"","percentage":""}' `stdbuf -oL scripts/volume-listener`) (deflisten keymap `stdbuf -oL scripts/keymap-listener`) (deflisten emails :initial '{"icon":"","text":""}' `stdbuf -oL scripts/email-listener`) ;; Pollers (defpoll user :interval "69h" `whoami | sed 's/.*/\\u&/'`) (defpoll battery :initial '{"icon":"","percentage":""}' :interval "1s" `scripts/battery`) (defpoll wireless :initial '{"icon":"","ssid":""}' :interval "1s" `scripts/wireless`) ;; Windows (defwindow bar-1 :monitor 0 :stacking "fg" :exclusive true :geometry (geometry :width "100%" :height "40px" :anchor "top center") (bar :monitor 0)) (defwindow bar-2 :monitor 1 :stacking "fg" :exclusive true :geometry (geometry :width "100%" :height "40px" :anchor "top center") (bar :monitor 1)) ;; Widgets (defwidget bar [monitor] (centerbox (start :monitor monitor) (middle) (end))) (defwidget start [monitor] (workspaces :monitor monitor)) (defwidget middle [] (clock)) (defwidget end [] (box :halign "end" :class "end" :space-evenly false (emails) (keymap) (wireless) (brightness) (volume) (battery) (user))) (defwidget workspaces [monitor] (box :class "workspaces" :space-evenly false (for id in {workspace-list[monitor]} (button :class {active-workspace[monitor] == id ? "active" : ""} :onclick `hyprctl dispatch workspace ${id}` id)))) (defwidget clock [] datetime) (defwidget wireless [] (eventbox :onhover "eww update wireless_rev=true" :onhoverlost "eww update wireless_rev=false" (box :vexpand false :hexpand false :space-evenly false :width 30 ; (label :text "") (label :text {wireless.icon}) (revealer :transition "slideright" :reveal wireless_rev :duration "350ms" (label :text {wireless.ssid}))))) (defwidget keymap [] (eventbox :onhover "eww update keymap_rev=true" :onhoverlost "eww update keymap_rev=false" (box :vexpand false :hexpand false :space-evenly false :width 30 (label :text "") (revealer :transition "slideright" :reveal keymap_rev :duration "350ms" (label :text keymap))))) (defwidget brightness [] (eventbox :onhover "eww update brightness_rev=true" :onhoverlost "eww update brightness_rev=false" (box :vexpand false :hexpand false :space-evenly false :width 30 (label :text "") (revealer :transition "slideright" :reveal brightness_rev :duration "350ms" (label :text brightness))))) (defwidget volume [] (eventbox :onhover "eww update volume_rev=true" :onhoverlost "eww update volume_rev=false" (box :vexpand false :hexpand false :space-evenly false :width 30 (label :text {volume.icon}) (revealer :transition "slideright" :reveal volume_rev :duration "350ms" (label :text {volume.percentage}))))) (defwidget battery [] (eventbox :onhover "eww update battery_rev=true" :onhoverlost "eww update battery_rev=false" (box :vexpand false :hexpand false :space-evenly false :width 30 (label :text {battery.icon}) (revealer :transition "slideright" :reveal battery_rev :duration "350ms" (label :text {battery.percentage}))))) (defwidget emails [] (eventbox :onhover "eww update emails_rev=true" :onhoverlost "eww update emails_rev=false" (box :vexpand false :hexpand false :space-evenly false :width 30 (label :text {emails.icon}) (revealer :transition "slideright" :reveal emails_rev :duration "350ms" (label :text {emails.text}))))) (defwidget user [] (eventbox :onhover "eww update user_rev=true" :onhoverlost "eww update user_rev=false" (box :vexpand false :hexpand false :space-evenly false :width 30 (label :text "") (revealer :transition "slideright" :reveal user_rev :duration "350ms" (label :text user))))) (defwidget pair [icon text] (box :width 70 :space-evenly false (label :text icon) (label :text text)))