Skip to content

Commit

Permalink
Minor improvements to coding style.
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperVector committed Nov 9, 2012
1 parent 2ea165a commit 7aa1654
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
32 changes: 15 additions & 17 deletions src/cdm
Expand Up @@ -48,7 +48,7 @@ yesno()
case "$value" in
[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;;
*) warn "Invalid value for \`$1'; falling back to \`no' for now.";;
*) warn "invalid value for \`$1'; falling back to \`no' for now.";;
esac
}

Expand Down Expand Up @@ -83,7 +83,7 @@ cktimeout=${cktimeout:-30}
serverargs=${serverargs:-'-nolisten tcp'}

# 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
binlist=($(find /etc/X11/Sessions -maxdepth 1 -type f))
Expand Down Expand Up @@ -121,13 +121,14 @@ 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.
# See also the example shell profile file shipped with the cdm package.

# 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.

trap - SIGINT SIGTSTP
Expand All @@ -138,12 +139,10 @@ case ${flaglist[$binindex]} in
[Xx])
clear

# If X is already running and locktty=yes, activate it
if $(yesno locktty); then
if xdpyinfo -display ":$display.0" &> /dev/null; then
chvt "$((display+xtty))"
exitnormal
fi
# If X is already running and locktty=yes, activate it.
if $(yesno locktty) && xdpyinfo -display ":$display.0" &> /dev/null; then
chvt "$((display+xtty))"
exitnormal
fi

# Get the first empty display.
Expand All @@ -161,17 +160,16 @@ case ${flaglist[$binindex]} in
fi
done

# run X in current tty
if [[ $xtty == "keep" ]]; then
vt=$(tty)
vt=${vt#/dev/}
if [[ $vt != tty* ]]; then
error "error: invalid TTY"
# Support for running X in current tty.
if [[ $xtty == 'keep' ]]; then
vt="$(tty)"
if [[ "$vt" != '/dev/tty'* ]]; then
error 'invalid TTY.'
exiterror
fi
vt=${vt#tty}
vt="${vt#/dev/tty}"
else
vt=$((xtty+display))
vt="$((xtty+display))"
fi

serverargs=":${display} $serverargs vt$vt"
Expand Down
6 changes: 3 additions & 3 deletions src/cdm-xlaunch
Expand Up @@ -56,7 +56,7 @@ done

# Do first to avoid race conditions.
if $consolekit; then
info "waiting for ConsoleKit to register X session."
info 'waiting for ConsoleKit to register X session.'
sleep "$cktimeout" & clockpid=$!
dbuspidfifo=$(mktemp --dry-run --tmpdir $name.XXXXXXXX)
if ! mkfifo "$dbuspidfifo"; then
Expand Down Expand Up @@ -86,11 +86,11 @@ if $consolekit; then
if wait "$clockpid" >& /dev/null
then
kill "$dbuspid"
error "ConsoleKit registration timed out."
error 'ConsoleKit registration timed out.'
exit 1
else
kill "$dbuspid"
info "ConsoleKit registration succeeded."
info 'ConsoleKit registration succeeded.'
exit 0
fi
fi
Expand Down
12 changes: 6 additions & 6 deletions src/cdmrc
Expand Up @@ -8,17 +8,17 @@
#
# (An example:)
# binlist=(
# "~/.xsession" # Launch your X session,
# "/bin/bash --login" # or just execute your shell,
# "/usr/bin/fbterm" # or start a frame buffer console,
# "/usr/bin/cdm ~/.submenu.cdmrc" # or go to a submenu :)
# '~/.xsession' # Launch your X session,
# '/bin/bash --login' # or just execute your shell,
# '/usr/bin/fbterm' # or start a frame buffer console,
# '/usr/bin/cdm ~/.submenu.cdmrc' # or go to a submenu :)
# )

# List all program display names, one-by-one matched with $binlist.
# Names with whitespaces should be quoted or escaped.
#
# (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.
# `C' for *C*onsole programs, which would be `exec'ed.
Expand All @@ -39,7 +39,7 @@ countfrom=0
display=0

# 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

# Should cdm(1) stick to the specified display?
Expand Down
2 changes: 1 addition & 1 deletion src/profile.sh
@@ -1,4 +1,4 @@
if [[ "$(tty)" == /dev/tty* ]]; then
if [[ "$(tty)" == '/dev/tty'* ]]; then
[[ -n "$CDM_SPAWN" ]] && return
[[ -z "$DISPLAY$SSH_TTY" ]] && exec cdm
fi
Expand Down

0 comments on commit 7aa1654

Please sign in to comment.