Merge pull request #9 from lahwaacz/master

added option to run X in current tty
This commit is contained in:
Ghost1227 2012-09-12 07:35:46 -07:00
commit 0be38c2ea1
5 changed files with 47 additions and 33 deletions

View File

22
src/cdm
View File

@ -132,15 +132,14 @@ case ${flaglist[$binindex]} in
[Xx])
clear
# If X is already running and locktty=yes, activate it,
# otherwise increment.
# If X is already running and locktty=yes, activate it
if $(yesno locktty); then
# Activate existing X session.
if xdpyinfo -display ":$display.0" &> /dev/null; then
chvt "$((display+xtty))"
exitnormal
fi
else
fi
# Get the first empty display.
display=0
while ((display < 7)); do
@ -155,8 +154,21 @@ case ${flaglist[$binindex]} in
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
serverargs=":${display} $serverargs vt$((xtty+display))"
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

View File

@ -77,11 +77,12 @@ if $consolekit; then
fi
# Conform to POSIX and do not use `>&' here.
sh -i -c "(startx $* > /dev/null 2>&1 &)"
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 [[ -n "$clockpid" ]]; then
if $consolekit; then
if [[ -n "$clockpid" ]]; then
if wait "$clockpid" >& /dev/null
then
kill "$dbuspid"
@ -92,5 +93,5 @@ if [[ -n "$clockpid" ]]; then
info "ConsoleKit registration succeeded."
exit 0
fi
fi
fi

View File

@ -39,6 +39,7 @@ countfrom=0
display=0
# Where should the first X tty be spawned?
# special value 'keep' causes to run X in current tty
xtty=7
# Should cdm(1) stick to the specified display?

View File

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