File tree Expand file tree Collapse file tree 6 files changed +66
-8
lines changed
Expand file tree Collapse file tree 6 files changed +66
-8
lines changed Original file line number Diff line number Diff line change 2222 first)]
2323 {:current current :last last}))
2424
25- (defn start-new []
25+ (defn start-if-break []
2626 (let [current (:current (get-state ))]
2727 (if current
2828 (log/warn " Attempted to start-new pomodoro when current exists, doing nothing" )
3535 (notify/notify " Starting new pomodoro" )))
3636 (get-state )))
3737
38+ ; ; TODO write some kind of 'smart-toggle' logic in here
39+ ; ; e.g. if we're on a break, start the pomorodo
40+ ; ; e.g. if we're beyond 2x our 'break' time, stop the pomodoro
41+ ; ; e.g. if we're beyond 4/5x our 'break' time, start another one
42+ (defn start-pomodoro
43+ " Starts a pomodoro regardless of the current state."
44+ []
45+ (-> {:doctor/type :type/pomodoro
46+ :pomodoro/started-at (dt/now )
47+ :pomodoro/is-current true
48+ :pomodoro/id (random-uuid )}
49+ (db/transact ))
50+ (notify/notify " Starting new pomodoro" )
51+ (get-state ))
52+
3853(defn end-current []
3954 (let [{:keys [current]} (get-state )]
4055 (when current
4762
4863(comment
4964 (get-state )
50- (start-new )
65+ (start-if-break )
66+ (start-pomodoro )
5167 (end-current ))
5268
5369
70+
5471(defn clean-up-pomodoros []
5572 (->> (db/query '[:find (pull ?e [*])
5673 :where [?e :pomodoro/id _]])
Original file line number Diff line number Diff line change 1919(defn update-screenshots []
2020 (slurp (str (clawe.config/doctor-base-url ) " /screenshots/update" )))
2121
22+ (defn start-pomodoro []
23+ (slurp (str (clawe.config/doctor-base-url ) " /pomodoros/start" )))
24+
2225(defn rebuild-blog
2326 ([] (rebuild-blog nil ))
2427 ([_] (slurp (str (clawe.config/doctor-base-url ) " /blog/rebuild" ))))
Original file line number Diff line number Diff line change 133133 (install-zsh-tab-completion ))
134134
135135 ; ; Doom env refresh - probably a race-case here....
136- (tmux/fire {:tmux.fire/cmd " doom env"
137- :tmux.fire/session " dotfiles"
136+ (tmux/fire {:tmux.fire/cmd " doom env"
137+ :tmux.fire/session " dotfiles"
138138 :tmux.fire/directory " ~/dotfiles"
139139 })
140140 (emacs/fire " (doom/reload-env)" )
141141
142142 (clawe.doctor/update-topbar )
143+
144+ ; ; TODO move to 'smart-toggle' (or some other name)
145+ (clawe.doctor/start-pomodoro )
146+
143147 (log " Reload complete" )
144148
145149 (check-unit-tests )))
Original file line number Diff line number Diff line change 186186 (duration-since (parse-time-string " 2022-02-26_15:47:52-0500" )))
187187
188188(defn an-x-ago-ms
189- " Returns duration-ago as milliseconds."
189+ " Returns duration-ago as milliseconds.
190+ NOTE only useful for per-day units, not less than 1 day.
191+ "
190192 [duration]
191193 (-> (t/today )
192194 (t/at (t/midnight ))
193195 (t/<< duration)
194196 t/inst
195197 inst-ms))
196198
199+ ; ; TODO support and update note above
200+ ; ; (defn an-hour-ago-ms
201+ ; ; "Returns an-hour-ago as milliseconds."
202+ ; ; []
203+ ; ; (an-x-ago-ms (t/new-duration 1 :hours)))
204+
205+ ; ; (comment
206+ ; ; (an-hour-ago-ms))
207+
197208(defn a-week-ago-ms
198209 " Returns a-week-ago as milliseconds."
199210 []
Original file line number Diff line number Diff line change 2424 (string/starts-with? " /api/pomodoros" uri)
2525 (pomodoros/route req)
2626
27+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28+ ; ; clawe
29+
2730 (= uri " /reload" )
2831 (do
2932 (clawe.restart/reload )
3538 (topbar/push-topbar-metadata )
3639 {:status 200 :body " updated topbar" })
3740
41+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42+ ; ; screenshots/clips
43+
3844 (= uri " /screenshots/update" )
3945 (do
4046 (screenshots/ingest-screenshots )
4551 (clips/ingest-clips )
4652 {:status 200 :body " updated clips" })
4753
54+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
55+ ; ; pomodoros/todos
56+
57+ (= uri " /pomodoros/start" )
58+ (do
59+ (pomodoros/start-pomodoro )
60+ {:status 200 :body " starting new pomodoro" })
61+
4862 (= uri " /todos/update" )
4963 (do
5064 (todos/reingest-todos )
5165 {:status 200 :body " updated todos" })
5266
67+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
68+ ; ; blog
69+
5370 (= uri " /blog/rebuild" )
5471 (do
5572 ; ; TODO perhaps this should be non-blocking?
7188 (blog/restart-systems )
7289 {:status 200 :body " restarted blog systems" })
7390
91+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
92+ ; ; clawe rofi/mx
93+
7494 (= uri " /clawe-mx" )
7595 (do
7696 (clawe.mx/mx )
91111 (clawe.mx/mx-open )
92112 {:status 200 })
93113
114+ ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
115+ ; ; clawe toggle
116+
94117 (= uri " /clawe-toggle" )
95118 (do
96119 ; ; TODO handle query params/body
Original file line number Diff line number Diff line change 161161; ; pomodoros
162162; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
163163
164- (defhandler pomodoro-start-new []
165- (api.pomodoros/start-new )
164+ (defhandler pomodoro-start-if-break []
165+ (api.pomodoros/start-if-break )
166166 :ok )
167167
168168(defhandler pomodoro-end-current []
177177 :action/on-click #(pomodoro-end-current )
178178 :action/icon octicons/stop16}
179179 {:action/label " Start"
180- :action/on-click #(pomodoro-start-new )
180+ :action/on-click #(pomodoro-start-if-break )
181181 :action/icon octicons/play16})])))
182182
183183; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
You can’t perform that action at this time.
0 commit comments