(defwidget powermenu_entry [label icon onclick]
    (box :orientation "v" :space-evenly false :class "powermenu-entry"
        (button :class "powermenu-button" :onclick {onclick}
            :tooltip "${label}"
            (label :class "powermenu-icon" :text {icon})
        )
    )
)

(defwidget powermenu []
    (box :orientation "h" :space-evenly true :valign "center" :halign "center" :class "powermenu-box"
        (powermenu_entry    :label "Power off" 
                            :icon "󰐥" 
                            :onclick "systemctl poweroff")
        (powermenu_entry    :label "Reboot" 
                            :icon "󰜉" 
                            :onclick "systemctl reboot")
        (powermenu_entry    :label "Lock" 
                            :icon "󰍁" 
                            :onclick "sleep 0.1 && gtklock & eww close powermenu &")

        (powermenu_entry    :label "Suspend" 
                            :icon "󰤄" 
                            :onclick "sleep 0.1 && gtklock & systemctl suspend & eww close powermenu &")
                                
        (powermenu_entry    :label "Sign out" 
                            :icon "󰗼" 
                            :onclick "hyprctl eval \"hl.dispatch(hl.dsp.exit())\"")

        (powermenu_entry    :label "Cancel" 
                            :icon "󰅖" 
                            :onclick "eww close powermenu")
    )
)

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