This commit is contained in:
2026-03-12 02:05:30 +01:00
parent c5af037f52
commit 1ded2e792c
9 changed files with 700 additions and 0 deletions

248
bin/TODOlist Executable file
View File

@@ -0,0 +1,248 @@
#!/bin/bash
me=${0##*/}
CONKYDIR="$HOME/.config/conky"
CFG_FILE=~/.config/mabox/mabox-todo.conf
TODO_DIR=~/.todo
source <(grep = $CFG_FILE)
sleep .1
#notify-send.sh aaa "${0} ${1} ${me}"
# LANG
#case "$LANG" in
# pl*):;;
# es*):;;
# *):;;
#esac
#MENU
prettyname=${filename//_/ }
out+=("^sep(TODO list: <b>${prettyname}</b>)")
out+=("<big></big> Add <b>new</b> task...,mabox-todo.sh addtask && ${0} center")
out+=("^sep()")
s=0
i=0
dirty=0
# Dostępne pliki
readarray -t files < <(mabox-todo.sh listfiles)
readarray -t contexts < <(mabox-todo.sh listcon)
readarray -t projects < <(mabox-todo.sh listproj)
# Lista zadań
while read -r line
do
[[ "$line" = "--" ]] && s=1 && continue;
((i++))
if [ "$s" = 1 ];then
out+=("^sep(<i>${line}</i>)")
else
#notify-send.sh MSG "${line}"
linia="${line}"
number=${linia#*>}
number=${number%%<*}
#notify-send.sh "${number}" "${line}"
#number=${line:21:2}
#notify-send.sh "${number}" "${line}"
#notify-send.sh "${number}" "${line:32:1}"
pri="([A-Z])"
line=${line/\<\/span\>\<\/span\>/\<\/span\>}
line=${line/\<\/span\> \<\/span\>/\<\/span\>}
line=${line/&/&amp;}
linia2="${line}"
iks=${linia#*span>} # pozbywamy sie początku
iks=${iks%%<*} # i reszty
[[ "$iks" == " x " ]] && ((dirty++)) #notify-send.sh "iks" "${iks}"
#[[ "${line:32:1}" = "x" || "${line:31:1}" = "x" ]] && ((dirty++))# && notify-send.sh "AAA" "<tt>${line}</tt>"
[[ "${dirty}" == "1" ]] && out+=("^sep(done tasks)")
out+=("\"\"\"${line}\"\"\",^checkout(${i})")
out2+=("^tag(${i})")
out2+=("^sep(TODO: <b>${prettyname}</b>)")
out2+=("^sep(Task: ${number})")
#out2+=("    <small>back to list</small>,^back()")
out2+=("^sep()")
out2+=("\"\"\"${line}\"\"\",geany -l ${number:-1} ${TODO_DIR}/${filename}.txt")
out2+=("^sep()")
if [ "$dirty" = "0" ];then
if [ -z "${line##*$pri*}" ]; then
out2+=(" Deprioritize,mabox-todo.sh dp ${number};${0} center")
fi
out2+=(" <b>(A)</b> priority,mabox-todo.sh p ${number} A;${0} center")
out2+=(" <b>(B)</b> priority,mabox-todo.sh p ${number} B;${0} center")
out2+=(" <b>(C)</b> priority,mabox-todo.sh p ${number} C;${0} center")
out2+=("^sep()")
out2+=("<big></big> Mark as done,mabox-todo.sh -a -f -n done ${number};${0} center" "^sep()")
fi
out2+=("<big></big> Edit task,geany -l ${number:-1} ${TODO_DIR}/${filename}.txt")
if [ "${#files[@]}" -gt "1" ];then
out2+=("<big>󱉆</big> Move to...,^checkout(file${number})")
out3+=("^tag(file${number})")
out3+=("^sep(Move task to...)")
for file in "${files[@]}"
do
prettyfile=${file//_/ }
[[ "$file" != "$filename" ]] && out3+=("${prettyfile},mabox-todo.sh -f -n move ${number} ${file}.txt ${filename}.txt;${0} center")
done
fi
#out2+=("    <small>back to list</small>,^back()")
out2+=("^sep()")
out2+=("<big></big> Delete task,mabox-todo.sh -f -n del ${number};${0} center")
fi
done <<< $(mabox-todo.sh -d ~/.config/todo/config-jgmenu ls)
[[ "$dirty" > "0" ]] && out+=("<big>󱝧</big> Archive (remove all done tasks),mabox-todo.sh -f archive; ${0} center" "^sep()")
out+=("<big></big> TODO List: <b>${prettyname}</b>...,^checkout(files)")
[[ -f "${TODO_DIR}/${filename}.ctb" ]] && out+=("^sep()" "<big>󱁂</big> <b>Notes</b> for ${prettyname},cherrytree ${TODO_DIR}/${filename}.ctb")
out2+=("^tag(files)")
if [ "${#files[@]}" -gt "1" ];then
out2+=("^sep(Switch to todolist:)")
while read -r line
do
prettyline=${line//_/ }
tasks=$(cat ~/.todo/${line}.txt |wc -l)
if [ "$line" = "${filename}" ];then
out2+=("<big>綠</big> ${prettyline} <small><i>(${tasks} tasks)</i></small> ,${0} center")
else
out2+=("<big>祿</big> ${prettyline} <small><i>(${tasks} tasks)</i></small> ,mabox-todo.sh s $line;${0} center")
fi
done <<< $(mabox-todo.sh listfiles)
fi
out2+=("^sep(TODO List: ${prettyname})")
out2+=("<big></big> Edit <b>${prettyname}</b>.txt in Text editor,xdg-open ${TODO_DIR}/${filename}.txt")
### Cherrytree
if hash cherrytree 2>/dev/null
then
if [[ -f "${TODO_DIR}/${filename}.ctb" ]];then
out2+=("Edit notes,cherrytree ${TODO_DIR}/${filename}.ctb")
else
out2+=("<big></big> Add hierarchical notes to <b>${prettyname}</b> todolist (Cherrytree),mabox-todo.sh addnotes ${filename};${0}")
fi
else
out2+=("<big>󱁂</big> Need notes for todolist? Install Cherrytree,pamac-installer cherrytree")
fi
## Custom Menu
if [[ -f "${TODO_DIR}/${filename}.csv" ]];then
out2+=("Edit <b>${prettyname}</b> todolist custom menu,xdg-open ${TODO_DIR}/${filename}.csv")
out2+=("Delete <b>${prettyname}</b> todolist custom menu,rm -f ${TODO_DIR}/${filename}.csv;${0} center")
else
out2+=("<big>󰍜</big> Add custom menu for <b>${prettyname}</b> todolist,mabox-todo.sh addmenu ${filename}")
fi
out2+=("^sep()")
out2+=("<b></b> Create <b>New TODO List</b> (file)...,mabox-todo.sh addfile && ${0} center")
#out2+=("   ,^back()")
out2+=("^sep(Danger Zone)")
out2+=("<big></big> Delete <b>${prettyname}</b> todolist and all related files,^checkout(delproj)")
out3+=("^tag(delproj)")
out3+=("^sep(Are you sure?)")
out3+=("\"\"\"Yes, delete <b>${prettyname}</b> todolist and all files\"\"\",mabox-todo.sh removeproject ${filename};${0} center")
### for Conky only if running
out+=("^sep()")
if pgrep -f 'conky.*conky/TODOlist' 2> /dev/null;then
out+=("<big></big> Conky display settings/filter,^checkout(display)")
# DISPLAY SETTINGS SUBMENU
out2+=("^tag(display)")
out2+=("^sep(Conky settings)")
[[ "$filter" != "" ]] && out2+=("<big></big> Clear filter ($filter),mb-setvar filter= ${CFG_FILE};${0} center")
out2+=("^sep(Filter by)")
# Projects
if (( ${#projects[@]} == 0 )); then
: #empty
else
for proj in "${projects[@]}"
do
[[ "$filter" == "$proj" ]] && out2+=("<big>綠</big> <span bgcolor='#CCCCCC' fgcolor='purple'><b> ${proj} </b></span>,mb-setvar filter= ${CFG_FILE};${0} center") || out2+=("<big>祿</big> <span bgcolor='#CCCCCC' fgcolor='purple'> ${proj} </span>,mb-setvar filter=${proj} ${CFG_FILE};${0} center")
done
fi
if (( ${#contexts[@]} == 0 )); then
: #empty
else
out2+=("^sep()")
for context in "${contexts[@]}"
do
[[ "$filter" == "$context" ]] && out2+=("<big>綠</big> <span fgcolor='green' bgcolor='#EEEEEE'><b> ${context} </b></span>,mb-setvar filter= ${CFG_FILE};${0} center") || out2+=("<big>祿</big> <span fgcolor='green' bgcolor='#EEEEEE'> ${context} </span>,mb-setvar filter=${context} ${CFG_FILE};${0} center")
done
fi
out2+=("^sep(Show/hide some elements in Conky)")
[[ "$hide_done" = "y" ]] && out2+=("<big></big> Show done tasks ,mb-setvar hide_done=n ${CFG_FILE}; ${0} center") || out2+=("<big></big> Show done tasks ,mb-setvar hide_done=y ${CFG_FILE}; ${0} center")
[[ "$hide_priority" = "y" ]] && out2+=("<big></big> (A-C) priority ,mb-setvar hide_priority=n ${CFG_FILE}; ${0} center") || out2+=("<big></big> (A-C) priority ,mb-setvar hide_priority=y ${CFG_FILE}; ${0} center")
[[ "$hide_project" = "y" ]] && out2+=("<big></big> +project,mb-setvar hide_project=n ${CFG_FILE}; ${0} center") || out2+=("<big></big> +project,mb-setvar hide_project=y ${CFG_FILE}; ${0} center")
[[ "$hide_context" = "y" ]] && out2+=("<big></big> @context,mb-setvar hide_context=n ${CFG_FILE}; ${0} center") || out2+=("<big></big> @context,mb-setvar hide_context=y ${CFG_FILE}; ${0} center")
else
out+=("Start TODOList conky widget,conkyctl startone ${HOME}/.config/conky/TODOlist_mbcolor.conkyrc;${0}")
fi
out+=("^sep()")
out+=("<big></big> About and Help,${0} center")
#out+=("󰞷 CLI usage Help,^term(mabox-todo.sh help)")
#Custom COMMANDS from CSV file
if [ -f ${TODO_DIR}/${filename}.csv ]; then
LINES=$(grep -Ev "^#|^$" ${TODO_DIR}/${filename}.csv|wc -l)
if [ ${LINES} != 0 ]; then
out+=("^sep(Custom commands for <b>${prettyname}</b> todolist)")
fi
fi
source /usr/share/mb-jgtools/pipemenu-standalone.cfg
source "$HOME/.config/mabox/mabox.conf"
CONFIG_FILE=$(mktemp)
MENU_ITEMS=$(mktemp)
trap "rm -f ${CONFIG_FILE} ${MENU_ITEMS}" EXIT
POSITION_MODE=center
CENTER=""
if [ "$1" = "center" ]; then
POSITION_MODE="center"
fi
MENU_HALIGN="center"
MENU_VALIGN="top"
menu_margin_x=90
MENU_MARGIN_Y=90
HIDE_BACK_ITEMS=1
MENU_PADDING_TOP=${jgtools_padding:-0}
JGWIDTH=180
TABS=90
jgmenu_icon_size=0
menu_font_size=11
jgmenu_font="Noto Sans 11"
jgtools_border=12
jgtools_padding=12
mkconfigfile
echo menu_height_mode=dynamic >> ${CONFIG_FILE}
echo hide_back_items=0 >> ${CONFIG_FILE}
cat <<EOF > ${MENU_ITEMS}
$(printf '%s\n' "${out[@]}")
. ${TODO_DIR}/${filename}.csv
$(printf '%s\n' "${out2[@]}")
$(printf '%s\n' "${out3[@]}")
EOF
cat "${MENU_ITEMS}"
#cat /home/napcok/.config/conky/menuscripts/TODOtxt.csv
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null