(defvar date_rev false)

(defwidget clock-mod []
  (module
    (eventbox
      :onhover "${EWW_CMD} update date_rev=true"
      :onhoverlost "${EWW_CMD} update date_rev=false"
      :onclick "(sleep 0.1 && scripts/panel-toggle clock)"
      :onrightclick "(sleep 0.1 && eww-open-on-current-screen powermenu --toggle)"
      (box
        :class "datetime"
        (overlay
          (box
            :orientation "v"
            (label :show-truncated false 
              :class "hour" 
              :text {hour})
            (label :show-truncated false
            :class "minute"
              :text {minute}))
          (revealer
            :reveal date_rev
            (box
              :class "date"
              :orientation "v"
              (label :show-truncated "false" 
                :class "day"
                :text {day})
              (label :show-truncated "false"
                :class "month" 
                :text {month}))
          )
        )
      )
    )
  )
)

(defpoll hour	:interval "15s"	"date '+%H'")
(defpoll minute	:interval "15s"	"date '+%M'")
(defpoll day	:interval "15s"	"date '+%d'")
(defpoll month	:interval "15s"	"date '+%m'")
