#!/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: ${prettyname})") out+=(" Add new 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(${line})") 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/&/&} 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" "${line}" [[ "${dirty}" == "1" ]] && out+=("^sep(done tasks)") out+=("\"\"\"${line}\"\"\",^checkout(${i})") out2+=("^tag(${i})") out2+=("^sep(TODO: ${prettyname})") out2+=("^sep(Task: ${number})") #out2+=("    back to list,^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+=(" (A) priority,mabox-todo.sh p ${number} A;${0} center") out2+=(" (B) priority,mabox-todo.sh p ${number} B;${0} center") out2+=(" (C) priority,mabox-todo.sh p ${number} C;${0} center") out2+=("^sep()") out2+=(" Mark as done,mabox-todo.sh -a -f -n done ${number};${0} center" "^sep()") fi out2+=(" Edit task,geany -l ${number:-1} ${TODO_DIR}/${filename}.txt") if [ "${#files[@]}" -gt "1" ];then out2+=("󱉆 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+=("    back to list,^back()") out2+=("^sep()") out2+=(" 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+=("󱝧 Archive (remove all done tasks),mabox-todo.sh -f archive; ${0} center" "^sep()") out+=(" TODO List: ${prettyname}...,^checkout(files)") [[ -f "${TODO_DIR}/${filename}.ctb" ]] && out+=("^sep()" "󱁂 Notes 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+=(" ${prettyline} (${tasks} tasks) ,${0} center") else out2+=(" ${prettyline} (${tasks} tasks) ,mabox-todo.sh s $line;${0} center") fi done <<< $(mabox-todo.sh listfiles) fi out2+=("^sep(TODO List: ${prettyname})") out2+=(" Edit ${prettyname}.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+=(" Add hierarchical notes to ${prettyname} todolist (Cherrytree),mabox-todo.sh addnotes ${filename};${0}") fi else out2+=("󱁂 Need notes for todolist? Install Cherrytree,pamac-installer cherrytree") fi ## Custom Menu if [[ -f "${TODO_DIR}/${filename}.csv" ]];then out2+=("Edit ${prettyname} todolist custom menu,xdg-open ${TODO_DIR}/${filename}.csv") out2+=("Delete ${prettyname} todolist custom menu,rm -f ${TODO_DIR}/${filename}.csv;${0} center") else out2+=("󰍜 Add custom menu for ${prettyname} todolist,mabox-todo.sh addmenu ${filename}") fi out2+=("^sep()") out2+=(" Create New TODO List (file)...,mabox-todo.sh addfile && ${0} center") #out2+=("   ,^back()") out2+=("^sep(Danger Zone)") out2+=(" Delete ${prettyname} todolist and all related files,^checkout(delproj)") out3+=("^tag(delproj)") out3+=("^sep(Are you sure?)") out3+=("\"\"\"Yes, delete ${prettyname} 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+=(" Conky display settings/filter,^checkout(display)") # DISPLAY SETTINGS SUBMENU out2+=("^tag(display)") out2+=("^sep(Conky settings)") [[ "$filter" != "" ]] && out2+=(" 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+=(" ${proj} ,mb-setvar filter= ${CFG_FILE};${0} center") || out2+=(" ${proj} ,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+=(" ${context} ,mb-setvar filter= ${CFG_FILE};${0} center") || out2+=(" ${context} ,mb-setvar filter=${context} ${CFG_FILE};${0} center") done fi out2+=("^sep(Show/hide some elements in Conky)") [[ "$hide_done" = "y" ]] && out2+=(" Show done tasks ,mb-setvar hide_done=n ${CFG_FILE}; ${0} center") || out2+=(" Show done tasks ,mb-setvar hide_done=y ${CFG_FILE}; ${0} center") [[ "$hide_priority" = "y" ]] && out2+=(" (A-C) priority ,mb-setvar hide_priority=n ${CFG_FILE}; ${0} center") || out2+=(" (A-C) priority ,mb-setvar hide_priority=y ${CFG_FILE}; ${0} center") [[ "$hide_project" = "y" ]] && out2+=(" +project,mb-setvar hide_project=n ${CFG_FILE}; ${0} center") || out2+=(" +project,mb-setvar hide_project=y ${CFG_FILE}; ${0} center") [[ "$hide_context" = "y" ]] && out2+=(" @context,mb-setvar hide_context=n ${CFG_FILE}; ${0} center") || out2+=(" @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+=(" 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 ${prettyname} 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 < ${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