Inspired by Shortcut Obsidian's file in desktop, here is a way to have a desktop shortcut that creates a new date- and time-stamped note in your vault’s “Inbox”. This is for Linux users, but maybe it also works on MacOS (someone to try?).
Note: You must have xdg-open
on your system for this to work. My Linux Mint has it. (Hint: Try xdg-open --help
in a terminal.)
First, create a new .desktop
file on your desktop, using a text editor. Let’s call it Quicknote.desktop
.
[Desktop Entry]
Name=New Inbox Note
Exec=sh -c 'xdg-open "obsidian://new?vault=Schreiben&file=+Inbox/$(date +"%%Y-%%m-%%d %%H.%%M").md"'
Comment=Creates a new date/time-stamped inbox note in Obsidian
Terminal=false
Icon=obsidian
Type=Application
My vault is called Schreiben
, and my Inbox folder +Inbox
. Replace these with yours in the Exec=
line in above file. I use a date/time format of YYYY-MM-DD HH.MM
since a colon :
isn’t allowed on Mac and Windows machines.
You should now get a new icon (or “starter”) on your desktop that looks like this:
Double-clicking it should open Obsidian and create a new file in your vault’s “Inbox” folder:
Easy and useful.
Note: If this fails, it might be that the obsidian:
protocol isn’t registered correctly in your system. This sometimes happens when using the .AppImage
version of Obsidian, and not creating a correct .desktop
file for it. See Meta Post - Linux tips, tricks & solutions to common problems - #8 by Moonbase59
Notes for the curious
- Change the name by editing the
Name=
line, or by simply right-clicking the icon on the desktop and renaming it.
- If needed, you could also use
bash
instead of sh
in the Exec=
line.
- You cannot leave out the shell chain in the
Exec=
line, because otherwise the date
command wouldn’t be executed.
- The
date
command needs double percent signs %%
(not like in the terminal) because the percent sign has a special meaning in desktop files and must be escaped.
- The
date
command needs the apostrophes "
around the format string because it can contain blanks.
- Use
man date
or date --help
to find out more about the available format options.
Have fun making your own Obsidian desktop starters!
5 Likes
Since this desktop file would not work on Windows, I created a small [quickly hacked] node.js script. Basically you’d need to create 2 files, 3 if you want to assign a system wide keyboard shortcut (in which case you create a link to the *.vbs file and assign the desire shortcut).
Steps »
- note that both files require you to find your paths, your vault name, the folder withing the vault (currently set to +Inbox), etc.
- create file note.js (name as you wish, contents below)
- create file new-note.vbs (name as you wish, contents below)
- run new-note.vbs which will run ‘node note.js’ in the background w/out opening the Node output window
- [optional extra] create a Shortcut to the *.vbs file and assign a keyboard shortcut to it to have system wide hotkey that opens Obsidian ready to go w/ a timestamped note
Basically the node script creates a filesystem friendly timestamp, and launches Obsidian with the new file switch giving the file the datestamped name (using the syntax of the Exec command from this original post ).
You can easily change or add to the name which is focused when Obsidian opens. Am trying to emulate some classic Tomboy Notes type functionality…
note.js
let now = new Date();
let year = now.getFullYear();
let month = String(now.getMonth() + 1).padStart(2, '0');
let day = String(now.getDate()).padStart(2, '0');
let hour = String(now.getHours()).padStart(2, '0');
let minute = String(now.getMinutes()).padStart(2, '0');
let second = String(now.getSeconds()).padStart(2, '0');
let datestamp = `${year}-${month}-${day}_${hour}.${minute}.${second}`;
// console.log(datestamp);
let cmdPath = 'start C:\\Users\\[your-username]\\\AppData\\Local\\Obsidian\\Obsidian.exe';
let command = `${cmdPath} "obsidian://new?vault=obsidian-vault&file=+Inbox/${datestamp}.md"`;
// console.log(command);
var exec = require('child_process').exec;
exec(`START /B C:\\Users\\[your-username]\\AppData\\Local\\Obsidian\\Obsidian.exe "obsidian://new?vault=obsidian-vault&file=+Inbox/${datestamp}.md"`, function (err, stdout, stderr) {
if (err) {
throw err;
}
})
new-note.vbs
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.CurrentDirectory = "C:\Users\[your-username]\\bin\"
objShell.Run("""node"" note.js"), 0
Set objShell = Nothing