From 3c5f3155ebe45f64a9894a648328df6b9d6eb1c8 Mon Sep 17 00:00:00 2001 From: fz0x1 Date: Tue, 6 May 2025 15:06:01 +0200 Subject: [PATCH] 20250506.1746536761 --- global/.config/doom/config.el | 32 +++++++++++++------ global/.zshrc | 2 ++ global/scripts/bin/diary.py | 60 +++++++++++++++++++++++++++++++---- 3 files changed, 77 insertions(+), 17 deletions(-) diff --git a/global/.config/doom/config.el b/global/.config/doom/config.el index cbdc747..2443a8a 100644 --- a/global/.config/doom/config.el +++ b/global/.config/doom/config.el @@ -357,21 +357,33 @@ PRIORITY may be one of the characters ?A, ?B, or ?C." ;; View 7 days in the calendar view ((agenda "" ((org-agenda-span 7))) - ;; Display items with priority A + + (tags-todo "+TODO=\"STRT\"" + ((org-agenda-overriding-header "All started tasks (STRT)"))) + + ;; ------------------ Priority A ------------------ (tags "PRIORITY=\"A\"" - ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) - (org-agenda-overriding-header "High-priority unfinished tasks:"))) + ((org-agenda-skip-function + '(or (org-agenda-skip-entry-if 'todo 'done) + (org-agenda-skip-entry-if 'todo '("STRT" "HOLD")))) + (org-agenda-overriding-header "High‑priority unfinished tasks:"))) - - ;; Display items with priority B (really it is view all items minus A & C) + ;; ------------------ Priority B ------------------ (tags "PRIORITY=\"B\"" - ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) - (org-agenda-overriding-header "ALL normal priority tasks:"))) + ((org-agenda-skip-function + '(or (org-agenda-skip-entry-if 'todo 'done) + (org-agenda-skip-entry-if 'todo '("STRT" "HOLD")))) + (org-agenda-overriding-header "ALL normal‑priority tasks:"))) - ;; Display items with pirority C + ;; ------------------ Priority C ------------------ (tags "PRIORITY=\"C\"" - ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done)) - (org-agenda-overriding-header "Low-priority Unfinished tasks:"))) + ((org-agenda-skip-function + '(or (org-agenda-skip-entry-if 'todo 'done) + (org-agenda-skip-entry-if 'todo '("STRT" "HOLD")))) + (org-agenda-overriding-header "Low‑priority unfinished tasks:"))) + + (tags-todo "+TODO=\"HOLD\"" + ((org-agenda-overriding-header "All holded tasks (HOLD)"))) ) ;; Don't compress things (change to suite your tastes) diff --git a/global/.zshrc b/global/.zshrc index 9eacc47..bc0feb9 100644 --- a/global/.zshrc +++ b/global/.zshrc @@ -129,6 +129,8 @@ alias dib="diary.py insert ${DIARY:?} bulk" alias dis=" diary_string" alias dit="diary.py doctor ${DIARY:?}" alias jrnlc="jrnl --encrypt" +# vifm +alias fm="vifmrun" # bindkeys ## autosuggest diff --git a/global/scripts/bin/diary.py b/global/scripts/bin/diary.py index 716c991..5e84722 100755 --- a/global/scripts/bin/diary.py +++ b/global/scripts/bin/diary.py @@ -62,6 +62,22 @@ class Config: Config.validate() +def daytime(dt: datetime): + hour = int(dt.strftime("%I")) + + am_pm = dt.strftime("%p") # "AM"/"PM" + + part_of_day = "none" + + if am_pm == "AM": + if 5 <= hour < 12: + part_of_day = "morning" + elif 12 <= hour < 5: + part_of_day = "night" + + return part_of_day + + def make_logger(): logging.basicConfig( level=logging.INFO, @@ -104,13 +120,16 @@ def find_closest_entry(data, target_timestamp: int): ) -def convert_diary_date(date_str): +def convert_diary_date(date_str, to_str: bool = True): try: - return ( + dt = ( datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%SZ") .replace(tzinfo=ZoneInfo("UTC")) .astimezone(TZ) - ).strftime("%d %b %Y at %H:%M:%S:") + ) + if to_str: + return dt.strftime("%d %b %Y at %H:%M:%S:") + return dt except ValueError: return None @@ -569,9 +588,15 @@ def export(): ) try: + diary_datetime = convert_diary_date(create_time) + daytime_tag = daytime(convert_diary_date(create_time, False)) + + if daytime_tag != "none": + content += f"\n@{daytime_tag}" + content = shlex.quote(content) subprocess.run( - f'printf "%s %b" "{convert_diary_date(create_time)}" {content} | jrnl {diary_name}', + f'printf "%s %b" "{diary_datetime}" {content} | jrnl {diary_name}', shell=True, capture_output=True, text=True, @@ -629,13 +654,24 @@ def insert(): """ Inserting a string from the terminal """ - content = shlex.quote(sys.argv[4]) + + diary_datetime = convert_diary_date(datenow_timestamp) + daytime_tag = daytime(convert_diary_date(datenow_timestamp, False)) + + content = sys.argv[4] + + # inserting daytime tag + if daytime_tag != "none": + content += f"\n@{daytime_tag}" + + content = shlex.quote(content) + if not content: print("There is no text") sys.exit(1) try: subprocess.run( - f'printf "%s %s" "{convert_diary_date(datenow_timestamp)}" {content} | jrnl {diary_name}', + f'printf "%s %s" "{diary_datetime}" {content} | jrnl {diary_name}', shell=True, capture_output=True, text=True, @@ -658,11 +694,21 @@ def insert(): subprocess.run(["nvim", temp_file_path], text=True, check=True) with open(temp_file_path, "r") as file: + diary_datetime = convert_diary_date(datenow_timestamp) + daytime_tag = daytime(diary_datetime) + + content = file.read() + + # inserting daytime tag + if daytime_tag != "none": + content += f"\n@{daytime_tag}" + content = shlex.quote(file.read()) + if hash != make_hash(temp_file_path): try: subprocess.run( - f'printf "%s %s" "{convert_diary_date(datenow_timestamp)}" {content} | jrnl {diary_name}', + f'printf "%s %s" "{diary_datetime}" {content} | jrnl {diary_name}', shell=True, capture_output=True, text=True,