commit
b70bbc45a0
55
src/cdm
55
src/cdm
@ -86,7 +86,7 @@ altstartx=${altstartx:-no}
|
||||
# Offer all available sessions in /etc/X11/Sessions,
|
||||
# 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))
|
||||
flaglist=($(sed 's/[[:digit:]]\+/X/g' <<< ${!binlist[@]}))
|
||||
namelist=(${binlist[@]##*/})
|
||||
@ -95,7 +95,7 @@ fi
|
||||
# If $binlist is not set in cdmrc or by files in /etc/X11/Sessions,
|
||||
# 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))
|
||||
#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
|
||||
@ -119,37 +119,38 @@ if [[ "${#binlist[@]}" == 0 ]]; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Generate the main menu.
|
||||
menu=()
|
||||
for ((count = 0; count < ${#namelist[@]}; count++)); do
|
||||
menu=("${menu[@]}" "$((count+countfrom))" "${namelist[${count}]}")
|
||||
done
|
||||
|
||||
# Override dialog display if only one option is available.
|
||||
if [[ "$count" == 1 ]]; then
|
||||
binindex=0
|
||||
else
|
||||
# Display selection dialog.
|
||||
binindex=$(
|
||||
DIALOGRC="$dialogrc" dialog --colors --stdout \
|
||||
--backtitle "$longname v$ver" \
|
||||
--ok-label ' Select ' --cancel-label ' Exit ' \
|
||||
--menu 'Select session' 0 0 0 "${menu[@]}"
|
||||
)
|
||||
if [[ $? != 0 ]]; then
|
||||
case "${#binlist[@]}" in
|
||||
0)
|
||||
error "No programs found in cdm config file, /etc/X11/Sessions or /usr/share/xsessions."
|
||||
exiterror
|
||||
;;
|
||||
1)
|
||||
# No need to call dialog AND clear, only one possible program
|
||||
binindex=0
|
||||
;;
|
||||
*)
|
||||
menu=()
|
||||
for ((count = 0; count < ${#namelist[@]}; count++)); do
|
||||
menu=("${menu[@]}" "$((count+countfrom))" "${namelist[${count}]}")
|
||||
done
|
||||
binindex=$(
|
||||
DIALOGRC="$dialogrc" dialog --colors --stdout \
|
||||
--backtitle "$longname v$ver" --ok-label ' Select ' \
|
||||
--cancel-label ' Exit ' --menu 'Select session' 0 0 0 "${menu[@]}"
|
||||
)
|
||||
if [[ $? != 0 ]]; then
|
||||
clear; exitnormal
|
||||
fi
|
||||
clear
|
||||
exitnormal
|
||||
fi
|
||||
fi
|
||||
let binindex-=countfrom
|
||||
;;
|
||||
esac
|
||||
|
||||
# Run $bin according to its flag.
|
||||
let binindex-=countfrom
|
||||
bin=($(eval echo "${binlist[${binindex}]}"))
|
||||
case ${flaglist[$binindex]} in
|
||||
# *C*onsole programs.
|
||||
[Cc])
|
||||
clear
|
||||
|
||||
# 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
|
||||
# only let the shell automatically `exec' cdm when $CDM_SPAWN is not set.
|
||||
@ -165,8 +166,6 @@ case ${flaglist[$binindex]} in
|
||||
|
||||
# *X* programs.
|
||||
[Xx])
|
||||
clear
|
||||
|
||||
# If X is already running and locktty=yes, activate it.
|
||||
if $(yesno locktty) && xdpyinfo -display ":$display.0" &> /dev/null; then
|
||||
chvt "$((display+xtty))"
|
||||
|
@ -4,7 +4,8 @@
|
||||
# Values set here is the default as in cdm(1).
|
||||
|
||||
# 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:)
|
||||
# binlist=(
|
||||
|
Loading…
Reference in New Issue
Block a user