Added shutdown option

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

@ -21,7 +21,7 @@
# MA 02110-1301, USA.
name="Console Display Manager"
ver="0.1"
ver="0.2"
info="\e[1;34m==>\e[1;37m"
error="\e[1;31m==>\e[1;37m"
success="\e[1;32m==>\e[1;37m"
@ -73,46 +73,86 @@ if [[ `echo $?` != "1" ]]; then
exit 0
fi
# Generate main menu
count=0
menu=$(
while [[ ${count} -lt ${#wmdisplist[@]} ]]; do
echo -ne "${count} ${wmdisplist[${count}]} "
let count=count+1
done
)
mainmenu() {
# Generate main menu
count=0
menu=$(
while [[ ${count} -lt ${#wmdisplist[@]} ]]; do
echo -ne "${count} ${wmdisplist[${count}]} "
let count=count+1
done
)
# Check if console access is allowed
let console=${#wmdisplist[@]}
if [[ ${allowconsole} == "yes" ]]; then
menu=$(echo -ne "${menu} ${console} Console ")
fi
# Check if console access is allowed
if [[ ${allowconsole} == "yes" ]]; then
let console=${#wmdisplist[@]}
menu=$(echo -ne "${menu} ${console} Console ")
fi
# Override dialog display if only one option is available
if [[ ${allowconsole} != "yes" ]] && [[ ${#wmdisplist[@]} == 1 ]]; then
wm=${wmbinlist[@]}
else
# 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
# Check if shutdown access is allowed
if [[ ${allowshutdown} == "yes" ]]; then
if [[ ${allowconsole} != "yes" ]]; then
let halt=${#wmdisplist[@]}
else
let halt=${#wmdisplist[@]}+1
fi
menu=$(echo -ne "${menu} ${halt} Shutdown ")
fi
# Set wm_bin
if [[ $? == 0 ]]; then
clear
if [[ ${wm} -eq ${console} ]]; then
${SHELL}
exit 0
# Override dialog display if only one option is available
if [[ ${allowconsole} != "yes" ]] && [[ ${#wmdisplist[@]} == 1 ]]; then
wm=${wmbinlist[@]}
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
exec ck-launch-session startx /usr/share/cdm/xinitrc -- :${display} &> /dev/null &
# 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
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
else
clear
exit 0
fi
}
shutdownmenu() {
# 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
# List all WM binary names
# globalbinlist=(gnome-session openbox-session awesome)
wmbinlist=(awesome openbox-session)
# List all WM display names
# globaldisplist=(Gnome Openbox Awesome)
wmdisplist=(Awesome Openbox)
# Allow console login?
allowconsole=yes
# Allow shutdown?
allowshutdown=yes
shutdowncommand='sudo shutdown -h now'
rebootcommand='sudo shutdown -r now'
# Set configuration for specific users?
# userconfig=(courtney)
userconfig=(courtney)
# Set default display
display=0
@ -26,22 +29,25 @@ display=0
### USER CONFIGURATION ###
##########################
# courtney() {
courtney() {
# Set CDM theme
# theme=lime
theme=lime
# List user allowed WM binary names
# wmbinlist=(openbox-session)
wmbinlist=(openbox-session)
# List user allowed WM display names
# wmdisplist=(Openbox)
wmdisplist=(Openbox)
# Allow console login?
# allowconsole=no
allowconsole=no
# Allow shutdown?
allowshutdown=no
# Set specific display for user
# display=1
# }
display=1
}
############################
### SYSTEM CONFIGURATION ###
@ -53,6 +59,9 @@ xtty=7
# Set default Window Manager
defaultwm=xterm
# Enable login shell (fixes issues with some keymaps, requires bash)
loginshell=no
###################################
### DO NOT EDIT BELOW THIS LINE ###
###################################

Loading…
Cancel
Save