Convert Gentoo-specific code to more universal form.

pull/7/head
Casper Ti. Vector 12 years ago
parent 6d05770aca
commit 6eb00db562

@ -33,12 +33,23 @@ longname='Console Display Manager'
ver='0.6'
trap '' SIGINT SIGTSTP
source /etc/init.d/functions.sh
# Exit functions.
# Helper functions.
warn() { printf ' \033[01;33m*\033[00m '; echo "$name: $*" > /dev/stderr; }
error() { printf ' \033[01;31m*\033[00m '; echo "$name: $*" > /dev/stderr; }
exitnormal() { exit 0; }
exiterror() { sleep 1; exit 1; }
yesno()
{
[ -z "$1" ] && return 1
case "$1" 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 "\`$1' is not a valid argument for \`yesno'; using \`no' for now."
esac
}
# Source cdm configurations.
@ -47,7 +58,7 @@ if [[ -n "$1" ]]; then
then
source "$1"
else
eerror "$name: config file \`$1' does not exist."
error "config file \`$1' does not exist."
exiterror
fi
elif [[ -f "$HOME/.cdmrc" ]]; then
@ -146,13 +157,13 @@ case ${flaglist[$binindex]} in
$(yesno consolekit) && launchflags="-c -t $cktimeout"
if ! eval cdm-xlaunch $launchflags -- $bin -- $serverargs; then
ewarn "$name: \`cdm-xlaunch' exited unsuccessfully."
warn "\`cdm-xlaunch' exited unsuccessfully."
exiterror
fi
;;
*)
eerror "$name: unknown flag: \`${flaglist[$binindex]}'."
error "unknown flag: \`${flaglist[$binindex]}'."
exiterror
;;
esac

@ -31,7 +31,9 @@
name=$(basename "$0")
consolekit=false
cktimeout=30
source /etc/init.d/functions.sh
info() { printf ' \033[01;32m*\033[00m '; echo "$name: $*"; }
error() { printf ' \033[01;31m*\033[00m '; echo "$name: $*" > /dev/stderr; }
args=$(getopt -n "$name" -o ct: -l consolekit,timeout: -- "$@") || exit 1
eval set -- "$args"
@ -54,11 +56,11 @@ done
# Do first to avoid race conditions.
if $consolekit; then
ebegin "$name: 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
eend "$name: failed to create FIFO \`$fifo'."
error "failed to create FIFO \`$fifo'."
exit 1
fi
@ -77,16 +79,17 @@ fi
# Conform to POSIX and do not use `>&' here.
sh -i -c "(startx $* > /dev/null 2>&1 &)"
# If wait(1) returns with a value >128, it was interrupted by kill(1), so registration was sucessful.
# If wait(1) returns with a value >128, it was interrupted by kill(1), so
# registration was sucessful.
if [[ -n "$clockpid" ]]; then
if wait "$clockpid" >& /dev/null
then
kill "$dbuspid"
eend "$name: ConsoleKit registration timed out."
error "ConsoleKit registration timed out."
exit 1
else
kill "$dbuspid"
eend 0
info "ConsoleKit registration succeeded."
exit 0
fi
fi

@ -38,7 +38,7 @@ countfrom=0
# Set default display.
display=0
# Where should first X tty be spawned?
# Where should the first X tty be spawned?
xtty=7
# Should cdm(1) stick to the specified display?

Loading…
Cancel
Save