commit 26ccf40797fca45bb83e77a487cd2d632abdfd92
parent 1fc79ad9f888b58ce1c159d3f3f13ff93f9aa1b1
Author: mtmn <miro@haravara.org>
Date: Sat, 18 Apr 2026 15:13:57 +0200
dotfiles: expand todomenu
Diffstat:
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/modules/mixins/dotfiles/bin/todomenu b/modules/mixins/dotfiles/bin/todomenu
@@ -6,6 +6,7 @@ TODO_FILE="$HOME/misc/notes/nota/todo.txt"
selected=$(awk '{
if (/^[0-9]{4}-[0-9]{2}-[0-9]{2}/) {
+ date = substr($0, 1, 10)
getline
if (/^todo:/) {
match($0, /^todo: (.*)/, arr)
@@ -14,10 +15,22 @@ selected=$(awk '{
}
}' "$TODO_FILE" | tac | dmenu "$@")
-if [ -n "$selected" ]; then
- if ! grep -q "^todo: $selected$" "$TODO_FILE"; then
- printf "\n%s\ntodo: %s" "$(date --rfc-3339=s)" "$selected" >>"$TODO_FILE"
- else
- echo "$selected" | awk '{print $0}' | wl-copy
- fi
+[ -z "$selected" ] && exit 0
+
+task="$selected"
+
+if ! grep -q "^todo: $task$" "$TODO_FILE"; then
+ [ -n "$(tail -c1 "$TODO_FILE")" ] && printf '\n' >>"$TODO_FILE"
+ printf "%s\ntodo: %s\n" "$(date --rfc-3339=s)" "$task" >>"$TODO_FILE"
+else
+ action=$(printf "copy to clipboard\nmark as done" | dmenu -p "$task" "$@")
+ case "$action" in
+ "copy to clipboard")
+ echo "$task" | wl-copy
+ ;;
+ "mark as done")
+ offset=$(grep -bo "^todo: $task$" "$TODO_FILE" | head -1 | cut -d: -f1)
+ printf 'done:' | dd of="$TODO_FILE" bs=1 seek="$offset" conv=notrunc 2>/dev/null
+ ;;
+ esac
fi