Update multiple scripts

This commit is contained in:
ItsDrike 2022-10-29 23:31:40 +02:00
parent 542ac098b4
commit 44b010a541
No known key found for this signature in database
GPG key ID: B014E761034AF742
17 changed files with 424 additions and 37 deletions

View file

@ -1,36 +0,0 @@
#!/bin/sh
# This is inspired by dmenu's todo script made by suckless
#
# Manage TODO tasks in dmenu by writing them, remove by selecting
# an existing entry
#
# Configurable variables
# ---------------------------------------------------------------------
FILE="${XDG_DATA_HOME:-$HOME/.local/share}/todos"
PROMPT="Add/delete a task: "
# Logic
# ---------------------------------------------------------------------
mkdir -p "$(dirname $FILE)"
touch "$FILE"
height=$(wc -l "$FILE" | awk '{print $1}')
# Run dmenu and keep restarting it until it returns an empty output
cmd=$(dmenu -l "$height" -p "$PROMPT" "$@" < "$FILE")
while [ -n "$cmd" ]; do
# If the output matched an existing TODO, remove it
if grep -q "^$cmd\$" "$FILE"; then
grep -v "^$cmd\$" "$FILE" > "$FILE.$$"
mv "$FILE.$$" "$FILE"
height=$(( height - 1 ))
# If the output didn't match an existing TODO, it's a new one, add it
else
echo "$cmd" >> "$FILE"
height=$(( height + 1 ))
fi
# Keep restarting until empty output
cmd=$(dmenu -l "$height" -p "$PROMPT" "$@" < "$FILE")
done