From 89b867eba1d835cdf0a08bb63508000f0d50373d Mon Sep 17 00:00:00 2001 From: Ghost1227 Date: Wed, 18 Nov 2009 06:48:29 -0600 Subject: [PATCH] Maybe fixed the incrementation bug? --- src/cdm | 92 ++++++++++++++++++++++++++++++------------------------- src/cdmrc | 16 +++++++--- 2 files changed, 62 insertions(+), 46 deletions(-) diff --git a/src/cdm b/src/cdm index e8c879d..6275a2c 100755 --- a/src/cdm +++ b/src/cdm @@ -57,20 +57,29 @@ else echo -e "${info} A valid theme file was not found, using system defaults.${reset}" fi -# Verify display exists -if `echo ""${display}"" | grep [^0-9] &> /dev/null`; then +# If X is already running and locktty=yes, activate it, +# otherwise, increment. +if [[ ${locktty} == "yes" ]]; then + # Verify display exists + if `echo ""${display}"" | grep [^0-9] &> /dev/null`; then + display=0 + fi + # Activate existing X session + if [[ `xdpyinfo -display :${display}.0 &> /dev/null` != "1" ]]; then + let tty=${display}+${xtty} + chvt ${tty} + exit 0 + fi +else + # Get the first empty display display=0 -fi - -# Check if X is already running -xdpyinfo -display :${display}.0 &> /dev/null && \ -echo $? &> /dev/null - -# If X is already running, activate it -if [[ `echo $?` != "1" ]]; then - let tty=${display}+${xtty} - chvt ${tty} - exit 0 + while ${display} < 7; do + if [[ `xdpyinfo -display :${display}.0 &> /dev/null` != "1" ]]; then + let display=${display}+1 + else + break + fi + done fi mainmenu() { @@ -108,38 +117,23 @@ mainmenu() { dialog --colors --backtitle "${name} v${ver}" --stdout \ --ok-label " Select " --cancel-label " Logout " \ --menu "Select Window Manager" 0 0 0 ${menu} - ) + ) + if [[ $? != 0 ]]; then + clear + exit 0 + fi fi # Set wm_bin - if [[ $? == 0 ]]; then - clear - if [[ ${wm} -eq ${console} ]]; then - ${SHELL} - exit 0 - elif [[ ${wm} -eq ${halt} ]]; then - shutdownmenu - else - export wm_bin="${wmbinlist[${wm}]}" - - # Start X - if [[ ${loginshell} == "yes" ]]; then - if [[ ${wm_bin} == "gnome-session" ]]; then - exec bash --login -c startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & - else - exec ck-launch-session bash --login -c startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & - fi - else - if [[ ${wm_bin} == "gnome-session" ]]; then - exec startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & - else - exec ck-launch-session startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & - fi - fi - fi - else - clear + clear + if [[ ${wm} -eq ${console} ]]; then + ${SHELL} exit 0 + elif [[ ${wm} -eq ${halt} ]]; then + shutdownmenu + else + export wm_bin="${wmbinlist[${wm}]}" + xstart fi } @@ -163,4 +157,20 @@ shutdownmenu() { fi } +xstart() { + # Start X + if [[ ${loginshell} == "yes" ]]; then + if [[ ${wm_bin} == "gnome-session" ]]; then + exec bash --login -c startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & + else + exec ck-launch-session bash --login -c startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & + fi + else + if [[ ${wm_bin} == "gnome-session" ]]; then + exec startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & + else + exec ck-launch-session startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & + fi + fi +} mainmenu diff --git a/src/cdmrc b/src/cdmrc index 83c2906..b12f0cf 100644 --- a/src/cdmrc +++ b/src/cdmrc @@ -22,9 +22,6 @@ rebootcommand='sudo shutdown -r now' # Set configuration for specific users? userconfig=(courtney) -# Set default display -display=0 - ########################## ### USER CONFIGURATION ### ########################## @@ -40,22 +37,31 @@ courtney() { wmdisplist=(Openbox) # Allow console login? - allowconsole=no + allowconsole=yes # Allow shutdown? allowshutdown=no # Set specific display for user - display=1 + # (Not used unless restricttty=yes) + # display=1 } ############################ ### SYSTEM CONFIGURATION ### ############################ +# Set default display +display=0 + # Set first X tty (default is 7) xtty=7 +# Restrict tty? (By default, cdm increments X tty, this setting +# allows administrators to lock users into one specific tty by +# setting the display=x option on a per-user basis.) +locktty=no + # Set default Window Manager defaultwm=xterm