Improved user selection dialog
This commit is contained in:
parent
cc07972c78
commit
b9baec2b1f
|
@ -403,24 +403,29 @@ function show_about {
|
||||||
|
|
||||||
function select_user {
|
function select_user {
|
||||||
SELECTED_USERNAME=
|
SELECTED_USERNAME=
|
||||||
data=$(tempfile 2>/dev/null)
|
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
users_array=($(ls /home))
|
||||||
dialog --title "Select a user" \
|
|
||||||
--backtitle $"Freedombone Control Panel" \
|
delete=(mirrors git)
|
||||||
--dselect "/home/" 14 40 2> $data
|
for del in ${delete[@]}
|
||||||
sel=$?
|
do
|
||||||
case $sel in
|
users_array=(${users_array[@]/$del})
|
||||||
0) SELECTED_USERNAME=$(cat $data | awk -F '/' '{print $3}');;
|
done
|
||||||
1) return;;
|
|
||||||
255) return;;
|
i=0
|
||||||
esac
|
W=()
|
||||||
if [ ${#SELECTED_USERNAME} -lt 2 ]; then
|
name=()
|
||||||
SELECTED_USERNAME=
|
for u in ${users_array[@]}
|
||||||
fi
|
do
|
||||||
if [ ! -d /home/$SELECTED_USERNAME ]; then
|
i=$((i+1))
|
||||||
dialog --title $"User directory check" \
|
W+=($i "$u")
|
||||||
--msgbox $"This does not look like a user directory" 6 40
|
name+=("$u")
|
||||||
SELECTED_USERNAME=
|
done
|
||||||
|
|
||||||
|
user_index=$(dialog --backtitle $"Freedombone Control Panel" --title $"Select User" --menu $"Select one of the following:" 24 40 17 "${W[@]}" 3>&2 2>&1 1>&3)
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
SELECTED_USERNAME="${name[$((user_index-1))]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue