added option to run X in current TTY

This commit is contained in:
Jakub Klinkovský 2012-09-12 00:06:55 +02:00
parent 4327bd6cf2
commit 97afbbf072
4 changed files with 46 additions and 33 deletions

View File

22
src/cdm
View File

@ -132,15 +132,14 @@ 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
# otherwise increment.
if $(yesno locktty); then if $(yesno locktty); then
# Activate existing X session.
if 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
else fi
# Get the first empty display. # Get the first empty display.
display=0 display=0
while ((display < 7)); do while ((display < 7)); do
@ -155,8 +154,21 @@ case ${flaglist[$binindex]} in
break break
fi fi
done 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 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" $(yesno consolekit) && launchflags="-c -t $cktimeout"
if ! eval cdm-xlaunch $launchflags -- $bin -- $serverargs; then if ! eval cdm-xlaunch $launchflags -- $bin -- $serverargs; then

View File

@ -77,11 +77,12 @@ if $consolekit; then
fi fi
# Conform to POSIX and do not use `>&' here. # 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), # If wait(1) returns with a value >128, it was interrupted by kill(1),
# so registration was sucessful. # so registration was sucessful.
if [[ -n "$clockpid" ]]; then if $consolekit; then
if [[ -n "$clockpid" ]]; then
if wait "$clockpid" >& /dev/null if wait "$clockpid" >& /dev/null
then then
kill "$dbuspid" kill "$dbuspid"
@ -92,5 +93,5 @@ if [[ -n "$clockpid" ]]; then
info "ConsoleKit registration succeeded." info "ConsoleKit registration succeeded."
exit 0 exit 0
fi fi
fi
fi fi

View File

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