
(defwidget pm-btn [icon label onclick]
  (button :class "pm-btn" :onclick onclick
    (box :orientation "v" :space-evenly false :halign "center" :valign "center"
      (label :class "pm-icon" :text icon)
      (label :class "pm-label" :text label))))

(defwidget powermenu []
  (box :hexpand true :vexpand true :class "pm-overlay"
    (box :halign "center" :valign "center"
      (eventbox :class "winevent"
        (box :class "wininner pm-win"
          (box :orientation "h" :space-evenly true
            (pm-btn :icon "󰐥" :label "Power off"
                    :onclick "systemctl poweroff")
            (pm-btn :icon "󰜉" :label "Reboot"
                    :onclick "systemctl reboot")
            (pm-btn :icon "󰍁" :label "Lock"
                    :onclick "scripts/lock")
            (pm-btn :icon "󰤄" :label "Suspend"
                    :onclick "scripts/lock & systemctl suspend")
            (pm-btn :icon "󰗼" :label "Sign out"
                    :onclick "hyprctl eval \"hl.dispatch(hl.dsp.exit())\"")
            (pm-btn :icon "󰅖" :label "Cancel"
                    :onclick "eww close powermenu")))))))

(defwindow powermenu
  :monitor 0
  :stacking "overlay"
  :geometry (geometry
    :anchor "center"
    :width "120%"
    :height "120%")
  :namespace "eww-blur"
  (powermenu))
