2024-02-07 15:53:39 +01:00
|
|
|
(defvar WORK_TIME_SEC 1200)
|
|
|
|
(defvar PAUSE_TIME_SEC 300)
|
|
|
|
|
|
|
|
(defvar timer-state "inactive")
|
|
|
|
(defvar timer-start-time 0)
|
|
|
|
|
|
|
|
(defpoll timer-time
|
2024-08-19 21:16:01 +02:00
|
|
|
:interval "900ms"
|
2024-02-07 15:53:39 +01:00
|
|
|
:run-while {timer-state != "inactive"}
|
|
|
|
`date +%s`)
|
|
|
|
|
|
|
|
(defpoll timer-work-period
|
|
|
|
:interval "20m"
|
|
|
|
:initial "first"
|
|
|
|
:run-while {timer-state == "work"}
|
|
|
|
`if [ "$(eww get timer-work-period)" == "first" ]; then
|
|
|
|
eww update timer-start-time=$(date +%s)
|
|
|
|
echo next
|
|
|
|
else
|
2024-03-09 11:47:34 +01:00
|
|
|
notify-send -c grind-timer -i ~/Images/Icons/moai.jpg "Work period over" "You can take a little nap now."
|
2024-08-19 21:16:01 +02:00
|
|
|
eww update timer-state=pause timer-pause-period=first
|
|
|
|
echo final
|
2024-02-07 15:53:39 +01:00
|
|
|
fi`) ; TODO: Put in a separate script
|
|
|
|
|
|
|
|
(defpoll timer-pause-period
|
|
|
|
:interval "5m"
|
|
|
|
:initial "first"
|
|
|
|
:run-while {timer-state == "pause"}
|
|
|
|
`if [ "$(eww get timer-pause-period)" == "first" ]; then
|
|
|
|
eww update timer-start-time=$(date +%s)
|
|
|
|
echo next
|
|
|
|
else
|
2024-03-09 11:47:34 +01:00
|
|
|
notify-send -c grind-timer -i ~/Images/Icons/moai.jpg "Pause period over" "Back to grinding we go."
|
2024-08-19 21:16:01 +02:00
|
|
|
eww update timer-state=work timer-work-period=first
|
|
|
|
echo final
|
2024-02-07 15:53:39 +01:00
|
|
|
fi`) ; TODO: Put in a separate script
|
|
|
|
|
|
|
|
(defwidget start-button []
|
|
|
|
(button
|
|
|
|
:class "start-button"
|
|
|
|
:vexpand true
|
|
|
|
:onclick "eww update timer-state=${timer-state == "inactive" ? "work" : "inactive"} timer-work-period=first timer-pause-period=first"
|
|
|
|
(overlay
|
|
|
|
(circular-progress
|
|
|
|
:class "circle-progress"
|
2024-02-16 15:09:42 +01:00
|
|
|
:value "${
|
|
|
|
timer-state == "inactive" ? 100 :
|
|
|
|
100 * (timer-start-time + (timer-state == "work" ? WORK_TIME_SEC : PAUSE_TIME_SEC) - timer-time)
|
|
|
|
/ (timer-state == "work" ? WORK_TIME_SEC : PAUSE_TIME_SEC)
|
|
|
|
}"
|
2024-02-07 15:53:39 +01:00
|
|
|
:thickness 6
|
2024-02-16 15:09:42 +01:00
|
|
|
:start-at 75
|
2024-02-07 15:53:39 +01:00
|
|
|
:clockwise true)
|
|
|
|
(label :class "start-icon" :text "${timer-state == "inactive" ? 'Start' : (timer-state == "work" ? "Working" : "Pause")}")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
(defwidget timer []
|
|
|
|
(box
|
|
|
|
:orientation "v"
|
|
|
|
:space-evenly false
|
|
|
|
:class "timer ${timer-state}"
|
|
|
|
(label :class "timer-title" :text "Grind timer")
|
|
|
|
(start-button :valign "center" :vexpand true)
|
|
|
|
(revealer
|
|
|
|
:transition "slideup"
|
|
|
|
:reveal {timer-state != "inactive"}
|
|
|
|
(label :class "timer-text" :text "${timer-state != "inactive" ? formattime(timer-start-time - (3600 - (timer-state == "work" ? WORK_TIME_SEC : PAUSE_TIME_SEC)) - timer-time, "%H:%M:%S") : "00:20:00"}")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(defwindow timer
|
|
|
|
:namespace "eww.timer"
|
|
|
|
:monitor 0
|
|
|
|
:geometry (geometry
|
2024-03-21 10:14:51 +01:00
|
|
|
:x "128px"
|
|
|
|
:y "128px"
|
2024-02-07 15:53:39 +01:00
|
|
|
:width "300px"
|
|
|
|
:height "350px"
|
|
|
|
:anchor "top left")
|
|
|
|
:stacking "bg"
|
|
|
|
:focusable false
|
|
|
|
:exclusive true
|
|
|
|
(timer)
|
|
|
|
)
|