(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 && scripts/powermenu-toggle)"
      (box
        :class "datetime"
        (overlay
          (box
            :orientation "v"
            (label :show-truncated false 
              :class "hour" 
              :text {time.hour})
            (label :show-truncated false
            :class "minute"
              :text {time.minute}))
          (revealer
            :reveal date_rev
            (box
              :class "date"
              :orientation "v"
              (label :show-truncated "false"
                :class "day"
                :text {time.day})
              (label :show-truncated "false"
                :class "month"
                :text {time.month}))
          )
        )
      )
    )
  )
)

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

