aboutsummaryrefslogtreecommitdiffstats
path: root/oni
diff options
context:
space:
mode:
authorGravatar Tom Willemse2023-10-12 20:56:47 -0700
committerGravatar Tom Willemse2023-10-12 20:56:47 -0700
commit7f3e524136c18bc5fe1292123ce3f03b84c2f0e8 (patch)
tree4e32fb55705e43360325bb9049c4715278ee6cdb /oni
parent934b8bbffa658a476916dab78896eed7cdc0145f (diff)
downloadnew-dotfiles-7f3e524136c18bc5fe1292123ce3f03b84c2f0e8.tar.gz
new-dotfiles-7f3e524136c18bc5fe1292123ce3f03b84c2f0e8.zip
Add a random note from my Roam database to the dashboard
Diffstat (limited to 'oni')
-rw-r--r--oni/home/config/rincewind.scm6
-rw-r--r--oni/home/services/emacs/oni-dashboard.el46
2 files changed, 51 insertions, 1 deletions
diff --git a/oni/home/config/rincewind.scm b/oni/home/config/rincewind.scm
index 14888fa..afaaaf1 100644
--- a/oni/home/config/rincewind.scm
+++ b/oni/home/config/rincewind.scm
@@ -425,7 +425,11 @@
(list
(local-file "../services/emacs/oni-helpful.el")))))
(service home-emacs-yasnippet-capf-service-type)
- (service home-emacs-dashboard-service-type)
+ (service home-emacs-dashboard-service-type
+ (home-emacs-dashboard-configuration
+ (configurations
+ (list
+ (local-file "../services/emacs/oni-dashboard.el")))))
(service home-emacs-eros-service-type)
(service home-emacs-ace-link-service-type
(home-emacs-ace-link-configuration
diff --git a/oni/home/services/emacs/oni-dashboard.el b/oni/home/services/emacs/oni-dashboard.el
new file mode 100644
index 0000000..a0a1767
--- /dev/null
+++ b/oni/home/services/emacs/oni-dashboard.el
@@ -0,0 +1,46 @@
+;;; oni-dashboard.el --- Customization for the dashboard module -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2023 Tom Willemse
+
+;; Author: Tom Willemse <tom@ryuslash.org>
+;; Keywords: local
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(defun oni-dashboard-insert-random-note (_)
+ "Insert a link to a random note from my Roam database."
+ (dashboard-insert-heading "Today's Note:" "n")
+ (insert "\n ")
+ (dashboard-insert-shortcut 'random-note "n" "Today's Note:")
+ (let ((element (seq-random-elt (org-roam-node-read--completions))))
+ (widget-create 'link
+ :notify (lambda (&rest _)
+ (find-file (org-roam-node-file (cdr element)))
+ (goto-char (org-roam-node-point (cdr element))))
+ :button-prefix ""
+ :button-suffix ""
+ (string-trim-right (car element)))))
+
+(require 'org-roam)
+(add-to-list 'dashboard-item-generators '(random-note . oni-dashboard-insert-random-note))
+(add-to-list 'dashboard-items '(random-note))
+
+(provide 'oni-dashboard)
+;;; oni-dashboard.el ends here