[22966] | 1 | #!/bin/athena/bash --norc |
---|
| 2 | # Global xsession file for bash users |
---|
| 3 | # Accepts one optional argument, either "nocalls" (use no user files) |
---|
| 4 | # or "dash" (use old dash-based interface). |
---|
| 5 | # |
---|
| 6 | # $Id: xsession.bash,v 1.1 2008-05-08 18:02:32 ghudson Exp $ |
---|
| 7 | |
---|
| 8 | initdir=/usr/lib/init |
---|
| 9 | gconftool=/usr/bin/gconftool-2 |
---|
| 10 | |
---|
| 11 | source_if_exists() { |
---|
| 12 | [ -r "$1" ] && . "$1" |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | echo_if_verbose() { |
---|
| 16 | [ t = "$verbose_login" ] && echo "$@" |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | # Determine whether to use user customizations: use no customization files |
---|
| 20 | # ONLY if the single argument "nocalls" was provided to xsession (e.g., if |
---|
| 21 | # the user selected the "Ignore your customizations" option from the |
---|
| 22 | # initial xlogin menu). |
---|
| 23 | |
---|
| 24 | case $# in |
---|
| 25 | 0) |
---|
| 26 | ;; |
---|
| 27 | 1) |
---|
| 28 | if [ nocalls = "$1" -o x-nocalls = "x$1" ]; then |
---|
| 29 | echo -n "xsession: Running standard xsession " |
---|
| 30 | echo "with NO user configuration files..." |
---|
| 31 | export NOCALLS= |
---|
| 32 | elif [ dash = "$1" ]; then |
---|
| 33 | echo -n "xsession: Running standard xsession " |
---|
| 34 | echo "with dash-based interface..." |
---|
| 35 | export ATHENA_DASH_INTERFACE=t |
---|
| 36 | else |
---|
| 37 | bad_args= |
---|
| 38 | fi |
---|
| 39 | ;; |
---|
| 40 | *) |
---|
| 41 | bad_args=t |
---|
| 42 | ;; |
---|
| 43 | esac |
---|
| 44 | |
---|
| 45 | if [ t = "$bad_args" ]; then |
---|
| 46 | echo "xsession: Arguments ($*) not recognized." |
---|
| 47 | echo "Running standard xsession with user configuration files..." |
---|
| 48 | unset NOCALLS |
---|
| 49 | unset bad_args |
---|
| 50 | fi |
---|
| 51 | |
---|
| 52 | # Echo messages unless user has ~/.hushlogin file AND the session was not |
---|
| 53 | # started using the xlogin "SYSTEM" option. |
---|
| 54 | |
---|
| 55 | if [ ! -r "$HOME/.hushlogin" -o "${NOCALLS+set}" = set ]; then |
---|
| 56 | verbose_login=t |
---|
| 57 | fi |
---|
| 58 | |
---|
| 59 | # Use old dash-based interface if the user has |
---|
| 60 | # ~/.athena_dash_interface and the session was not started with |
---|
| 61 | # NOCALLS. |
---|
| 62 | |
---|
| 63 | if [ -r "$HOME/.athena_dash_interface" -a "${NOCALLS+set}" != set ]; then |
---|
| 64 | export ATHENA_DASH_INTERFACE= |
---|
| 65 | fi |
---|
| 66 | |
---|
| 67 | # ******************* ENVIRONMENT SETUP ******************* |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | # Identify this as a window session. |
---|
| 71 | |
---|
| 72 | export XSESSION=$$ |
---|
| 73 | |
---|
| 74 | # The ~/.bashrc file sets environment variables, attaches lockers, and sets |
---|
| 75 | # the command search path. |
---|
| 76 | |
---|
| 77 | echo_if_verbose "Setting up environment..." |
---|
| 78 | |
---|
| 79 | # Source the system startup scripts if necessary. |
---|
| 80 | source_if_exists /etc/profile |
---|
| 81 | source_if_exists /etc/bashrc |
---|
| 82 | source_if_exists /etc/bash.bashrc |
---|
| 83 | |
---|
| 84 | if [ "${NOCALLS+set}" = set ]; then |
---|
| 85 | source_if_exists "$initdir/bashrc" |
---|
| 86 | else |
---|
| 87 | if [ -r "$HOME/.bashrc" ]; then |
---|
| 88 | . "$HOME/.bashrc" |
---|
| 89 | else |
---|
| 90 | source_if_exists "$initdir/bashrc" |
---|
| 91 | fi |
---|
| 92 | fi |
---|
| 93 | |
---|
| 94 | if [ "${ATHENA_DASH_INTERFACE+set}" = set ]; then |
---|
| 95 | default_windowmanager=mwm |
---|
| 96 | terminal='xterm -geometry 80x48+0+38' |
---|
| 97 | else |
---|
| 98 | default_windowmanager=metacity |
---|
| 99 | terminal='gnome-terminal --geometry=80x40-0-52' |
---|
| 100 | |
---|
| 101 | # GNOME processes can apparently collide trying to start gconfd, so |
---|
| 102 | # spawn one before we start any in the background. |
---|
| 103 | $gconftool --spawn |
---|
| 104 | fi |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | # ******************* DEVICE SETUP ******************* |
---|
| 108 | |
---|
| 109 | # Load user X resources. |
---|
| 110 | |
---|
| 111 | if [ "${NOCALLS+set}" != set -a -r "$HOME/.Xresources" ]; then |
---|
| 112 | xrdb -merge ~/.Xresources |
---|
| 113 | fi |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | # ******************* ACTIVITY STARTUP ******************* |
---|
| 117 | |
---|
| 118 | # Start window manager. To change your default window manager, set the |
---|
| 119 | # WINDOW_MANAGER environment variable in your ~/.bash_environment file. |
---|
| 120 | if [ "${WINDOW_MANAGER+set}" != set ]; then |
---|
| 121 | if [ -r "$HOME/.athena-sawfish" ]; then |
---|
| 122 | export WINDOW_MANAGER=sawfish |
---|
| 123 | else |
---|
| 124 | export WINDOW_MANAGER=$default_windowmanager |
---|
| 125 | fi |
---|
| 126 | fi |
---|
| 127 | |
---|
| 128 | echo_if_verbose "Starting $WINDOW_MANAGER window manager..." |
---|
| 129 | |
---|
| 130 | if [ "${NOCALLS+set}" = set ]; then |
---|
| 131 | (metacity >/dev/null 2>&1 &) |
---|
| 132 | else |
---|
| 133 | ($WINDOW_MANAGER >/dev/null 2>&1 &) |
---|
| 134 | fi |
---|
| 135 | |
---|
| 136 | # Run standard system/user startup activities |
---|
| 137 | |
---|
| 138 | if [ "${ATHENA_DASH_INTERFACE+set}" != set ]; then |
---|
| 139 | # Run gnome-settings-daemon unless the user has chosen to skip it. |
---|
| 140 | # (We used to run a series of capplets with an init flag; thus the |
---|
| 141 | # skip variable is named skip_capplets.) |
---|
| 142 | if [ "${skip_capplets+set}" != set ]; then |
---|
| 143 | echo_if_verbose "Initializing settings..." |
---|
| 144 | |
---|
| 145 | # This incantation causes gnome-settings-daemon to be run via |
---|
| 146 | # Bonobo, such that we won't continue until the settings-daemon |
---|
| 147 | # object has been initialized and all settings have been |
---|
| 148 | # propagated. If we just naively run gnome-settings-daemon in the |
---|
| 149 | # background, settings may not propagate before GNOME programs |
---|
| 150 | # run. In particular, GNOME programs might render text before the |
---|
| 151 | # Xft settings have been propagated, leading to incorrect font |
---|
| 152 | # selection. |
---|
| 153 | activation-client -s "iid == 'OAFIID:GNOME_SettingsDaemon'" >/dev/null |
---|
| 154 | fi |
---|
| 155 | |
---|
| 156 | # Run the GNOME panel unless the user has chosen to skip it. |
---|
| 157 | if [ "${skip_panel+set}" != set ]; then |
---|
| 158 | echo_if_verbose "Starting panel..." |
---|
| 159 | (gnome-panel >/dev/null 2>&1 && kill -HUP "$XSESSION" &) |
---|
| 160 | fi |
---|
| 161 | |
---|
| 162 | # If you decide to set skip_nautilus, GNOME will stop taking care |
---|
| 163 | # of your background image unless you run: |
---|
| 164 | # gconftool-2 -s -t bool /apps/nautilus/preferences/show_desktop false |
---|
| 165 | if [ "${skip_nautilus+set}" != set ]; then |
---|
| 166 | (nautilus -n >/dev/null 2>&1 &) |
---|
| 167 | fi |
---|
| 168 | |
---|
| 169 | elif [ "${skip_dash+set}" != set ]; then |
---|
| 170 | if [ "${skip_xlogout+set}" != set ]; then |
---|
| 171 | echo_if_verbose "Starting the Athena Dashboard..." |
---|
| 172 | echo_if_verbose "Creating logout button..." |
---|
| 173 | (dash -default -logout &) |
---|
| 174 | else |
---|
| 175 | echo_if_verbose "Starting the Athena Dashboard..." |
---|
| 176 | (dash &) |
---|
| 177 | fi |
---|
| 178 | elif [ "${skip_xlogout+set}" != set ]; then |
---|
| 179 | echo_if_verbose "Creating logout button..." |
---|
| 180 | (dash -logout &) |
---|
| 181 | fi |
---|
| 182 | |
---|
| 183 | # Start default initial xterm window. To skip this, put the command |
---|
| 184 | # "skip_initial_xterm=t" in your ~/.bash_environment file. |
---|
| 185 | |
---|
| 186 | # BE CAREFUL: If you skip this, make sure that your ~/.startup.X file |
---|
| 187 | # provides a way for you to exit your session (e.g., an xterm from which |
---|
| 188 | # you can type "logout"). |
---|
| 189 | |
---|
| 190 | if [ "${skip_initial_xterm+set}" != set ]; then |
---|
| 191 | echo_if_verbose "Creating initial xterm window..." |
---|
| 192 | ($terminal >/dev/null 2>&1 &) |
---|
| 193 | fi |
---|
| 194 | |
---|
| 195 | # Run default system startup activities. To skip these, put the command |
---|
| 196 | # "skip_x_startup=t" in your ~/.bash_environment file. |
---|
| 197 | |
---|
| 198 | if [ "${skip_x_startup+set}" != set ]; then |
---|
| 199 | echo_if_verbose "Running standard startup activities..." |
---|
| 200 | |
---|
| 201 | # Start Zephyr client, and if zephyr started okay, send message of |
---|
| 202 | # the day as windowgram |
---|
| 203 | : ${ZEPHYR_CLIENT=zwgc} |
---|
| 204 | if [ "${NOCALLS+set}" = set ]; then |
---|
| 205 | zwgc -f /etc/zephyr/zwgc.desc -subfile /dev/null && \ |
---|
| 206 | get_message -new -zephyr |
---|
| 207 | else |
---|
| 208 | $ZEPHYR_CLIENT && get_message -new -zephyr |
---|
| 209 | fi |
---|
| 210 | if [ "${skip_quotawarn+set}" != set ]; then |
---|
| 211 | ($initdir/quotawarn &) # Display warning dialogs if near quota |
---|
| 212 | fi |
---|
| 213 | from -t -n # Check for mail |
---|
| 214 | if [ "${skip_xss+set}" != set ]; then |
---|
| 215 | (xscreensaver -no-splash &) |
---|
| 216 | fi |
---|
| 217 | if [ "${skip_authwatch+set}" != set ]; then |
---|
| 218 | (authwatch &) |
---|
| 219 | fi |
---|
| 220 | fi |
---|
| 221 | |
---|
| 222 | # Maybe start the Disco-Athena daemon. |
---|
| 223 | if [ -r /var/run/athstatusd.sock -a "${skip_athneteventd+set}" != set ]; then |
---|
| 224 | athneteventd |
---|
| 225 | fi |
---|
| 226 | |
---|
| 227 | # Run the window-session customizing commands in your ~/.startup.X |
---|
| 228 | # file. We want to background this process in case something in the |
---|
| 229 | # startup hangs. Thus, the user will not be left with active windows |
---|
| 230 | # and no method of easily logging out. |
---|
| 231 | |
---|
| 232 | # We also run the notification system, lert. Ideally, we wish the user |
---|
| 233 | # to receive the alert in the form of a zephyrgram, and since they may |
---|
| 234 | # run zwgc from their .startup.X, we wait until that has finished. To |
---|
| 235 | # skip lert (a generally bad idea unless you plan to run it yourself - |
---|
| 236 | # it is not at all intended for frivolous messages), put the command |
---|
| 237 | # "skip_lert=t" in your ~/.bash_environment file. |
---|
| 238 | |
---|
| 239 | if [ "${NOCALLS+set}" != set -a -r "$HOME/.startup.X" ]; then |
---|
| 240 | echo_if_verbose "Running custom startup activities listed in ~/.startup.X..." |
---|
| 241 | ( . "$HOME/.startup.X"; \ |
---|
| 242 | if [ "${skip_lert+set}" != set ]; then lert -q -z; fi; \ |
---|
| 243 | echo_if_verbose "Session initialization completed." &) |
---|
| 244 | else |
---|
| 245 | if [ "${skip_lert+set}" != set ]; then |
---|
| 246 | lert -q -z |
---|
| 247 | fi |
---|
| 248 | echo "Session initialization completed." |
---|
| 249 | fi |
---|
| 250 | |
---|
| 251 | |
---|
| 252 | # Gate the session. |
---|
| 253 | |
---|
| 254 | # This command replaces this script and will wait for you to log out. |
---|
| 255 | # To terminate this process, logout (type the "logout" command in any |
---|
| 256 | # xterm window, use the Logout button, or select the "Logout of |
---|
| 257 | # Athena" option from Dash), or invoke the "end_session" program. |
---|
| 258 | |
---|
| 259 | if [ "${NOCALLS+set}" = set ]; then |
---|
| 260 | exec session_gate |
---|
| 261 | else |
---|
| 262 | exec session_gate -logout |
---|
| 263 | fi |
---|
| 264 | |
---|
| 265 | # The session gate will source .logout when it gets a SIGHUP, if |
---|
| 266 | # invoked with the -logout flag. |
---|