commit 07f70d0c6f095b8720e072f96cf4c4f2aa6e4c63
parent abfc68c580b3b12569270e25474f504fc801862a
Author: Riaz <riaz@riazj.com>
Date: Fri, 18 Jul 2025 19:35:56 -0700
Use dmenu for todo list
Diffstat:
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc
@@ -9,3 +9,6 @@ alt + {_,shift + } w
alt + z
zathura
+
+ctrl + t
+ todo
diff --git a/.local/bin/td b/.local/bin/td
@@ -1,8 +0,0 @@
-#!/bin/sh -e
-
-TODO="$HOME/todo"
-TEMP="/tmp/todo.tmp"
-
-[ $# -eq 0 ] && { nl -nln -ba "$TODO"; exit; }
-[ "$1" != "rm" ] && { echo "$*" >> "$TODO"; exit; }
-shift; sed "$*d" "$TODO" > "$TEMP" && mv "$TEMP" "$TODO"
diff --git a/.local/bin/todo b/.local/bin/todo
@@ -0,0 +1,16 @@
+#!/bin/sh -e
+
+TODO="$HOME/todo"
+height="$(wc -l "$TODO")"
+height="${height% *}"
+
+while true; do
+ sel="$(dmenu -i -l "$height" < "$TODO")"
+ if grep -q "^$sel$" "$TODO"; then
+ sed -i "/^$sel$/d" "$TODO"
+ height=$((height-1))
+ else
+ echo "$sel" >> "$TODO"
+ height=$((height+1))
+ fi
+done