[Linux] Quick Capture using AutoKey

AutoKey is a Linux application that is very much similar to AutoHotKey. The below code can be used to launch a small popup window where you can quickly write/paste down information for later processing. You can also bind this script to any hotkey.

Just change INBOX_LOCATION to any markdown file in your vault. This is the file where the contents are appended.

# Capture info to inbox quickly 
import subprocess
import sys
from datetime import datetime
INBOX_LOCATION = "/path/to/vault/inbox.md"

dialog_op = dialog.input_dialog(title="Quick Capture", message="Enter anything")
if dialog_op[0] != 0:
    #subprocess.Popen(['notify-send',f"Error getting input."])
    sys.exit(0)
else:
    message = dialog_op[1]

today = datetime.today().strftime("%Y-%m-%d")
stored_date = store.get_global_value("date")

# if not same, write the H2 heading in the file and the append message
# else append the message alone
if today != stored_date:
    store.set_global_value("date", today)
    with open(INBOX_LOCATION, "a") as inbox:
        inbox.write(f"\n\n### {today}" + f"\n- {message}")
else:
    with open(INBOX_LOCATION, "a") as inbox:
        inbox.write(f"\n- {message}")
        
subprocess.Popen(['notify-send',f"Note captured!"])