(defwidget workspaces_button []
  (eventbox 
    :onscroll "${setworkspace_cmd} {} ${workspace_active} ${workspace_total}"
    :onclick "hyprctl dispatch workspace ${workspace_total + 1}"
    (box :class "workspace_button"
    "${workspace_active}/${workspace_total}")))

(defpoll workspace_total :interval "1s" "hyprctl workspaces | grep ID | awk 'BEGIN{max=0}{if(($3)>max)  max=($3)}END {print max}'")
(defpoll workspace_active :interval "1s" "hyprctl activeworkspace | grep ID | awk 'END {print $3}'")

(defvar setworkspace_cmd "widgets/workspaces/setworkspace")
