Merge pull request #23 from polyphemus/develop

Miscellaneous cleanup
pull/24/head
Ghost1227 11 years ago
commit b70bbc45a0

@ -86,7 +86,7 @@ altstartx=${altstartx:-no}
# Offer all available sessions in /etc/X11/Sessions, # Offer all available sessions in /etc/X11/Sessions,
# if $binlist if not explicitly set in cdmrc. # if $binlist if not explicitly set in cdmrc.
if [[ "${#binlist[@]}" == 0 ]]; then if [[ "${#binlist[@]}" == 0 && -d /etc/X11/Sessions ]]; then
binlist=($(find /etc/X11/Sessions -maxdepth 1 -type f)) binlist=($(find /etc/X11/Sessions -maxdepth 1 -type f))
flaglist=($(sed 's/[[:digit:]]\+/X/g' <<< ${!binlist[@]})) flaglist=($(sed 's/[[:digit:]]\+/X/g' <<< ${!binlist[@]}))
namelist=(${binlist[@]##*/}) namelist=(${binlist[@]##*/})
@ -95,7 +95,7 @@ fi
# If $binlist is not set in cdmrc or by files in /etc/X11/Sessions, # If $binlist is not set in cdmrc or by files in /etc/X11/Sessions,
# try .desktop files in /usr/share/xsessions/ . # try .desktop files in /usr/share/xsessions/ .
if [[ "${#binlist[@]}" == 0 ]]; then if [[ "${#binlist[@]}" == 0 && -d /usr/share/xsessions ]]; then
desktopsessions=($(find /usr/share/xsessions/ -regex .\*.desktop)) desktopsessions=($(find /usr/share/xsessions/ -regex .\*.desktop))
#TODO: allow full quoting and expansion according to desktop entry spec: #TODO: allow full quoting and expansion according to desktop entry spec:
# http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables # http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables
@ -119,37 +119,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.
@ -165,8 +166,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))"

@ -4,7 +4,8 @@
# Values set here is the default as in cdm(1). # Values set here is the default as in cdm(1).
# List of programs, commands with whitespaces should be quoted or escaped. # List of programs, commands with whitespaces should be quoted or escaped.
# If unset, all sessions in /etc/X11/Sessions are offered as choices. # If unset, all sessions in /etc/X11/Sessions or /usr/share/xsessions are
# offered as choices.
# #
# (An example:) # (An example:)
# binlist=( # binlist=(

Loading…
Cancel
Save