[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#195845: xfree86-common: allow-user-xsession does not allow user xsessions



Package: xfree86-common
Subject: xfree86-common: allow-user-xsession does not allow user xsessions
Version: 4.2.1-7
Severity: important
Tags: patch sid

When trying to use a .xsession file, I discovered that the functionality
doesn't work as it is documented.

The core problem is on line 29 of 20xfree86-common_process-args, where the
variable STARTUP is used to hold the program name of a non-default window
manager. However, STARTUP is supposed to hold the string $HOME/.xsession.
This causes problems in 50xfree86-common_determine-startup.

I've reworked these scripts more than just that change, so that they
set the default in a clearer way, and also exports a variable so that
.xsession can exec the selected window manager. If you don't want to
export this variable, delete the last three lines of
20xfree86-common_process-args

I disclaim any copyright to these changes. (If that is what I'm supposed to 
say; please integrate these changes into any program you wish.)

-- System Information:
Debian Release: testing/unstable
Architecture: powerpc
Kernel: Linux polo 2.4.20-powerpc #1 Wed Mar 26 12:47:45 EST 2003 ppc
Locale: LANG=C, LC_CTYPE=C

Versions of packages xfree86-common depends on:
ii  debconf                       1.2.38     Debian configuration management 
sy
ii  debianutils                   2.5.2      Miscellaneous utilities specific 
t

-- debconf information:
  xfree86-common/experimental_packages:
set_default_startup_session () {
  if [ -x /usr/bin/x-session-manager ]; then
    STARTUPSESSION=x-session-manager
  elif [ -x /usr/bin/x-window-manager ]; then
    STARTUPSESSION=x-window-manager
  elif [ -x /usr/bin/x-terminal-emulator ]; then
    STARTUPSESSION=x-terminal-emulator
  fi
}

case $# in
  0)
    set_default_startup_session
    ;;
  1)
    case "$1" in
      failsafe)
        if grep -qs ^allow-failsafe "$OPTIONFILE"; then
          if [ -e /usr/bin/x-terminal-emulator ]; then
            if [ -x /usr/bin/x-terminal-emulator ]; then
              exec x-terminal-emulator -geometry +1+1
            else
              # fatal error
              errormsg "Xsession: unable to launch failsafe X session;" \
                       "x-terminal-emulator not executable.  Aborting."
            fi
          else
            # fatal error
            errormsg "Xsession: unable to launch failsafe X session;" \
                     "x-terminal-emulator not found.  Aborting."
          fi
        fi
        ;;
      default)
        set_default_startup_session
        ;;
      *)
        STARTUPSESSION=$(which $1)
        if [ -n "$STARTUPSESSION" -a -e "$STARTUPSESSION" ]; then
          if [ -x "$STARTUPSESSION" ]; then
            REALSTARTUP=$STARTUPSESSION
          else
            message "Xsession: unable to launch $1 X session; $1 not" \
                    "executable.  Falling back to default session."
          fi
        else
          message "Xsession: unable to launch $1 X session; $1 not found." \
                  "Falling back to default session."
        fi
        ;;
    esac
    ;;
  *)
    message "Xsession: unsupported number of arguments ($#).  Falling back" \
            "to default session."
    ;;
esac

# Allow .xsession to use this variable
export STARTUPSESSION
if grep -qs ^allow-user-xsession "$OPTIONFILE"; then
  for STARTUPFILE in "$STARTUP" "$ALTSTARTUP"; do
    if [ -e "$STARTUPFILE" ]; then
      if [ -x "$STARTUPFILE" ]; then
        REALSTARTUP=$STARTUPFILE
      else
        REALSTARTUP="sh $STARTUPFILE"
      fi
      break
    fi
  done
fi

if [ -z "$REALSTARTUP" ]; then
  REALSTARTUP=$STARTUPSESSION
fi

if [ -z "$REALSTARTUP" ]; then
  # fatal error
  ERRMSG="Xsession: unable to start X session; "
  if grep -qs ^allow-user-xsession "$OPTIONFILE"; then
    ERRMSG="$ERRMSG no $STARTUP file, no $ALTSTARTUP file,"
  fi
  errormsg "$ERRMSG no session managers, no window managers, and no terminal" \
           "emulators found.  Aborting."
fi

Reply to: