-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06_script_obsidian.html
More file actions
329 lines (278 loc) · 13 KB
/
Copy path06_script_obsidian.html
File metadata and controls
329 lines (278 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="description" content="obsidian script using dmenu" />
<meta name="author" content="Leo Castro" />
<title>dotfiles setup</title>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-49S4JFVG49"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-49S4JFVG49');
</script>
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<!-- Google Font -->
<link
href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<!-- Bootstrap Icons -->
<link
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css"
rel="stylesheet"
/>
<!-- Core Theme CSS (includes Bootstrap) -->
<link href="css/styles.css" rel="stylesheet" />
<link href="css/dark.css" rel="stylesheet" />
<link href="css/custom.css" rel="stylesheet" />
<!-- Syntax Highlighting Theme -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark-dimmed.min.css"
/>
<style>
/* Inline hyperlinks (purple, bold, no underline) */
p a {
text-decoration: none !important;
font-weight: 700;
color: #9b2dd1;
}
p a:hover {
text-decoration: none !important;
opacity: 0.85;
}
/* Highlight.js comment color (bash)*/
.hljs-comment,
.hljs-quote {
color: #53b7ff !important;
}
/* Paragraph spacing */
p {
line-height: 1.65;
}
/* Code block styling */
.code-box pre {
background-color: #1b263b; /* navy background */
color: #f8f9fa; /* light text */
border-left: 4px solid #9b2dd1; /* purple accent */
padding: 0rem 1rem; /* vertical fixed by line-height */
border-radius: 10px;
font-size: 0.95rem;
line-height: 1.3;
overflow-x: auto;
box-shadow: 0 2px 8px rgba(0,0,0,0.15); /* soft depth */
}
.code-box code {
background-color: transparent;
color: inherit; /* keep syntax highlighting */
font-family: "Fira Code", monospace;
}
</style>
</head>
<body class="d-flex flex-column h-100 bg-light">
<main class="flex-shrink-0">
<!-- NAVBAR -->
<nav class="navbar navbar-expand-lg navbar-dark bg-white py-3">
<div class="container px-5">
<a class="navbar-brand" href="index.html">
<span class="fw-bolder navbar-brand-name">Leo Castro</span>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-expanded="false">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0 small fw-bolder">
<li class="nav-item">
<a class="nav-link" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="projects.html">Projects</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<section class="py-5 project-article">
<div class="container px-5">
<h1 class="fw-bold text-center mb-4" style="color:#9b2dd1;">Automating the Flow of Information</h1>
<!-- Project Card -->
<div class="row gx-5 justify-content-center">
<div class="col-lg-12 col-xl-10">
<div class="article-content">
<!-- Article Meta. Everything below is now counted for word count -->
<div class="article-meta">
<div id="article-date">30 January 2026</div>
<div>
<span id="article-word-count"></span>
·
<span id="article-reading-time"></span>
</div>
</div>
<br>
<p>
I'm typically not the person to make New Year's resolutions, especially regarding career goals. I usually keep goals in my head, but there is no accountability if they're not written down somewhere. This year, I decided to change that. Three months ago, I joined KubeCraft and began implementing the <a href="https://en.wikipedia.org/wiki/Zettelkasten" target="_blank" rel="noopener noreferrer">Zettelkasten</a> system, a method for intentional note-taking and knowledge linking.
<p>
<p>
When I started Kubecraft, I was taking daily notes, but that went out the window 2-3 weeks later. Building a habit is tough. While completing the Arch Linux module, I found myself with scattered Obsidian notes on both my phone and laptop. Keeping my instructions updated became a nightmare as I tweaked my Arch system. I was also failing to track my goals or even how to tackle the modules within a given timeframe. Creating daily, weekly, or monthly notes felt cumbersome. My pure laziness is what got in the way of building a habit.
</p>
<p>
Since dmenu is my menu of choice on Arch, I decided to create a script to initiate a new note via a keyboard shortcut. Inspired by <a href="https://youtu.be/h_E3ddNQ1xw?si=Qssolm_QTFEiDITOX" target="_blank" rel="noopener noreferrer">@BreadonPenguins</a>, this script removes the friction of starting to write. While my script and folder structure will surely evolve, I've been using this shortcut seamlessly for nearly a month. I value Obsidian for its simple vault interface, interactive graph, Excalidraw, and Kanban plugin, but my actual writing stays in Neovim.
</p>
<div class="card-body text-start">
<h4 class="fw-bold">Directory Structure</h4>
<p>
My current structure has changed several times, but this layout is working well.
<ul>
<li><b>input</b>: internal note-taking</li>
<li><b>output</b>: projects or blogs for sharing </li>
<li><b>journal</b>: daily logs and reflections</li>
<li><b>weekly_goals & monthly_goals</b>: goal tracking</li>
<li><b>Excalidraw</b>: visual brainstorming and drawings</li>
<li><b>Kanban</b>: active, work-in progress</li>
</ul>
</p>
<!--Image below text-->
<div class="my-4">
<img src="assets/06_obsidian_script/dmenu_obsidian.png"
alt="dmenu script showing folders"
class="img-fluid w-100 rounded">
</div>
</div>
<div class="card-body text-start">
<h4 class="fw-bold">Setting the Stage</h4>
<p>
Every script starts with a <i>shebang</i>. Use <code>#!/bin/bash</code> to avoid path hijacking associated with <code>#!/usr/bin/env bash</code>. To keep the script portable, I defined variables for my paths and tools. If I switch terminal emulators or move my vault path, I only have to change a line.
</p>
</div>
<div class="code-box mb-4">
<pre><code class="language-bash">
#!/bin/bash
folder=$HOME/obsidian/
FONT="Monospace:size=13"
TERMINAL="alacritty"
</code></pre>
</div>
<h4 class="fw-bold">Smart Folders</h4>
<p>
Filtering my subfolders was the key to making this script usable. Without filtering, dmenu would output every single directory in my vault. Instead, I used <code>find</code> to crawl the <code>$folder</code> and hide the root folders, 2025 folders, and any hidden files.
</p>
<div class="code-box mb-4">
<pre><code class="language-bash">
choice=$(cd "$folder" && find . -mindepth 1 -type d \
-not -path '*/.*' \
-regextype posix-extended \
-not -regex ".*(0_input|1_output|1_output/neovim|3_weekly_goals/2025|4_monthly_goals/2025)" \
-not -regex ".*/3_weekly_goals$" \
-not -regex ".*/4_monthly_goals$" | \
sort | dmenu -fn "$FONT" -l 25 -i -p "Select Category: ") || exit 0
</code></pre>
<p>
A breakdown of the logic:
<ul>
<li><b>find "$folder"</b>: scan the vault path</li>
<li><b>-mindepth 1</b>: omit the root folder and only include subfolders</li>
<li><b>-type d</b>: filter for directories only</li>
</ul>
<ul>
<li><b>-not -path '*/.*'</b>: hide hidden directories (<code>.obsidian</code>)</li>
<li><b>-regextype posix-extended</b>: enable regex to group multiple folders</li>
<li><b>-not -regex "..."</b>: act as an "ignore list" to keep the menu focused on active categories</li>
</ul>
<ul>
<li><b>dmenu</b>: Take the filtered list and turn it into a searchable, top-bar menu that is sorted and case-insensitive.</li>
</ul>
</div>
<h4 class="fw-bold">Template Automation</h4>
<p>
After selecting a folder, the script ensures that the path is valid. If it isn't, the script exits. Once a valid folder is selected, it prompts for a note name. If left blank, the script defaults to a timestamp for the filename. The script then injects a YAML frontmatter (title, date, and tags) using a Heredoc. This metadata is used by Obsidian’s dataview plugin and graph analysis. The <code>.md</code> extension is appended automatically.
</p>
<div class="code-box mb-4">
<pre><code class="language-bash">
name=$(echo "" | dmenu -fn "$FONT" -p "New Note Name: " <&-) || exit 0
: "${name:=$(date +%F_%H%M)}"
full_path="${dir}${name}.md"
# Only add frontmatter if the file does not exist or is empty. Use a Heredoc
if [ ! -s "$full_path" ]; then
cat <<EOF > "$full_path"
...
</code></pre>
</div>
<div class="card-body text-start">
<h4 class="fw-bold">Shellcheck and Keybinding</h4>
<p>
The end of the Bash code launches a new terminal instance and detaches it from the script process. If the file is saved, it's created, otherwise <code>:q</code> will discard the note. I used <code>shellcheck</code> to verify the script's logic and <code>chmod +x</code> to make it executable. Lastly, I created a keybinding in my <code>hyprland.conf</code>. The Zettelkasten method is now literally at my fingertips by pressing, <code>SUPER + N</code>.
</p>
<div class="code-box mb-4">
<pre><code class="language-bash">
bind = $mainMod, N, exec, ~/.local/bin/script_menu_obsidian
</code></pre>
</div>
<div class="card-body text-start">
<h4 class="fw-bold">The View Ahead</h4>
<p>
Having just finished the Linux Foundations module, this was a very practical exercise. Since this is only my second script, I used Gemini to bridge a few technical gaps, but the real progress happened through several days of trial and error to fit my specific needs. My New Year's resolution is still going strong as January has come to an end and the friction of note-taking is officially gone. Now I get to watch my Obsidian graph view grow and visualize the relationship between the notes in my vault. Most importantly, I finally have a system in place to hold myself accountable for my 2026 goals.
</p>
<p>
<a href="https://github.com/castro-ux/lab/blob/main/script_menu_obsidian" target="_blank" rel="noopener noreferrer">[Click here for the full script]</a>
</p>
</div>
</div> <!-- END article-content -->
<!-- Clearfix to push button below floated image -->
<div class="clearfix"></div>
</div>
<!-- Back Button pushed below everything -->
<div class="text-center mt-5 pb-4">
<a class="btn-back" href="projects.html">
← Back to Projects
</a>
</div>
</div>
</main>
<!-- FOOTER -->
<footer class="py-2" style="background-color: transparent;">
<div class="container px-5 text-center">
<div class="mb-2">
<a class="small footer-link" href="index.html">Home</a>
<span class="mx-2">·</span>
<a class="small footer-link" href="projects.html">Projects</a>
<span class="mx-2">·</span>
<a class="small footer-link" href="contact.html">Contact</a>
</div>
<div class="small text-white copyright">© Castro 2026</div>
</div>
</footer>
<!-- Scripts -->
<script>
document.addEventListener("DOMContentLoaded", function () {
// 1. Get article text
const articleText = document.querySelector(".article-content").innerText;
// 2. Count words
const wordCount = articleText.trim().split(/\s+/).length;
// 3. Reading time (average 200 words/min)
const readingTime = Math.ceil(wordCount / 200);
// 4. Insert values into the page
document.getElementById("article-reading-time").textContent =
`${readingTime} min read`;
document.getElementById("article-word-count").textContent =
`${wordCount} words`;
});
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
<script src="js/scripts.js"></script>
</body>
</html>