Cleanup of $binlist behaviour. Show error when no programs are found. Don't use $countdown if only one program is available. Don't call clear when only one program is available/dialog is not called.

pull/23/head
polyphemus 11 years ago
parent 89473c35f3
commit 536010fea5

@ -118,37 +118,38 @@ if [[ "${#binlist[@]}" == 0 ]]; then
done done
fi fi
# Generate the main menu. case "${#binlist[@]}" in
menu=() 0)
for ((count = 0; count < ${#namelist[@]}; count++)); do error "No programs found in cdm config file, /etc/X11/Sessions or /usr/share/xsessions."
menu=("${menu[@]}" "$((count+countfrom))" "${namelist[${count}]}") exiterror
done ;;
1)
# Override dialog display if only one option is available. # No need to call dialog AND clear, only one possible program
if [[ "$count" == 1 ]]; then binindex=0
binindex=0 ;;
else *)
# Display selection dialog. menu=()
binindex=$( for ((count = 0; count < ${#namelist[@]}; count++)); do
DIALOGRC="$dialogrc" dialog --colors --stdout \ menu=("${menu[@]}" "$((count+countfrom))" "${namelist[${count}]}")
--backtitle "$longname v$ver" \ done
--ok-label ' Select ' --cancel-label ' Exit ' \ binindex=$(
--menu 'Select session' 0 0 0 "${menu[@]}" DIALOGRC="$dialogrc" dialog --colors --stdout \
) --backtitle "$longname v$ver" --ok-label ' Select ' \
if [[ $? != 0 ]]; then --cancel-label ' Exit ' --menu 'Select session' 0 0 0 "${menu[@]}"
)
if [[ $? != 0 ]]; then
clear; exitnormal
fi
clear clear
exitnormal let binindex-=countfrom
fi ;;
fi esac
# Run $bin according to its flag. # Run $bin according to its flag.
let binindex-=countfrom
bin=($(eval echo "${binlist[${binindex}]}")) bin=($(eval echo "${binlist[${binindex}]}"))
case ${flaglist[$binindex]} in case ${flaglist[$binindex]} in
# *C*onsole programs. # *C*onsole programs.
[Cc]) [Cc])
clear
# If $bin is a login shell, it might `exec' cdm again, causing an endless # If $bin is a login shell, it might `exec' cdm again, causing an endless
# loop. To solve this problem, export $CDM_SPAWN when `exec'ing $bin and # loop. To solve this problem, export $CDM_SPAWN when `exec'ing $bin and
# only let the shell automatically `exec' cdm when $CDM_SPAWN is not set. # only let the shell automatically `exec' cdm when $CDM_SPAWN is not set.
@ -164,8 +165,6 @@ case ${flaglist[$binindex]} in
# *X* programs. # *X* programs.
[Xx]) [Xx])
clear
# If X is already running and locktty=yes, activate it. # If X is already running and locktty=yes, activate it.
if $(yesno locktty) && xdpyinfo -display ":$display.0" &> /dev/null; then if $(yesno locktty) && xdpyinfo -display ":$display.0" &> /dev/null; then
chvt "$((display+xtty))" chvt "$((display+xtty))"

Loading…
Cancel
Save