#!/bin/sh

sketchybar --set pomodoro popup.drawing=toggle \
                          popup.background.drawing=on \
                          popup.background.color="0xff363a4f" \
                          popup.background.corner_radius=3

STATUS=$(/usr/local/bin/pomodoro status)

if [ "$STATUS" = "" ]; then
  sketchybar --set focus icon="󰣉" \
                         label="Focus 50:00" \
                         icon.color="0xfff5bde6" \
                         label.color="0xfff5bde6" \
                         click_script="/usr/local/bin/pomodoro start --duration 50 && sketchybar --set pomodoro popup.drawing=toggle"
  sketchybar --set shortBreak icon="󱅻" \
                              label="Short Break 5:00" \
                              icon.color="0xffcad3f5" \
                              label.color="0xffcad3f5" \
                              click_script=""
  sketchybar --set longBreak icon="" \
                             label="Long Break 15:00" \
                             icon.color="0xffcad3f5" \
                             label.color="0xffcad3f5" \
                             click_script=""
elif /usr/local/bin/pomodoro status | grep -q "Break: ❗️"; then
  sketchybar --set focus icon="󰣉" \
                         label="Focus 50:00" \
                         icon.color="0xfff5bde6" \
                         label.color="0xfff5bde6" \
                         click_script="/usr/local/bin/pomodoro start --duration 50 && sketchybar --set pomodoro popup.drawing=toggle"
  sketchybar --set shortBreak icon="󱅻" \
                              label="Short Break 5:00" \
                              icon.color="0xffcad3f5" \
                              label.color="0xffcad3f5" \
                              click_script=""
  sketchybar --set longBreak icon="" \
                             label="Long Break 15:00" \
                             icon.color="0xffcad3f5" \
                             label.color="0xffcad3f5" \
                             click_script=""
elif /usr/local/bin/pomodoro status | grep -q "Pomodoro: ❗"; then
  sketchybar --set focus icon="󰣉" \
                         label="Focus 50:00" \
                         icon.color="0xffcad3f5" \
                         label.color="0xffcad3f5" \
                         click_script=""
  sketchybar --set shortBreak icon="󱅻" \
                              label="Short Break 5:00" \
                              icon.color="0xff91d7e3" \
                              label.color="0xff91d7e3" \
                              click_script="/usr/local/bin/pomodoro break && sketchybar --set pomodoro popup.drawing=toggle"
  sketchybar --set longBreak icon="" \
                             label="Long Break 15:00" \
                             icon.color="0xff91d7e3" \
                             label.color="0xff91d7e3" \
                             click_script="/usr/local/bin/pomodoro break -d 15 && sketchybar --set pomodoro popup.drawing=toggle"
else
  sketchybar --set focus icon="󰣉" \
                         label="Focus 50:00" \
                         icon.color="0xffcad3f5" \
                         label.color="0xffcad3f5" \
                         click_script=""
  sketchybar --set shortBreak icon="󱅻" \
                              label="Short Break 5:00" \
                              icon.color="0xffcad3f5" \
                              label.color="0xffcad3f5" \
                              click_script=""
  sketchybar --set longBreak icon="" \
                             label="Long Break 15:00" \
                             icon.color="0xffcad3f5" \
                             label.color="0xffcad3f5" \
                             click_script=""
fi
