Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # simple script to ease XFCE installation on a WSL (Windows Subsystem for Linux)
- # environment:
- #
- # This will install essential Xorg packages (without install server side as WSL
- # currently don't have the ability of starting a native Xserver)
- #
- # You'll have to rely on a Windows native Xserver such like vcxsrv or Xming
- #
- # 2019-02-16 - Eric Belhomme
- if [ $UID != 0 ]; then
- echo "Fatal: run run as root user"
- exit 1
- fi
- function install_locales() {
- # sudo dpkg-reconfigure locales
- BAKIFS=$IFS
- IFS=$'\n'
- LOCALES=('en_US ISO-8859-1' \
- 'en_US.ISO-8859-15 ISO-8859-15' \
- 'en_US.UTF-8 UTF-8' \
- 'fr_FR ISO-8859-1' \
- 'fr_FR.UTF-8 UTF-8' \
- 'fr_FR@euro ISO-8859-15')
- for ITEM in ${LOCALES[@]}; do
- sed -i -e "s/^# .*$ITEM/$ITEM/" /etc/locale.gen
- done
- IFS=$BAKIFS
- dpkg-reconfigure --frontend=noninteractive locales && update-locale LANG=en_US.UTF-8
- cat > /etc/default/locale <<EOF
- LANGUAGE=en_US.UTF-8
- LC_ALL=C
- LANG=en_US.UTF-8
- EOF
- }
- function install_xcore() {
- apt-get install -y xserver-xorg-video-dummy xserver-xorg-input-void xserver-xorg-core
- apt-get install -y xorg
- apt-get install -y x11-xkb-utils xfonts-base xfonts-encodings xfonts-scalable \
- xfonts-utils x11-session-utils dbus-x11 desktop-base desktop-file-utils gconf* \
- gnome-mime-data gnome-themes-standard*
- }
- function install_xfce4() {
- apt-get install -y xfce4-session xfce4-settings xfdesktop4* xfce4-appfinder \
- xfce4-panel xfce4-notifyd xfce4-xkb-plugin notification-daemon thunar
- }
- function install_gutils() {
- apt-get install -y terminator
- apt-get install -y --no-install-recommends meld firefox-esr firefox-esr-l10n-fr
- update-alternatives --set x-terminal-emulator /usr/bin/terminator
- update-alternatives --set x-www-browser /usr/bin/firefox-esr
- }
- function configure_xstart() {
- WINHOME=$(wslpath $(cmd.exe /C "echo %USERPROFILE%"))
- if [ ! -e ${HOME}/winhome ]; then
- ln -s $WINHOME ${HOME}/winhome
- fi
- if [ ! -e ${HOME}/startxfce4 ]; then
- cat > ${HOME}/startxfce4 <<EOF
- #!/bin/bash
- cd $HOME
- #eval "$(ssh-agent -s)" &> /dev/null
- export DISPLAY="localhost:0.0"
- exec dbus-run-session -- bash -l -c startxfce4 &> $HOME/xfce-session.log
- EOF
- fi
- chmod 0750 ${HOME}/startxfce4
- if [ "$(grep -c "export DISPLAY")" == "0" ]; then
- echo 'export DISPLAY="localhost:0.0"' >> ${HOME}.bashrc
- fi
- if [ "$(grep -c "export LD_PRELOAD")" == "0" ]; then
- echo 'export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGL.so.1' >> ${HOME}.bashrc
- fi
- if [ "$(grep -c "export NO_AT_BRIDGE")" == "0" ]; then
- echo 'export NO_AT_BRIDGE=1' >> ${HOME}.bashrc
- fi
- if [ "$(grep -c "export WINHOME")" == "0" ]; then
- echo "export WINHOME=$WINHOME" >> ${HOME}.bashrc
- fi
- if [ ! -e $WINHOME/Desktop/Xfce4.xlaunch ]; then
- cat > $WINHOME/Desktop/Xfce4.xlaunch << EOF
- <?xml version="1.0" encoding="UTF-8"?>
- <XLaunch WindowMode="Windowed" ClientMode="StartProgram" LocalClient="True" Display="-1" LocalProgram="C:\Windows\System32\wsl.exe -u $USER ${HOME}/startxfce4" RemoteProgram="xterm" RemotePassword="" PrivateKey="" RemoteHost="" RemoteUser="" XDMCPHost="" XDMCPBroadcast="False" XDMCPIndirect="False" Clipboard="True" ClipboardPrimary="True" ExtraParams="" Wgl="True" DisableAC="False" XDMCPTerminate="False"/>
- EOF
- fi
- }
- ###
- function exit_help() {
- cat <<EOF
- $0 - installs XFCE4 graphical on WSL env
- usage : $0 -h -a -l -c -x -g
- -h : this help
- -l : set locales
- -c : installs Xorg core
- -x : installs Xfce4 Window Manager
- -g : installs some GUI tools (terminator, meld, Firefox)
- -i : configure Linux and Windows env to start Xfce4 with vcXsrv
- -a : do all of the above
- EOF
- exit 1
- }
- if [ "$#" -eq 0 ]; then exit_help; fi
- loca=0
- xcor=0
- xfce=0
- guti=0
- vcxs=0
- while getopts "halcxgi" option; do
- case "$1" in
- -a)
- loca=1
- xcor=1
- xfce=1
- guti=1
- vcxs=1
- shift; ;;
- -l)
- loca=1; shift; ;;
- -c)
- xcor=1; shift; ;;
- -x)
- xfce=1; shift; ;;
- -g)
- guti=1; shift; ;;
- -i)
- vcxs=1; shift; ;;
- *)
- exit_help
- shift
- ;;
- esac
- done
- # do this anytime
- if [ -z "$(find /var/cache/apt/pkgcache.bin -mmin -60)" ]; then
- apt-get update
- fi
- apt-get install -y locales bash-completion git vim
- update-alternatives --set editor /usr/bin/vim.basic
- if [ $loca -eq 1 ]; then install_locales; fi
- if [ $xcor -eq 1 ]; then install_xcore; fi
- if [ $xfce -eq 1 ]; then install_xfce4; fi
- if [ $guti -eq 1 ]; then install_gutils; fi
- if [ $vcxs -eq 1 ]; then configure_xstart; fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement