2024-10-07 21:57:33 +02:00
|
|
|
(deflisten timer_state :initial '{"pid": 0, "state": "inactive", "time": "00:00", "progress": 100000}' "~/.config/eww/scripts/timer")
|
2024-02-07 15:53:39 +01:00
|
|
|
|
|
|
|
(defwidget start-button []
|
|
|
|
(button
|
|
|
|
:class "start-button"
|
|
|
|
:vexpand true
|
2024-10-07 10:44:20 +02:00
|
|
|
:onclick "kill -10 ${timer_state.pid}"
|
2024-02-07 15:53:39 +01:00
|
|
|
(overlay
|
|
|
|
(circular-progress
|
|
|
|
:class "circle-progress"
|
2024-10-07 21:57:33 +02:00
|
|
|
:value "${timer_state.progress / 1000}"
|
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)
|
2024-10-07 10:44:20 +02:00
|
|
|
(label :class "start-icon" :text "${timer_state.state == "inactive" ? 'Start' : (timer_state.state == "work" ? "Working" : "Pause")}")
|
2024-02-07 15:53:39 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
(defwidget timer []
|
|
|
|
(box
|
|
|
|
:orientation "v"
|
|
|
|
:space-evenly false
|
2024-10-07 10:44:20 +02:00
|
|
|
:class "timer ${timer_state.state}"
|
2024-02-07 15:53:39 +01:00
|
|
|
(label :class "timer-title" :text "Grind timer")
|
|
|
|
(start-button :valign "center" :vexpand true)
|
|
|
|
(revealer
|
|
|
|
:transition "slideup"
|
2024-10-07 10:44:20 +02:00
|
|
|
:reveal {timer_state.state != "inactive"}
|
|
|
|
(label :class "timer-text" :text "${timer_state.time}")
|
2024-02-07 15:53:39 +01: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)
|
|
|
|
)
|