Skip to content

Commit

Permalink
Simplify the theme mechanism, just specify an absolute path to a
Browse files Browse the repository at this point in the history
dialogrc file as $dialogrc, and let dialog(1) worry about the validity
of $dialogrc.

Rename variables:
    $theme -> $dialogrc: make the low level things more transparent.
    $cosolekittime -> $cktimeout: indicate "timeout" here.
  • Loading branch information
CasperVector committed Apr 7, 2012
1 parent 64b5c81 commit a7de917
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
38 changes: 12 additions & 26 deletions src/cdm
Expand Up @@ -35,6 +35,8 @@ success="\e[1;32m==>\e[1;37m"
reset="\e[0m"
# Ignore SIGINT (^C) and SIGTSTP (^Z)
trap "" 2 20

dialogrc=${dialogrc:-}
userclientrc=$HOME/.xinitrc
sysclientrc=/etc/X11/xinit/xinitrc
# userserverrc=$HOME/.xserverrc
Expand All @@ -51,7 +53,7 @@ if [[ -f /etc/X11/cdm/cdmrc ]]; then
let count=count+1
done
countfrom=${countfrom:-0}
consolekittime=${consolekittime:-30}
cktimeout=${cktimeout:-30}
else
echo -e "${error} ERROR: A valid cdm configuration was not found!${reset}"
echo -e "${info} Logging out.${reset}"
Expand All @@ -67,23 +69,6 @@ if [[ "${#wmbinlist[@]}" -eq 0 ]]; then
wmdisplist=($(echo ${wmbinlist[@]^}))
fi

unset DIALOGRC
# Source theme file
if [[ ! -z ${theme} ]]; then
if [[ -f /usr/share/cdm/themes/${theme} ]]; then
DIALOGRC=/usr/share/cdm/themes/${theme}
else
echo -e "${info} Theme file ${theme} is invalid, reverting to default theme.${reset}"
fi
fi
if [[ -z $DIALOGRC ]]; then
if [[ -f /usr/share/cdm/themes/default ]]; then
DIALOGRC=/usr/share/cdm/themes/default
else
echo -e "${info} A valid theme file was not found, using system defaults.${reset}"
fi
fi

# Based on FreeBSD's /etc/rc.subr
#
# checkyesno var
Expand Down Expand Up @@ -172,14 +157,14 @@ mainmenu() {
let halt=halt+countfrom
menu="${menu} ${halt} Shutdown "
fi

# Override dialog display if only one option is available
if ! $(checkyesno allowconsole) && ! $(checkyesno allowshutdown) && [[ ${#wmdisplist[@]} == 1 ]]; then
wm=$countfrom
else
# Display selection dialog
wm=$(
DIALOGRC="$DIALOGRC" dialog --colors \
DIALOGRC="$dialogrc" dialog --colors \
--backtitle "${name} v${ver}" --stdout \
--ok-label " Select " --cancel-label " Logout " \
--menu "Select Window Manager" 0 0 0 ${menu}
Expand Down Expand Up @@ -219,12 +204,12 @@ shutdownmenu() {

# Display shutdown dialog
haltopt=$(
DIALOGRC="$DIALOGRC" dialog --colors \
DIALOGRC="$dialogrc" dialog --colors \
--backtitle "${name} v${ver}" --stdout \
--ok-label " Select " --cancel-label " Cancel " \
--menu "Shutdown" 0 0 0 ${haltmenu}
)

if [[ $? == 0 ]]; then
clear
if [[ ${haltopt} -eq $countfrom ]]; then
Expand Down Expand Up @@ -256,13 +241,13 @@ xstart() {
serverargs=":${display} ${serverargs} vt$((xtty+display))"

if $(checkyesno consolekit); then #do first to avoid race conditions
echo -ne "${info} Waiting for ConsoleKit to register X session (timeout ${consolekittime}s)..."
echo -ne "${info} Waiting for ConsoleKit to register X session (timeout ${cktimeout}s)..."

sleep $consolekittime &
sleep $cktimeout &
clockpid=$!

trap "echo -e \"Registered! ${reset}\"" USR1

#have to store pid of dbus-monitor this way since dbus-monitor will run until killed.
fifo=$(mktemp --dry-run)
mkfifo --mode=700 $fifo
Expand Down Expand Up @@ -300,3 +285,4 @@ xstart() {
exit 0
}
mainmenu

4 changes: 2 additions & 2 deletions src/cdmrc
Expand Up @@ -3,7 +3,7 @@
############################

# Set CDM theme and dialog options
theme=cdm
dialogrc=/usr/share/cdm/themes/cdm
countfrom=1

# List all WM binary names
Expand Down Expand Up @@ -89,7 +89,7 @@ loginshell=no
consolekit=yes

# Timeout for waiting for X session to register with consoleKit
consolekittime=30
cktimeout=30

# Additional arguments to pass to X server
# When usexinit=yes, we use ~/.xinitrc when it exists or /etc/X11/xinit/xinitrc
Expand Down

0 comments on commit a7de917

Please sign in to comment.