Harukaのnote

Linuxやプログラミング,写真,旅行等の記録帳

OpenSUSE Leap 15.4のXRDPでcinnamonやxfce4を使う方法

/etc/xrdp/startwm.shを編集する.

sudo vim /etc/xrdp/startwm.sh

以下のようにif文を書き換え,SESSION="cinnamon"に任意のデスクトップ環境を指定する.

{
  #To customize system-wise session, edit this file.
  #To customize user specific session, copy this file to $HOME and edit it.
  #Please refer to DefaultWindowManager and UserWindowManager in /etc/xrdp/sesman.ini for more details.

  #The default session is gnome (GNOME Session)
  #sle means SLE-Classic Session

  SESSION="cinnamon"

  case $SESSION in
    cinnamon)
      if [ -r /usr/bin/cinnamon-session ]; then
        export XDG_SESSION_TYPE=x11
        /usr/bin/cinnamon-session
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;; 
    xfce)
      if [ -r /usr/bin/startxfce4 ]; then
        export XDG_SESSION_TYPE=x11
        /usr/bin/startxfce4
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;; 
    sle)
      if [ -r /usr/bin/gnome-session ]; then
        export XDG_SESSION_TYPE=x11
        export GNOME_SHELL_SESSION_MODE=sle-classic
        /usr/bin/gnome-session --session gnome-classic
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;;
    gnome)
      if [ -r /usr/bin/gnome-session ]; then
        export XDG_SESSION_TYPE=x11
        /usr/bin/gnome-session
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;;
    plasma)
      if [ -r /usr/bin/startplasma-x11 ]; then
        export XDG_SESSION_TYPE=x11
        /usr/bin/startplasma-x11
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;;
    icewm)
      if [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;;
  esac
}

以下はファイルの全文.

#!/usr/bin/env bash
#
# This script is an example. You might need to edit this script
# depending on your distro if it doesn't work for you.
#
# Uncomment the following line for debug:
# exec xterm


#start the window manager
wm_start()
{
  #To customize system-wise session, edit this file.
  #To customize user specific session, copy this file to $HOME and edit it.
  #Please refer to DefaultWindowManager and UserWindowManager in /etc/xrdp/sesman.ini for more details.

  #The default session is gnome (GNOME Session)
  #sle means SLE-Classic Session

  SESSION="cinnamon"

  case $SESSION in
    cinnamon)
      if [ -r /usr/bin/cinnamon-session ]; then
        export XDG_SESSION_TYPE=x11
        /usr/bin/cinnamon-session
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;; 
    xfce)
      if [ -r /usr/bin/startxfce4 ]; then
        export XDG_SESSION_TYPE=x11
        /usr/bin/startxfce4
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;; 
    sle)
      if [ -r /usr/bin/gnome-session ]; then
        export XDG_SESSION_TYPE=x11
        export GNOME_SHELL_SESSION_MODE=sle-classic
        /usr/bin/gnome-session --session gnome-classic
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;;
    gnome)
      if [ -r /usr/bin/gnome-session ]; then
        export XDG_SESSION_TYPE=x11
        /usr/bin/gnome-session
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;;
    plasma)
      if [ -r /usr/bin/startplasma-x11 ]; then
        export XDG_SESSION_TYPE=x11
        /usr/bin/startplasma-x11
      elif [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;;
    icewm)
      if [ -r /usr/bin/icewm-session ]; then
        /usr/bin/icewm-session
      fi
      ;;
  esac
}

#Execution sequence for interactive login shell
#Following pseudo code explains the sequence of execution of these files.
#execute /etc/profile
#IF ~/.bash_profile exists THEN
#    execute ~/.bash_profile
#ELSE
#    IF ~/.bash_login exist THEN
#        execute ~/.bash_login
#    ELSE
#        IF ~/.profile exist THEN
#            execute ~/.profile
#        END IF
#    END IF
#END IF
pre_start()
{
  if [ -f /etc/profile ]
  then
    . /etc/profile
  fi
  if [ -f ~/.bash_profile ]
  then
    . ~/.bash_profile
  else
    if [ -f ~/.bash_login ]
    then
      . ~/.bash_login
    else
      if [ -f ~/.profile ]
      then
        . ~/.profile
      fi
    fi
  fi
  return 0
}

#When you logout of the interactive shell, following is the
#sequence of execution:
#IF ~/.bash_logout exists THEN
#    execute ~/.bash_logout
#END IF
post_start()
{
  if [ -f ~/.bash_logout ]
  then
    . ~/.bash_logout
  fi
  return 0
}

#. /etc/environment
#export PATH=$PATH
#export LANG=$LANG

# change PATH to be what your environment needs usually what is in
# /etc/environment
#PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
#export PATH=$PATH

# for PATH and LANG from /etc/environment
# pam will auto process the environment file if /etc/pam.d/xrdp-sesman
# includes
# auth       required     pam_env.so readenv=1

pre_start
wm_start
post_start

exit 1