Merge pull request #9 from lahwaacz/master
added option to run X in current tty
This commit is contained in:
commit
0be38c2ea1
48
src/cdm
48
src/cdm
@ -132,31 +132,43 @@ 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
|
||||||
|
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
|
else
|
||||||
# Get the first empty display.
|
vt=$((xtty+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
|
|
||||||
fi
|
fi
|
||||||
serverargs=":${display} $serverargs vt$((xtty+display))"
|
|
||||||
|
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
|
||||||
|
@ -77,20 +77,21 @@ 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 wait "$clockpid" >& /dev/null
|
if [[ -n "$clockpid" ]]; then
|
||||||
then
|
if wait "$clockpid" >& /dev/null
|
||||||
kill "$dbuspid"
|
then
|
||||||
error "ConsoleKit registration timed out."
|
kill "$dbuspid"
|
||||||
exit 1
|
error "ConsoleKit registration timed out."
|
||||||
else
|
exit 1
|
||||||
kill "$dbuspid"
|
else
|
||||||
info "ConsoleKit registration succeeded."
|
kill "$dbuspid"
|
||||||
exit 0
|
info "ConsoleKit registration succeeded."
|
||||||
fi
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ countfrom=0
|
|||||||
display=0
|
display=0
|
||||||
|
|
||||||
# Where should the first X tty be spawned?
|
# Where should the first X tty be spawned?
|
||||||
|
# special value 'keep' causes to run X in current tty
|
||||||
xtty=7
|
xtty=7
|
||||||
|
|
||||||
# Should cdm(1) stick to the specified display?
|
# Should cdm(1) stick to the specified display?
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user