summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-07-19 23:40:19 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-07-19 23:40:19 +0200
commit1908d77b12c6f78e0db9d674863108109377f553 (patch)
tree8445b952f557d2fef9a834bf4e6cb36302d75531
parent05b2322c1f0e26bdfdbbcdc6ef32a51fb06a7468 (diff)
Add cron opt to org mode
-rw-r--r--fnl/config/orgmode.fnl40
1 files changed, 36 insertions, 4 deletions
diff --git a/fnl/config/orgmode.fnl b/fnl/config/orgmode.fnl
index 0def299..96cd2e0 100644
--- a/fnl/config/orgmode.fnl
+++ b/fnl/config/orgmode.fnl
@@ -5,13 +5,45 @@
(nvim.ex.set :concealcursor=nc)
(def- templates
- {:t {:description :Task :template "* TODO %?\n %u\n DEADLINE: %T\n :TAGS:"}
+ {:t {:description :Task
+ :template "* TODO %?\n %u\n DEADLINE: %T\n :TAGS:"}
:m {:description :Meeting
:template "* MEETING %? :MEETING: :LOGBOOK: CLOCK: %U :END:"}
:n {:description :Note :template "* NOTE %? :NOTE:\n %u\n :TAGS:"}})
+(defn- create-title [task]
+ (string.format "%s (%s)" task.category task.humanized_duration))
+
+(defn- create-subtitle [task]
+ (string.format "%s %s %s" (string.rep "*" task.level) task.todo
+ task.title))
+
+(defn- get-date [task] (string.format "%s: %s" task.type (task.time:to_string)))
+
+(def- notifications
+ {:reminder_time [0 1 5 10]
+ :repeater_reminder_time [0 1 5 10]
+ :deadline_warning_reminder_time [0]
+ :cron_notifier (fn [tasks]
+ (each [_ task (ipairs tasks)]
+ (let [title (create-title task)
+ sub-title (create-subtitle task)
+ date (get-date task)]
+ (if (vim.fn.executable :notify-send)
+ (vim.loop.spawn :notify-send
+ {:args [:--icon=.local/share/nvim/site/pack/packer/start/orgmode/assets/orgmode_nvim.png
+ (string.format "%s\n%s\n%s"
+ title
+ subtitle
+ date)]})))))})
+
+(def- opts {:org_agenda_files ["~/.local/share/org/**/*"]
+ :org_hide_emphasis_markers true
+ :org_agenda_start_on_weekday false
+ :org_default_notes_file "~/.local/share/org/refile.org"
+ :org_agenda_templates templates
+ : notifications})
+
(let [orgmode (util.load-plugin :orgmode)]
(orgmode.setup_ts_grammar)
- (orgmode.setup {:org_agenda_files ["~/.local/share/org/**/*"]
- :org_default_notes_file "~/.local/share/org/refile.org"
- :org_agenda_templates templates}))
+ (orgmode.setup opts))