Minor improvements to coding style.

pull/14/head
Casper Ti. Vector 12 years ago
parent 2ea165a1bc
commit 7aa1654039

@ -48,7 +48,7 @@ yesno()
case "$value" in case "$value" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;;
*) warn "Invalid value for \`$1'; falling back to \`no' for now.";; *) warn "invalid value for \`$1'; falling back to \`no' for now.";;
esac esac
} }
@ -83,7 +83,7 @@ cktimeout=${cktimeout:-30}
serverargs=${serverargs:-'-nolisten tcp'} serverargs=${serverargs:-'-nolisten tcp'}
# 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 ]]; then
binlist=($(find /etc/X11/Sessions -maxdepth 1 -type f)) binlist=($(find /etc/X11/Sessions -maxdepth 1 -type f))
@ -121,13 +121,14 @@ case ${flaglist[$binindex]} in
# *C*onsole programs. # *C*onsole programs.
[Cc]) [Cc])
clear 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.
# See also the example shell profile file shipped with the cdm package. # See also the example shell profile file shipped with the cdm package.
# Also untrap SIGINT and SIGTSTP before spawning process: If this is not # Also untrap SIGINT and SIGTSTP before spawning process: If this is not
# done, *ANY* child process of *ANY* child (bash) shell will completely # done, any child process of any child (bash) shell will completely
# ignore SIGINT, which is rather confusing, and cannot be undone. # ignore SIGINT, which is rather confusing, and cannot be undone.
trap - SIGINT SIGTSTP trap - SIGINT SIGTSTP
@ -138,12 +139,10 @@ case ${flaglist[$binindex]} in
[Xx]) [Xx])
clear clear
# If X is already running and locktty=yes, activate it # If X is already running and locktty=yes, activate it.
if $(yesno locktty); then if $(yesno locktty) && xdpyinfo -display ":$display.0" &> /dev/null; then
if xdpyinfo -display ":$display.0" &> /dev/null; then chvt "$((display+xtty))"
chvt "$((display+xtty))" exitnormal
exitnormal
fi
fi fi
# Get the first empty display. # Get the first empty display.
@ -161,17 +160,16 @@ case ${flaglist[$binindex]} in
fi fi
done done
# run X in current tty # Support for running X in current tty.
if [[ $xtty == "keep" ]]; then if [[ $xtty == 'keep' ]]; then
vt=$(tty) vt="$(tty)"
vt=${vt#/dev/} if [[ "$vt" != '/dev/tty'* ]]; then
if [[ $vt != tty* ]]; then error 'invalid TTY.'
error "error: invalid TTY"
exiterror exiterror
fi fi
vt=${vt#tty} vt="${vt#/dev/tty}"
else else
vt=$((xtty+display)) vt="$((xtty+display))"
fi fi
serverargs=":${display} $serverargs vt$vt" serverargs=":${display} $serverargs vt$vt"

@ -56,7 +56,7 @@ done
# Do first to avoid race conditions. # Do first to avoid race conditions.
if $consolekit; then if $consolekit; then
info "waiting for ConsoleKit to register X session." info 'waiting for ConsoleKit to register X session.'
sleep "$cktimeout" & clockpid=$! sleep "$cktimeout" & clockpid=$!
dbuspidfifo=$(mktemp --dry-run --tmpdir $name.XXXXXXXX) dbuspidfifo=$(mktemp --dry-run --tmpdir $name.XXXXXXXX)
if ! mkfifo "$dbuspidfifo"; then if ! mkfifo "$dbuspidfifo"; then
@ -86,11 +86,11 @@ if $consolekit; then
if wait "$clockpid" >& /dev/null if wait "$clockpid" >& /dev/null
then then
kill "$dbuspid" kill "$dbuspid"
error "ConsoleKit registration timed out." error 'ConsoleKit registration timed out.'
exit 1 exit 1
else else
kill "$dbuspid" kill "$dbuspid"
info "ConsoleKit registration succeeded." info 'ConsoleKit registration succeeded.'
exit 0 exit 0
fi fi
fi fi

@ -8,17 +8,17 @@
# #
# (An example:) # (An example:)
# binlist=( # binlist=(
# "~/.xsession" # Launch your X session, # '~/.xsession' # Launch your X session,
# "/bin/bash --login" # or just execute your shell, # '/bin/bash --login' # or just execute your shell,
# "/usr/bin/fbterm" # or start a frame buffer console, # '/usr/bin/fbterm' # or start a frame buffer console,
# "/usr/bin/cdm ~/.submenu.cdmrc" # or go to a submenu :) # '/usr/bin/cdm ~/.submenu.cdmrc' # or go to a submenu :)
# ) # )
# List all program display names, one-by-one matched with $binlist. # List all program display names, one-by-one matched with $binlist.
# Names with whitespaces should be quoted or escaped. # Names with whitespaces should be quoted or escaped.
# #
# (Continued example:) # (Continued example:)
# namelist=("X session" Console FBTerm "Sub menu") # namelist=('X session' Console FBTerm 'Sub menu')
# Type of the programs, one-by-one matched with $binlist. # Type of the programs, one-by-one matched with $binlist.
# `C' for *C*onsole programs, which would be `exec'ed. # `C' for *C*onsole programs, which would be `exec'ed.
@ -39,7 +39,7 @@ countfrom=0
display=0 display=0
# Where should the first X tty be spawned? # Where should the first X tty be spawned?
# special value 'keep' causes to run X in current tty # special value `keep' causes to run X in current tty.
xtty=7 xtty=7
# Should cdm(1) stick to the specified display? # Should cdm(1) stick to the specified display?

@ -1,4 +1,4 @@
if [[ "$(tty)" == /dev/tty* ]]; then if [[ "$(tty)" == '/dev/tty'* ]]; then
[[ -n "$CDM_SPAWN" ]] && return [[ -n "$CDM_SPAWN" ]] && return
[[ -z "$DISPLAY$SSH_TTY" ]] && exec cdm [[ -z "$DISPLAY$SSH_TTY" ]] && exec cdm
fi fi

Loading…
Cancel
Save