diff --git a/src/cdm b/src/cdm index 9e5b40e..83b6019 100755 --- a/src/cdm +++ b/src/cdm @@ -33,6 +33,10 @@ success="\e[1;32m==>\e[1;37m" reset="\e[0m" # Ignore SIGINT (^C) and SIGTSTP (^Z) trap "" 2 20 +userclientrc=$HOME/.xinitrc +sysclientrc=/etc/X11/xinit/xinitrc +# userserverrc=$HOME/.xserverrc +# sysserverrc=/etc/X11/xinit/xserverrc # Source cdm configuration if [[ -f /etc/cdmrc ]]; then @@ -69,15 +73,14 @@ if [[ -z $DIALOGRC ]]; then fi fi -### Based on FreeBSD's /etc/rc.subr -## +# Based on FreeBSD's /etc/rc.subr +# # checkyesno var # Test $1 variable, and warn if not set to YES or NO. # Return 0 if it's "yes" (et al), nonzero otherwise. # to make default yes, do "checkyesno var yes" -checkyesno() -{ +checkyesno() { local value=${!1} # debug "checkyesno: $1 is set to $value." if [[ -n $2 ]]; then @@ -118,7 +121,10 @@ else # Get the first empty display display=0 while [[ ${display} -lt 7 ]]; do - if xdpyinfo -display :${display}.0 &> /dev/null; then + if info=$(xdpyinfo -display :${display}.0 2>&1 1>/dev/null); then + let display=display+1 + elif [[ $info = No\ protocol\ specified* ]]; then + # Display is in use by another user let display=display+1 else break @@ -222,20 +228,33 @@ shutdownmenu() { xstart() { # Start X + if $(checkyesno usexinit); then + if [[ -f $userclientrc ]]; then + wm_bin="$userclientrc $wm_bin" + elif [[ -f $sysclientrc ]]; then + wm_bin="$sysclientrc $wm_bin" + fi + else + wm_bin="/usr/share/cdm/xinitrc $wm_bin" + fi + serverargs=":${display} ${serverargs} vt$((xtty+display))" if $(checkyesno loginshell); then - if [[ ${wm_bin} == "gnome-session" ]]; then - exec ck-launch-session bash --login -c "startx /usr/share/cdm/xinirc "$wm_bin" -- ${serverargs} &> /dev/null" & - else - exec bash --login -c "startx /usr/share/cdm/xinitrc "$wm_bin" -- ${serverargs} &> /dev/null" & - fi + # if [[ ${wm_bin} == "gnome-session" ]]; then + nohup ck-launch-session bash --login -c "startx $wm_bin -- ${serverargs}" &> /dev/null & + # else + # nohup bash --login -c "startx $wm_bin -- ${serverargs}" &> /dev/null & + # fi else - if [[ ${wm_bin} == "gnome-session" ]]; then - exec ck-launch-session startx /usr/share/cdm/xinitrc $wm_bin -- ${serverargs} &> /dev/null & - else - exec startx /usr/share/cdm/xinitrc $wm_bin -- ${serverargs} &> /dev/null & - fi + # if [[ ${wm_bin} == "gnome-session" ]]; then + nohup ck-launch-session startx $wm_bin -- ${serverargs} &> /dev/null & + # else + # nohup startx $wm_bin -- ${serverargs} &> /dev/null & + # fi fi + # There's some kind of race condition: + # despite the nohup, if we exit too quickly the session is killed. + sleep 2 } mainmenu diff --git a/src/cdmrc b/src/cdmrc index be96dea..26c11d0 100644 --- a/src/cdmrc +++ b/src/cdmrc @@ -7,10 +7,10 @@ theme=cdm countfrom=1 # List all WM binary names -wmbinlist=(awesome openbox-session) +wmbinlist=(awesome) # List all WM display names -wmdisplist=(Awesome Openbox) +wmdisplist=(Awesome) # Allow console login? allowconsole=yes @@ -50,7 +50,7 @@ courtney() { allowshutdown=no # Set specific display for user - # (Not used unless locktty=yes) + # (Not honored unless locktty=yes) # display=1 } @@ -61,7 +61,7 @@ courtney() { # Set default display display=0 -# Where should first X tty be spawned +# Where should first X tty be spawned? xtty=7 # Restrict tty? (By default, cdm increments X tty, this setting @@ -69,8 +69,23 @@ xtty=7 # setting the display=N option on a per-user basis.) locktty=no -# Enable login shell (fixes issues with some keymaps, uses bash) +# Enable login shell (fixes issues with some keymaps, uses bash). +# Note that your bash scripts won't have any terminal as stdin when +# started in this way. This may break some commands, including stty, +# unless you explicitly check for [ -t 0 ] or that every login shell +# is also interactive. However, we're sending stdout and stderr to +# /dev/null, so you won't see the complaints. loginshell=no -# Additional arguments to pass to X server +# When usexinit=yes, we use ~/.xinitrc when it exists or +# /etc/X11/xinit/xinitrc when it doesn't. These are passed the +# chosen window manager as $1; note that the stock xinitrc +# ignores this and always starts twm and three xterms. Your +# custom xinitrc should start the window manager supplied as +# $1 instead. If usexinit=no, then we instead call the chosen +# window manager directly. +usexinit=no + +# Additional arguments to pass to X server; it will be called as: +# exec /usr/bin/X :$display $serverargs vt$((xtty+display)) serverargs="-nolisten tcp -dpi 96" diff --git a/src/zzz-cdm-profile.sh b/src/zzz-cdm-profile.sh index 4c1909a..27cad19 100755 --- a/src/zzz-cdm-profile.sh +++ b/src/zzz-cdm-profile.sh @@ -1,4 +1,4 @@ -if [[ -z "$DISPLAY" ]]; then +if [[ -z "$DISPLAY" && -z "$SSH_TTY" && $(tty) = /dev/tty* ]]; then # Drop root to console if [[ $EUID -eq 0 ]]; then exec ${SHELL}