chiark / gitweb /
Merge remote-tracking branch 'crybaby'
[profile] / dot / xinitrc
index 9dc19547187710ea768578957b2f423f717105dd..8fce589db011b56d1213649c07b13c3b44b79d24 100755 (executable)
@@ -70,6 +70,13 @@ EOF
   esac
 done
 
+###--------------------------------------------------------------------------
+### Preliminary hook.
+
+if [ -r $HOME/.xinitrc-prehook ]; then
+  . $HOME/.xinitrc-prehook
+fi
+
 ###--------------------------------------------------------------------------
 ### Iniitial settings.
 
@@ -87,21 +94,18 @@ initialize () {
   run init xrdb -override $HOME/.Xdefaults
 
   ## Random xsettery.
-  run init xset b 10 2000 50
+  run init xset b 5 2000 50
   run init xset r rate 500 50
   run init xset m 2 1
 
   ## Key mappings.
   xmodmap -e 'keysym BackSpace = BackSpace BackSpace'
-
-  ## Gnome settings.
-  case $vnc in no) run bginit gnome-settings-daemon ;; esac
 }
 
 ###--------------------------------------------------------------------------
 ### Start a window manager.
 
-wm=$(pick_program window-manager enlightenment e16 twm)
+wm=$(pick_program window-manager e16 compiz enlightenment e17 twm)
 wmopts=""
 case "$wm,$vnc" in
   enlightenment,yes | e16,yes)
@@ -109,8 +113,36 @@ case "$wm,$vnc" in
     ;;
 esac
 
-start-window-manager () {
+start-e16 () {
   run bginit $wm $wmopts
+  win=nil
+  for i in $(seq 10); do
+    sleep 1
+    if eesh version >/dev/null 2>&1; then
+      win=t
+      break
+    fi
+  done
+  case $win in
+    t)
+      info "$wm started ok"
+      run init xsetroot -cursor_name left_ptr
+      ;;
+    nil)
+      info "$wm failed to start!"
+      ;;
+  esac
+}
+
+start-window-manager () {
+  case $(type -t start-$wm || echo "not-found") in
+    function)
+      start-$wm $wmopts
+      ;;
+    *)
+      run bginit $wm $wmopts
+      ;;
+  esac
 }
 
 ###--------------------------------------------------------------------------
@@ -119,30 +151,19 @@ start-window-manager () {
 start-clients-local () { :; }
 
 start-clients () {
-  ## Mail notification.
-  run bginit mail-notification
-
-  ## Policykit authentication agent.
-  agent=/usr/lib/policykit-1-gnome/polkit/gnome-authentication-agent-1
-  if [ -x $agent ]; then run bginit $agent; fi
-
-  ## System monitor.
-  case $vnc in no) run bginit gkrellm ;; esac
 
-  ## Screensaver.
-  case $vnc in
-    no)
-      run init xscreensaver-command -exit
-      run bginit xscreensaver -no-splash
+  ## Gnome session.
+  case "$vnc,$(gnome-session --version 2>&1)" in
+    no,gnome-session\ 2.3[2-9].* | \
+    no,gnome-session\ 2.4[0-9].* | \
+    no,gnome-session\ 2.[1-9][0-9][0-9]*)
+      run bginit gnome-session --session mdw
+      ;;
+    no,*)
+      run bginit gnome-session
       ;;
   esac
 
-  ## Panel.
-  case $vnc in no) run bginit gnome-panel ;; esac
-
-  ## System tray.
-  ## run bginit stalonetray
-
   ## Local clients.
   start-clients-local
 }
@@ -254,7 +275,7 @@ start-xterms () {
 
 req () {
   declare title=$1 hist=$2; shift 2
-  cmd=$(xgetline -t "$title" -p "Command:" -Hl "$HOME/$hist") &&
+  cmd=$(xgetline -t "$title" -p "_Command:" -Hl "$HOME/$hist") &&
   exec "$@" "$cmd"
 }
 
@@ -308,13 +329,35 @@ EOF
        eval "${line#!}"
        ;;
       *)
-        set -- $line
+       set -- $line
        run bgclients "$@"
        ;;
     esac
   done
 }
 
+###--------------------------------------------------------------------------
+### Gnome session care and feeding.
+
+session-running-p () {
+  dbus-send --session --print-reply --dest=org.freedesktop.DBus / \
+    org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager \
+    >/dev/null 2>&1
+}
+
+kill-gnome-session () {
+  if session-running-p; then
+    info "killing Gnome session manager"
+    dbus-send --session \
+      --dest=org.gnome.SessionManager /org/gnome/SessionManager \
+      org.gnome.SessionManager.Logout uint32:2
+    for i in 1 2 3 4 5; do
+      sleep 1
+      if ! session-running-p; then break; fi
+    done
+  fi
+}
+
 ###--------------------------------------------------------------------------
 ### Actually start things up.
 
@@ -339,6 +382,7 @@ esac
 case "$wait" in
   yes)
     xwait
+    kill-gnome-session
     ;;
   no)
     info "not waiting before exit"