Merge pull request #20 from polyphemus/xsessions

Add support for /usr/share/xsessions.
This commit is contained in:
Ghost1227 2013-03-25 14:53:25 -07:00
commit 2722a1fb5c

27
src/cdm
View File

@ -91,6 +91,33 @@ if [[ "${#binlist[@]}" == 0 ]]; then
namelist=(${binlist[@]##*/}) namelist=(${binlist[@]##*/})
fi 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
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
for ((count=0; count < ${#desktopsessions[@]}; count++)); do
# TryExec key is there to determine if executable is present,
# but as we are going to test the Exec key anyway, we ignore it.
execkey=$(sed -n -e 's/^Exec=//p' <${desktopsessions[${count}]})
namekey=$(sed -n -e 's/^Name=//p' <${desktopsessions[${count}]})
if [[ -n ${execkey} && -n ${namekey} ]]; then
# The .desktop files allow there Exec keys to use $PATH lookup.
binitem="$(which $(cut -f 1 -d ' ' <<< ${execkey}))"
binargs="$(cut -s -f 2- -d ' ' <<< ${execkey})"
# If which fails to return valid path, skip to next .desktop file.
if [ -z $binitem ]; then continue; fi
if [ -n $binargs ]; then binitem+=" ${binargs}"; fi
binlist+=("${binitem}")
flaglist+=('X')
namelist+=("${namekey}")
fi
done
fi
# Generate the main menu. # Generate the main menu.
menu=() menu=()
for ((count = 0; count < ${#namelist[@]}; count++)); do for ((count = 0; count < ${#namelist[@]}; count++)); do