|
|
@ -24,9 +24,7 @@ list=${list//"$EMPTY_RAW"/"$EMPTY"} # empty checkboxes
|
|
|
|
list=${list//"$FILLED_RAW"/"$FILLED"} # filled checkboxes
|
|
|
|
list=${list//"$FILLED_RAW"/"$FILLED"} # filled checkboxes
|
|
|
|
|
|
|
|
|
|
|
|
# Don't show clear all option if task list is empty
|
|
|
|
# Don't show clear all option if task list is empty
|
|
|
|
if [[ $list == "" ]]; then
|
|
|
|
[[ -z $list ]] && clear=""
|
|
|
|
clear=""
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Don't show clear completed option if there are no completed tasks
|
|
|
|
# Don't show clear completed option if there are no completed tasks
|
|
|
|
count=${#list_raw_array[*]}
|
|
|
|
count=${#list_raw_array[*]}
|
|
|
@ -34,15 +32,13 @@ i=0
|
|
|
|
completed_tasks="n"
|
|
|
|
completed_tasks="n"
|
|
|
|
while [ $i -lt $count ]; do
|
|
|
|
while [ $i -lt $count ]; do
|
|
|
|
# %q escapes string, otherwise there are issues with square brackets
|
|
|
|
# %q escapes string, otherwise there are issues with square brackets
|
|
|
|
if [[ ${list_raw_array[$i]} == `printf "%q" "$FILLED_RAW"`* ]]; then
|
|
|
|
if [[ ${list_raw_array[$i]} = `printf "%q" "$FILLED_RAW"`* ]]; then
|
|
|
|
completed_tasks="y"
|
|
|
|
completed_tasks="y"
|
|
|
|
break
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
i=$(($i + 1))
|
|
|
|
i=$(($i + 1))
|
|
|
|
done
|
|
|
|
done
|
|
|
|
if [[ $completed_tasks == "n" ]]; then
|
|
|
|
[[ $completed_tasks = "n" ]] && clear_completed=""
|
|
|
|
clear_completed=""
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Run rofi, replace display checkmarks with raw syntax
|
|
|
|
# Run rofi, replace display checkmarks with raw syntax
|
|
|
|
selection=`printf "%s%s%s\n" "$clear" "$clear_completed" "$list" | rofi -dmenu -i -selected-row 2 -p " Task:"`
|
|
|
|
selection=`printf "%s%s%s\n" "$clear" "$clear_completed" "$list" | rofi -dmenu -i -selected-row 2 -p " Task:"`
|
|
|
@ -50,32 +46,32 @@ selection=${selection//"$EMPTY"/"$EMPTY_RAW"}
|
|
|
|
selection=${selection//"$FILLED"/"$FILLED_RAW"}
|
|
|
|
selection=${selection//"$FILLED"/"$FILLED_RAW"}
|
|
|
|
|
|
|
|
|
|
|
|
# Selection logic
|
|
|
|
# Selection logic
|
|
|
|
if [[ $selection == $CLEAR ]]; then
|
|
|
|
case $selection in
|
|
|
|
list_raw=""
|
|
|
|
$CLEAR) list_raw="" ;;
|
|
|
|
elif [[ $selection == $CLEAR_COMPLETED ]]; then
|
|
|
|
$CLEAR_COMPLETED)
|
|
|
|
list_raw_array=($list_raw)
|
|
|
|
list_raw_array=($list_raw)
|
|
|
|
count=${#list_raw_array[*]}
|
|
|
|
count=${#list_raw_array[*]}
|
|
|
|
i=0
|
|
|
|
i=0
|
|
|
|
while [ $i -lt $count ]
|
|
|
|
while [ $i -lt $count ]
|
|
|
|
do
|
|
|
|
do
|
|
|
|
if [[ ${list_raw_array[$i]} == `printf "%q" "$FILLED_RAW"`* ]]; then
|
|
|
|
if [[ ${list_raw_array[$i]} = `printf "%q" "$FILLED_RAW"`* ]]; then
|
|
|
|
unset 'list_raw_array[$i]'
|
|
|
|
unset 'list_raw_array[$i]'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
i=$(($i + 1))
|
|
|
|
i=$(($i + 1))
|
|
|
|
done
|
|
|
|
done
|
|
|
|
list_raw="${list_raw_array[*]}"
|
|
|
|
list_raw="${list_raw_array[*]}" ;;
|
|
|
|
elif [[ $selection == `printf "%q" "$FILLED_RAW"`* ]]; then
|
|
|
|
`printf "%q" "$FILLED_RAW"`*)
|
|
|
|
replace="${selection}${NL}"
|
|
|
|
replace="${selection}${NL}"
|
|
|
|
list_raw=${list_raw//"$replace"/""}
|
|
|
|
list_raw=${list_raw//"$replace"/""}
|
|
|
|
list_raw=${list_raw//"$selection"/""}
|
|
|
|
list_raw=${list_raw//"$selection"/""} ;;
|
|
|
|
elif [[ $selection == `printf "%q" "$EMPTY_RAW"`* ]]; then
|
|
|
|
`printf "%q" "$EMPTY_RAW"`*)
|
|
|
|
selection_filled=${selection//"$EMPTY_RAW"/"$FILLED_RAW"}
|
|
|
|
selection_filled=${selection//"$EMPTY_RAW"/"$FILLED_RAW"}
|
|
|
|
list_raw=${list_raw//"$selection"/"$selection_filled"}
|
|
|
|
list_raw=${list_raw//"$selection"/"$selection_filled"} ;;
|
|
|
|
elif [[ $selection != "" ]]; then
|
|
|
|
*)
|
|
|
|
if [[ $list_raw != "" ]]; then
|
|
|
|
if [[ -n $selection ]]; then
|
|
|
|
list_raw="${list_raw}${NL}"
|
|
|
|
[[ -n $list_raw ]] && list_raw="${list_raw}${NL}"
|
|
|
|
fi
|
|
|
|
list_raw=`printf "%s%s %s\n" "$list_raw" "$EMPTY_RAW" "$selection"`
|
|
|
|
list_raw=`printf "%s%s %s\n" "$list_raw" "$EMPTY_RAW" "$selection"`
|
|
|
|
fi ;;
|
|
|
|
fi
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
printf "%s\n" "$list_raw" >| $FILE
|
|
|
|
printf "%s\n" "$list_raw" >| $FILE
|
|
|
|