Thanks again for your help.
]]>Thanks again for your help.
]]>Howerer, even though It does return the selected package name as expected I get the below error:
(zenity:214751): GLib-WARNING **: 11:05:27.906: ../glib/glib/giounix.c:410Error while getting flags for FD: Bad file descriptor (9)
But really this is much much simpler, don't loop and use dozens of subshells and additional processes creating variables - just pipe:
pkgs="zsh conky"
pacman -Qi $pkgs | \
sed -n 's/^Name *: /FALSE\n/p;s/^Description *: //p' | \
zenity --width=900 --height=490 --list --radiolist --text "package" --column "select" --column "package" --column "description"
Tally: your approach would use (at least) 3N+1 subshells and N calls to pacman (where N is the number of packages), while mine uses 3 subshells total (2 as written, but I assume you'll wrap this in $() to store the result) and only 1 call to pacman no matter how many packages are in your input list.
]]>I create an array containg a list of pacman packages/descriptions with the below code:
installedPKGs=()
for PKG in zsh conky ; do
installedPKGs=("${installedPKGs[@]}FALSE ${PKG} \"$(pacman -Qi ${PKG} | egrep 'Description' | cut -c19-99)\" ")
done
the array then contains:
echo "${installedPKGs[@]}"
FALSE which "A utility to show the full path of commands" FALSE zsh "A very advanced and programmable command interpreter (shell) for UNIX" FALSE conky "Lightweight system monitor for X" FALSE pacman "A library-based package manager with dependency support"
using the above value of the array as a Zenity paramater as shown below works as expected:
selectedPKG=$( \
zenity --width=900 --height=490 --list --radiolist --text "package to REMOVE" --column "select" --column "package" --column "description" \
FALSE zsh "A very advanced and programmable command interpreter (shell) for UNIX" FALSE conky "Lightweight system monitor for X" \
)
However, when I pass the array as a paramater as shown below it results in a blank selection list:
selectedPKG=$( zenity --width=900 --height=490 --list --radiolist --text "package to REMOVE" --column "select" --column "package" --column "description" "${installedPKGs[@]}" )
Am I building/passing the array to zenity incorrectly?
]]>