nftable-migration
 1;; From http://www.howardism.org/Technical/Emacs/focused-work.html
 2;; Write something a bit similar, but better ?
 3
 4(defvar vde/focus-timer nil "A timer reference for the vde/focus functions")
 5
 6(defun vde/focus-countdown-timer (minutes fun)
 7  (let ((the-future (* minutes 60)))
 8    (run-at-time the-future nil fun)))
 9
10(defun vde/focus-begin ()
11  "Start a concerted, focused effort, ala Pomodoro Technique.
12We first clock into the current org-mode header (or last one),
13start some music to indicate we are working, and set a timer.
14
15Call `ha-focus-break' when finished."
16  (interactive)
17  (vde/focus-countdown-timer 25 'vde/focus-break)
18  (vde/focus--command "playerctl play-pause")
19  (vde/focus--command "notify-send 'Let's focus.'")
20  (vde/focus--command "swaync-client -d")
21  (if (eq major-mode 'org-mode)
22      (org-clock-in)
23    (org-clock-in-last)))
24
25(defun vde/focus-break ()
26  "Stop the focused time by stopping the music.
27This also starts another break timer, that calls
28`ha-focus-break-over' when finished."
29  (interactive)
30  (vde/focus-countdown-timer 5 'vde/focus-break-over)
31  (vde/focus--command "swaync-client -d")
32  (vde/focus--command "notify-send 'Let's take a break.'")
33  (vde/focus--command "playerctl play-pause")
34  (org-clock-out)
35  (message "Time to take a break."))
36
37(defun vde/focus-break-over ()
38  "Message me to know that the break time is over. Notice that
39this doesn't start anything automatically, as I may have simply
40wandered off."
41  (vde/focus--command "notify-send 'Break is over.'"))
42
43(defun vde/focus--command (command)
44  "Runs COMMAND by passing to the `command' command asynchronously."
45  (async-start-process "focus-os" "zsh" 'vde/focus--command-callback "-c" command))
46
47(defun vde/focus--command-callback (proc)
48  "Asynchronously called when the `osascript' process finishes."
49  (message "Finished calling command."))