various improvements
this commit also downgrades code quality slightly (by not using readarray). while readarray is cleaner, it is not compatible with older bash versions (< version 4) so a while loop will have to do. i may change this later.
This commit is contained in:
parent
c35aedb651
commit
30aaebb7f8
|
@ -401,11 +401,25 @@ main_desktop() {
|
||||||
else # we have entries, let's populate the arrays
|
else # we have entries, let's populate the arrays
|
||||||
command -v desktop_pre_func > /dev/null && desktop_pre_func
|
command -v desktop_pre_func > /dev/null && desktop_pre_func
|
||||||
|
|
||||||
readarray -t it_title < "$TEMPORARY_DIR/../.title"
|
# read title
|
||||||
readarray -t it_exec < "$TEMPORARY_DIR/../.exec"
|
while read -r p; do
|
||||||
readarray -t it_icon < "$TEMPORARY_DIR/../.icon"
|
it_title+=("$p")
|
||||||
readarray -t it_file < "$TEMPORARY_DIR/../.file"
|
done < "$TEMPORARY_DIR/../.title"
|
||||||
|
|
||||||
|
# read icon
|
||||||
|
while read -r p; do
|
||||||
|
it_icon+=("$p")
|
||||||
|
done < "$TEMPORARY_DIR/../.icon"
|
||||||
|
|
||||||
|
# read executable
|
||||||
|
while read -r p; do
|
||||||
|
it_exec+=("$p")
|
||||||
|
done < "$TEMPORARY_DIR/../.exec"
|
||||||
|
|
||||||
|
# read file
|
||||||
|
while read -r p; do
|
||||||
|
it_file+=("$p")
|
||||||
|
done < "$TEMPORARY_DIR/../.file"
|
||||||
|
|
||||||
# finally print all of it
|
# finally print all of it
|
||||||
for i in "${!it_title[@]}"; do
|
for i in "${!it_title[@]}"; do
|
||||||
|
@ -427,21 +441,37 @@ main_desktop() {
|
||||||
[ -z "$menusel" ] && return 1 \
|
[ -z "$menusel" ] && return 1 \
|
||||||
|| printf "User input: %s\n" "$menusel" >> "$LOGFILE"
|
|| printf "User input: %s\n" "$menusel" >> "$LOGFILE"
|
||||||
|
|
||||||
w_array() {
|
exec_program() {
|
||||||
readarray -t it_title < "$TEMPORARY_DIR/../.title"
|
# read title
|
||||||
readarray -t it_exec < "$TEMPORARY_DIR/../.exec"
|
while read -r p; do
|
||||||
readarray -t it_icon < "$TEMPORARY_DIR/../.icon"
|
it_title+=("$p")
|
||||||
readarray -t it_file < "$TEMPORARY_DIR/../.file"
|
done < "$TEMPORARY_DIR/../.title"
|
||||||
|
|
||||||
|
# read icon
|
||||||
|
while read -r p; do
|
||||||
|
it_icon+=("$p")
|
||||||
|
done < "$TEMPORARY_DIR/../.icon"
|
||||||
|
|
||||||
|
# read executable
|
||||||
|
while read -r p; do
|
||||||
|
it_exec+=("$p")
|
||||||
|
done < "$TEMPORARY_DIR/../.exec"
|
||||||
|
|
||||||
|
# read file
|
||||||
|
while read -r p; do
|
||||||
|
it_file+=("$p")
|
||||||
|
done < "$TEMPORARY_DIR/../.file"
|
||||||
|
|
||||||
|
|
||||||
# set exec
|
# set exec
|
||||||
[ -z "${it_exec[1]}" ] && printf "Executable array is empty.\n" >> "$LOGFILE"
|
[ -z "${it_exec[1]}" ] && printf "Executable array is empty.\n" >> "$LOGFILE"
|
||||||
for i in "${!it_title[@]}"; do
|
for i in "${!it_title[@]}"; do
|
||||||
if [ "${it_title[i]}" = "$menusel" ]; then
|
if [ "${it_title[i]}" = "$menusel" ]; then
|
||||||
exec="${it_exec[i]}"
|
exec="${it_exec[i]}"
|
||||||
printf "Current file: '%s'\n" "${it_file[i]}" >> "$LOGFILE"
|
printf "Current file: '%s'\nIndex: '%s'\n" "${it_file[i]}" "${i}" >> "$LOGFILE"
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
printf "Executable %s is: %s" "$i" "${it_exec[i]}" >> "$LOGFILE"
|
printf "Executable %s is: '%s'\n" "$i" "${it_exec[i]}" >> "$LOGFILE"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -453,7 +483,7 @@ main_desktop() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
w_array
|
exec_program "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
prep() { mkdir -p "$TEMPORARY_DIR"; rm -f "$LOGFILE"; touch "$LOGFILE"; }
|
prep() { mkdir -p "$TEMPORARY_DIR"; rm -f "$LOGFILE"; touch "$LOGFILE"; }
|
||||||
|
|
Loading…
Reference in a new issue