Added shutdown option

pull/3/head
Ghost1227 15 years ago
parent 8e3e47dbc4
commit 04ac644b64

@ -21,7 +21,7 @@
# MA 02110-1301, USA. # MA 02110-1301, USA.
name="Console Display Manager" name="Console Display Manager"
ver="0.1" ver="0.2"
info="\e[1;34m==>\e[1;37m" info="\e[1;34m==>\e[1;37m"
error="\e[1;31m==>\e[1;37m" error="\e[1;31m==>\e[1;37m"
success="\e[1;32m==>\e[1;37m" success="\e[1;32m==>\e[1;37m"
@ -73,46 +73,86 @@ if [[ `echo $?` != "1" ]]; then
exit 0 exit 0
fi fi
# Generate main menu mainmenu() {
count=0 # Generate main menu
menu=$( count=0
while [[ ${count} -lt ${#wmdisplist[@]} ]]; do menu=$(
echo -ne "${count} ${wmdisplist[${count}]} " while [[ ${count} -lt ${#wmdisplist[@]} ]]; do
let count=count+1 echo -ne "${count} ${wmdisplist[${count}]} "
done let count=count+1
) done
)
# Check if console access is allowed # Check if console access is allowed
let console=${#wmdisplist[@]} if [[ ${allowconsole} == "yes" ]]; then
if [[ ${allowconsole} == "yes" ]]; then let console=${#wmdisplist[@]}
menu=$(echo -ne "${menu} ${console} Console ") menu=$(echo -ne "${menu} ${console} Console ")
fi fi
# Override dialog display if only one option is available # Check if shutdown access is allowed
if [[ ${allowconsole} != "yes" ]] && [[ ${#wmdisplist[@]} == 1 ]]; then if [[ ${allowshutdown} == "yes" ]]; then
wm=${wmbinlist[@]} if [[ ${allowconsole} != "yes" ]]; then
else let halt=${#wmdisplist[@]}
# Display selection dialog else
wm=$( let halt=${#wmdisplist[@]}+1
dialog --colors --backtitle "${name} v${ver}" --stdout \ fi
--ok-label " Select " --cancel-label " Logout " \ menu=$(echo -ne "${menu} ${halt} Shutdown ")
--menu "Select Window Manager" 0 0 0 ${menu} fi
)
fi
# Set wm_bin # Override dialog display if only one option is available
if [[ $? == 0 ]]; then if [[ ${allowconsole} != "yes" ]] && [[ ${#wmdisplist[@]} == 1 ]]; then
clear wm=${wmbinlist[@]}
if [[ ${wm} -eq ${console} ]]; then
${SHELL}
exit 0
else else
export wm_bin="${wmbinlist[${wm}]}" # Display selection dialog
wm=$(
dialog --colors --backtitle "${name} v${ver}" --stdout \
--ok-label " Select " --cancel-label " Logout " \
--menu "Select Window Manager" 0 0 0 ${menu}
)
fi
# Start X # Set wm_bin
exec ck-launch-session startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null & 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
exec ck-launch-session bash --login -c startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null &
else
exec ck-launch-session startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null &
fi
fi
else
clear
exit 0
fi fi
else }
clear
exit 0 shutdownmenu() {
fi # Display shutdown dialog
haltopt=$(
dialog --colors --backtitle "${name} v${ver}" --stdout \
--ok-label " Select " --cancel-label " Cancel " \
--menu "Shutdown" 0 0 0 0 Shutdown 1 Reboot
)
if [[ $? == 0 ]]; then
clear
if [[ ${haltopt} -eq 0 ]]; then
${shutdowncommand}
else
${rebootcommand}
fi
else
mainmenu
fi
}
mainmenu

@ -6,18 +6,21 @@
theme=cdm theme=cdm
# List all WM binary names # List all WM binary names
# globalbinlist=(gnome-session openbox-session awesome)
wmbinlist=(awesome openbox-session) wmbinlist=(awesome openbox-session)
# List all WM display names # List all WM display names
# globaldisplist=(Gnome Openbox Awesome)
wmdisplist=(Awesome Openbox) wmdisplist=(Awesome Openbox)
# Allow console login? # Allow console login?
allowconsole=yes allowconsole=yes
# Allow shutdown?
allowshutdown=yes
shutdowncommand='sudo shutdown -h now'
rebootcommand='sudo shutdown -r now'
# Set configuration for specific users? # Set configuration for specific users?
# userconfig=(courtney) userconfig=(courtney)
# Set default display # Set default display
display=0 display=0
@ -26,22 +29,25 @@ display=0
### USER CONFIGURATION ### ### USER CONFIGURATION ###
########################## ##########################
# courtney() { courtney() {
# Set CDM theme # Set CDM theme
# theme=lime theme=lime
# List user allowed WM binary names # List user allowed WM binary names
# wmbinlist=(openbox-session) wmbinlist=(openbox-session)
# List user allowed WM display names # List user allowed WM display names
# wmdisplist=(Openbox) wmdisplist=(Openbox)
# Allow console login? # Allow console login?
# allowconsole=no allowconsole=no
# Allow shutdown?
allowshutdown=no
# Set specific display for user # Set specific display for user
# display=1 display=1
# } }
############################ ############################
### SYSTEM CONFIGURATION ### ### SYSTEM CONFIGURATION ###
@ -53,6 +59,9 @@ xtty=7
# Set default Window Manager # Set default Window Manager
defaultwm=xterm defaultwm=xterm
# Enable login shell (fixes issues with some keymaps, requires bash)
loginshell=no
################################### ###################################
### DO NOT EDIT BELOW THIS LINE ### ### DO NOT EDIT BELOW THIS LINE ###
################################### ###################################

Loading…
Cancel
Save