FROM --platform=linux/amd64 minimaldesktop
MAINTAINER Stefano Alberto Russo <stefano.russo@inaf.it>

# Switch to root
USER root

# Extra for Ubuntu18.04
RUN apt-get install net-tools dbus-x11 -y

#----------------------
#    Xfce
#----------------------

RUN apt-get update
RUN apt-get install xfce4 xfce4-terminal mousepad ristretto tumbler firefox gnome-flashback -y


#----------------------
#    Desktop
#----------------------

# Add some dependencies
RUN apt-get install imwheel zenity x11-xserver-utils -y

# Create the Desktop
RUN mkdir /metauser_home_vanilla/Desktop && chown metauser:metauser /metauser_home_vanilla/Desktop

# Add mouse scrolling script
COPY files/set_mouse_scrolling_speed /usr/bin/
COPY files/Set_Mouse_Scrolling_Speed.desktop /metauser_home_vanilla/Desktop/
RUN chmod 755 /usr/bin/set_mouse_scrolling_speed

# Add Display Resolution stuff
#COPY add_display_resolution /usr/bin/
#COPY add_display_resolution_gui /usr/bin/
#COPY Set_Display_Resolution.desktop /metauser_home_vanilla/Desktop/
#COPY Add_Display_Resolution.desktop /metauser_home_vanilla/Desktop/
#RUN chmod 755 /usr/bin/add_display_resolution && chmod 755 /usr/bin/add_display_resolution_gui 

# Correct ownership of Desktop shortcuts
RUN chown -R metauser:metauser /metauser_home_vanilla/Desktop/

# Shorter bash prompt
#RUN echo "PS1=\"\u@basicdesktop:\W $ \"" >> /metauser_home_vanilla/.bashrc


# Default conf (mostly eyecandy)
COPY files/home_metauser_.config /metauser_home_vanilla/.config
#COPY data/desktop-cf881dd7/metauser_home_vanilla/.config /metauser_home_vanilla/.config
RUN chown -R metauser:metauser /metauser_home_vanilla/.config

# Disable the X screensaver
COPY files/dot_xscreensaver /metauser_home_vanilla/.xscreensaver
RUN chown metauser:metauser /metauser_home_vanilla/.xscreensaver

# Remove the screen locker package altogether
RUN apt-get remove -y light-locker light-locker-settings

# Disable logout dialog
RUN chmod 000 /usr/bin/xfce4-session-logout

# Create Downloads folder. This is "required" for showing proper spacing between icons in the filemanager a bounch 
RUN mkdir /metauser_home_vanilla/Downloads && chown metauser:metauser /metauser_home_vanilla/Downloads

# Extra SW
#RUN apt-get install libreoffice gimp -y

# Terminator alternative terminal
RUN apt-get install terminator -y


#------------------------
# Post-intall
#------------------------

# Fix home permissions
RUN chmod 777 /home

# X environment startup
RUN mkdir -p /metauser_home_vanilla/.vnc
COPY files/xstartup /metauser_home_vanilla/.vnc
RUN chmod 755 /metauser_home_vanilla/.vnc/xstartup

# Set user
USER metauser

# Set container name
ENV CONTAINER_NAME='basicdesktop'
