Skip to content
Browse files

after discussion - use spaces instead of tabs

  • Loading branch information...
1 parent 277ed46 commit 1bb3691d379d0457909a97ee13f112b3fd9dc09a Jakub Klinkovský committed Sep 12, 2012
Showing with 144 additions and 144 deletions.
  1. +99 −99 src/cdm
  2. +43 −43 src/cdm-xlaunch
  3. +2 −2 src/profile.sh
View
198 src/cdm
@@ -42,30 +42,30 @@ exitnormal() { exit 0; }
exiterror() { sleep 1; exit 1; }
yesno()
{
- [ -z "$1" ] && return 1
- eval value=\$${1}
-
- 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.";;
- esac
+ [ -z "$1" ] && return 1
+ eval value=\$${1}
+
+ 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.";;
+ esac
}
# Source cdm configurations.
if [[ -n "$1" ]]; then
- if [[ -f "$1" ]]
- then
- source "$1"
- else
- error "config file \`$1' does not exist."
- exiterror
- fi
+ if [[ -f "$1" ]]
+ then
+ source "$1"
+ else
+ error "config file \`$1' does not exist."
+ exiterror
+ fi
elif [[ -f "$HOME/.cdmrc" ]]; then
- source "$HOME/.cdmrc"
+ source "$HOME/.cdmrc"
elif [[ -f /etc/cdmrc ]]; then
- source /etc/cdmrc
+ source /etc/cdmrc
fi
# Default options.
@@ -86,103 +86,103 @@ cktimeout=${cktimeout:-30}
# if binlist if not explicitly set in cdmrc.
if [[ "${#binlist[@]}" == 0 ]]; then
- binlist=($(ls /etc/X11/Sessions))
- flaglist=($(sed 's/[[:digit:]]\+/X/g' <<< ${!flaglist[*]}))
- namelist=(${binlist[@]^})
+ binlist=($(ls /etc/X11/Sessions))
+ flaglist=($(sed 's/[[:digit:]]\+/X/g' <<< ${!flaglist[*]}))
+ namelist=(${binlist[@]^})
fi
# Generate the main menu.
menu=()
for ((count = 0; count < ${#namelist[@]}; count++)); do
- menu=("${menu[@]}" "$((count+countfrom))" "${namelist[${count}]}")
+ menu=("${menu[@]}" "$((count+countfrom))" "${namelist[${count}]}")
done
# Override dialog display if only one option is available.
if [[ "$count" == 1 ]]; then
- binindex=0
+ 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
- clear
- exitnormal
- fi
+ # 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
+ clear
+ exitnormal
+ fi
fi
# Run $bin according to its flag.
let binindex-=countfrom
bin="${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.
- # See also the example shell profile file shipped with the cdm package.
- CDM_SPAWN=$$ exec $bin
- ;;
-
- # *X* programs.
- [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
- fi
-
- # Get the first empty display.
- display=0
- while ((display < 7)); do
- if dpyinfo=$(xdpyinfo -display ":$display.0" 2>&1 1>/dev/null) ||
- # Display is in use by another user.
- [[ "$dpyinfo" == 'No protocol specified'* ]] ||
- # Invalid MIT cookie.
- [[ "$dpyinfo" == 'Invalid MIT'* ]]
- then
- let display+=1
- else
- break
- fi
- done
-
- # run X in current tty
- if [[ $xtty == "keep" ]]; then
- vt=$(tty)
- vt=${vt#/dev/}
- if [[ $vt != tty* ]]; then
- error "error: invalid TTY"
- exiterror
- fi
- vt=${vt#tty}
- else
- vt=$((xtty+display))
- fi
-
- serverargs=":${display} $serverargs vt$vt"
-
- $(yesno consolekit) && launchflags="-c -t $cktimeout"
- if ! eval cdm-xlaunch $launchflags -- $bin -- $serverargs; then
- warn "\`cdm-xlaunch' exited unsuccessfully."
- exiterror
- else
- exitnormal
- fi
- ;;
-
- *)
- error "unknown flag: \`${flaglist[$binindex]}'."
- exiterror
- ;;
+ # *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.
+ CDM_SPAWN=$$ exec $bin
+ ;;
+
+ # *X* programs.
+ [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
+ fi
+
+ # Get the first empty display.
+ display=0
+ while ((display < 7)); do
+ if dpyinfo=$(xdpyinfo -display ":$display.0" 2>&1 1>/dev/null) ||
+ # Display is in use by another user.
+ [[ "$dpyinfo" == 'No protocol specified'* ]] ||
+ # Invalid MIT cookie.
+ [[ "$dpyinfo" == 'Invalid MIT'* ]]
+ then
+ let display+=1
+ else
+ break
+ fi
+ done
+
+ # run X in current tty
+ if [[ $xtty == "keep" ]]; then
+ vt=$(tty)
+ vt=${vt#/dev/}
+ if [[ $vt != tty* ]]; then
+ error "error: invalid TTY"
+ exiterror
+ fi
+ vt=${vt#tty}
+ else
+ vt=$((xtty+display))
+ fi
+
+ serverargs=":${display} $serverargs vt$vt"
+
+ $(yesno consolekit) && launchflags="-c -t $cktimeout"
+ if ! eval cdm-xlaunch $launchflags -- $bin -- $serverargs; then
+ warn "\`cdm-xlaunch' exited unsuccessfully."
+ exiterror
+ else
+ exitnormal
+ fi
+ ;;
+
+ *)
+ error "unknown flag: \`${flaglist[$binindex]}'."
+ exiterror
+ ;;
esac
-# vim:set ts=4 sw=4 noet:
+# vim:set ts=4 sw=4 et:
View
86 src/cdm-xlaunch
@@ -39,41 +39,41 @@ args=$(getopt -n "$name" -o ct: -l consolekit,timeout: -- "$@") || exit 1
eval set -- "$args"
for arg in "$@"
do
- case $arg in
- '--consolekit' | '-c')
- consolekit=true; shift
- ;;
- '--timeout' | '-t')
- shift
- cktimeout=$1; shift
- ;;
- '--')
- shift
- break
- ;;
- esac
+ case $arg in
+ '--consolekit' | '-c')
+ consolekit=true; shift
+ ;;
+ '--timeout' | '-t')
+ shift
+ cktimeout=$1; shift
+ ;;
+ '--')
+ shift
+ break
+ ;;
+ esac
done
# Do first to avoid race conditions.
if $consolekit; then
- info "waiting for ConsoleKit to register X session."
- sleep "$cktimeout" & clockpid=$!
- dbuspidfifo=$(mktemp --dry-run --tmpdir $name.XXXXXXXX)
- if ! mkfifo "$dbuspidfifo"; then
- error "failed to create FIFO \`$fifo'."
- exit 1
- fi
+ info "waiting for ConsoleKit to register X session."
+ sleep "$cktimeout" & clockpid=$!
+ dbuspidfifo=$(mktemp --dry-run --tmpdir $name.XXXXXXXX)
+ if ! mkfifo "$dbuspidfifo"; then
+ error "failed to create FIFO \`$fifo'."
+ exit 1
+ fi
- (dbus-monitor --system 'type=signal,interface=org.freedesktop.ConsoleKit.Seat,member=SessionAdded' & echo $! > "$dbuspidfifo") |
- sed -un 's@[[:space:]]*object path \"\(/[a-zA-Z0-9/]*\)\"@\1@p' | while read object; do
- if dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' "$object" 'org.freedesktop.ConsoleKit.Session.GetX11Display' |
- grep -qF "$display"
- then
- kill "$clockpid"
- break
- fi
- done &
- dbuspid=$(<"$dbuspidfifo"); rm -f "$dbuspidfifo"
+ (dbus-monitor --system 'type=signal,interface=org.freedesktop.ConsoleKit.Seat,member=SessionAdded' & echo $! > "$dbuspidfifo") |
+ sed -un 's@[[:space:]]*object path \"\(/[a-zA-Z0-9/]*\)\"@\1@p' | while read object; do
+ if dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' "$object" 'org.freedesktop.ConsoleKit.Session.GetX11Display' |
+ grep -qF "$display"
+ then
+ kill "$clockpid"
+ break
+ fi
+ done &
+ dbuspid=$(<"$dbuspidfifo"); rm -f "$dbuspidfifo"
fi
# Conform to POSIX and do not use `>&' here.
@@ -82,18 +82,18 @@ nohup startx $* > /dev/null 2>&1 &
# If wait(1) returns with a value >128, it was interrupted by kill(1),
# so registration was sucessful.
if $consolekit; then
- if [[ -n "$clockpid" ]]; then
- if wait "$clockpid" >& /dev/null
- then
- kill "$dbuspid"
- error "ConsoleKit registration timed out."
- exit 1
- else
- kill "$dbuspid"
- info "ConsoleKit registration succeeded."
- exit 0
- fi
- fi
+ if [[ -n "$clockpid" ]]; then
+ if wait "$clockpid" >& /dev/null
+ then
+ kill "$dbuspid"
+ error "ConsoleKit registration timed out."
+ exit 1
+ else
+ kill "$dbuspid"
+ info "ConsoleKit registration succeeded."
+ exit 0
+ fi
+ fi
fi
-# vim:set ts=4 sw=4 noet:
+# vim:set ts=4 sw=4 et:
View
4 src/profile.sh
@@ -1,5 +1,5 @@
if [[ "$(tty)" == /dev/tty* ]]; then
- [[ -n "$CDM_SPAWN" ]] && return
- [[ -z "$DISPLAY$SSH_TTY" ]] && exec cdm
+ [[ -n "$CDM_SPAWN" ]] && return
+ [[ -z "$DISPLAY$SSH_TTY" ]] && exec cdm
fi

0 comments on commit 1bb3691

Please sign in to comment.
Something went wrong with that request. Please try again.