From 4f4b9ab51c537198987335846c764ced09da48bc Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 13:13:59 -0700 Subject: [PATCH 01/14] Create desktop.sh --- desktop.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 desktop.sh diff --git a/desktop.sh b/desktop.sh new file mode 100644 index 0000000..a2684b1 --- /dev/null +++ b/desktop.sh @@ -0,0 +1,19 @@ +# set the Desktop dir to something in base +echo 'XDG_DESKTOP_DIR="/usr/share/Desktop"' > /etc/xdg/user-dirs.defaults + +# Copy in the Desktop files +APPLICATIONS_DIR=/usr/share/applications +DESKTOP_DIR=/usr/share/Desktop + +mkdir -p "${DESKTOP_DIR}" +# set the Desktop dir to something in base +echo 'XDG_DESKTOP_DIR="${DESKTOP_DIR}"' > /etc/xdg/user-dirs.defaults +for desktop_file_path in ${REPO_DIR}/Desktop/*.desktop; do + cp "${desktop_file_path}" "${APPLICATIONS_DIR}/." + + # Symlink application to desktop and set execute permission so xfce (desktop) doesn't complain + desktop_file_name="$(basename ${desktop_file_path})" + # Set execute permissions on the copied .desktop file + chmod +x "${APPLICATIONS_DIR}/${desktop_file_name}" + ln -sf "${APPLICATIONS_DIR}/${desktop_file_name}" "${DESKTOP_DIR}/${desktop_file_name}" +done From e364a7a507f91da83607cd874567f46577df99e2 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 13:20:41 -0700 Subject: [PATCH 02/14] Update desktop.sh --- desktop.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/desktop.sh b/desktop.sh index a2684b1..2b99be9 100644 --- a/desktop.sh +++ b/desktop.sh @@ -4,10 +4,13 @@ echo 'XDG_DESKTOP_DIR="/usr/share/Desktop"' > /etc/xdg/user-dirs.defaults # Copy in the Desktop files APPLICATIONS_DIR=/usr/share/applications DESKTOP_DIR=/usr/share/Desktop - mkdir -p "${DESKTOP_DIR}" -# set the Desktop dir to something in base +# set the Desktop dir default for XDG echo 'XDG_DESKTOP_DIR="${DESKTOP_DIR}"' > /etc/xdg/user-dirs.defaults + +# The for loops will fail if they return null (no files). Set shell option nullglob +shopt -s nullglob + for desktop_file_path in ${REPO_DIR}/Desktop/*.desktop; do cp "${desktop_file_path}" "${APPLICATIONS_DIR}/." @@ -17,3 +20,14 @@ for desktop_file_path in ${REPO_DIR}/Desktop/*.desktop; do chmod +x "${APPLICATIONS_DIR}/${desktop_file_name}" ln -sf "${APPLICATIONS_DIR}/${desktop_file_name}" "${DESKTOP_DIR}/${desktop_file_name}" done +update-desktop-database "${APPLICATIONS_DIR}" + +# Add MIME Type data from XML files to the MIME database. +MIME_DIR="/usr/share/mime" +MIME_PACKAGES_DIR="${MIME_DIR}/packages" +mkdir -p "${MIME_PACKAGES_DIR}" +for mime_file_path in ${REPO_DIR}/Desktop/*.xml; do + cp "${mime_file_path}" "${MIME_PACKAGES_DIR}/." +done +update-mime-database "${MIME_DIR}" + From 57d9c6a208ac6b10e78fd9a4dc8f510c4c630ac3 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 13:30:14 -0700 Subject: [PATCH 03/14] Update appendix --- appendix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/appendix b/appendix index 2db1013..26ab571 100644 --- a/appendix +++ b/appendix @@ -61,8 +61,10 @@ ONBUILD RUN echo "Checking for 'Desktop directory'..." \ ; cd "${REPO_DIR}/childimage/" \ ; if test -d Desktop ; then \ mkdir -p "${REPO_DIR}/Desktop" && \ - [ "$(ls -A Desktop 2>/dev/null)" ] && cp -r Desktop/* "${REPO_DIR}/Desktop/"; \ - fi + cp -r Desktop/* "${REPO_DIR}/Desktop/" 2>/dev/null && \ + chmod +x "${REPO_DIR}/desktop.sh" ; \ + fi \ + ; "${REPO_DIR}/desktop.sh" # Install apt packages specified in a apt.txt file if it exists. # blank lines and comments are supported in apt.txt From f2ae636c2186dd5d0f703143c5d65daea27c44da Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 13:30:36 -0700 Subject: [PATCH 04/14] Update desktop.sh --- desktop.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/desktop.sh b/desktop.sh index 2b99be9..5c277bb 100644 --- a/desktop.sh +++ b/desktop.sh @@ -1,3 +1,6 @@ +#!/bin/bash +set -e + # set the Desktop dir to something in base echo 'XDG_DESKTOP_DIR="/usr/share/Desktop"' > /etc/xdg/user-dirs.defaults From cf7c52ce3fdd6af06243168a7031f524061c1674 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 13:41:27 -0700 Subject: [PATCH 05/14] Update desktop.sh --- desktop.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/desktop.sh b/desktop.sh index 5c277bb..59a5e02 100644 --- a/desktop.sh +++ b/desktop.sh @@ -1,4 +1,8 @@ #!/bin/bash +# The default for XDG and xfce4 is for Desktop files to be in ~/Desktop but this leads to a variety of problems +# First we are altering the user directiory which seems rude, second orphan desktop files might be in ~/Desktop so who knows +# what the user Desktop experience with be, here the Desktop dir is set to /usr/share/Desktop so is part of the image. +# users that really want to customize Desktop can change ~/.config/user-dirs.dirs. Though py-rocket-base might not respect that. set -e # set the Desktop dir to something in base @@ -8,6 +12,8 @@ echo 'XDG_DESKTOP_DIR="/usr/share/Desktop"' > /etc/xdg/user-dirs.defaults APPLICATIONS_DIR=/usr/share/applications DESKTOP_DIR=/usr/share/Desktop mkdir -p "${DESKTOP_DIR}" +chown :staff /usr/share/Desktop +chmod 775 /usr/share/Desktop # set the Desktop dir default for XDG echo 'XDG_DESKTOP_DIR="${DESKTOP_DIR}"' > /etc/xdg/user-dirs.defaults From 753bc817452788ebab0ef83e72e0b4cab56df508 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 13:58:52 -0700 Subject: [PATCH 06/14] Update desktop.sh --- desktop.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/desktop.sh b/desktop.sh index 59a5e02..b77700a 100644 --- a/desktop.sh +++ b/desktop.sh @@ -40,3 +40,14 @@ for mime_file_path in ${REPO_DIR}/Desktop/*.xml; do done update-mime-database "${MIME_DIR}" +# Add icons +ICON_DIR="/usr/share/icons" +ICON_PACKAGES_DIR="${ICON_DIR}/packages" +mkdir -p "${ICON_PACKAGES_DIR}" +for icon_file_path in "${REPO_DIR}"/Desktop/*.png; do + cp "${icon_file_path}" "${ICON_PACKAGES_DIR}/" || echo "Failed to copy ${icon_file_path}" +done +for icon_file_path in "${REPO_DIR}"/Desktop/*.svg; do + cp "${icon_file_path}" "${ICON_PACKAGES_DIR}/" || echo "Failed to copy ${icon_file_path}" +donegtk-update-icon-cache "${ICON_DIR}" + From 5c1ceec76f55b9268d82c499ffa73b917a265394 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 14:12:23 -0700 Subject: [PATCH 07/14] Update start --- start | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/start b/start index 11ba4ee..cafc24b 100644 --- a/start +++ b/start @@ -9,41 +9,6 @@ set -euo pipefail source ${REPO_DIR}/env.txt # End - Set any environment variables here -# The for loops will fail if they return null (no files). Set shell option nullglob -shopt -s nullglob - -# Add any .desktop files to the application database and desktop. This is done -# at startup-time because it's expected that a remote filesystem will be -# mounted at $HOME, which would overwrite the data if it was created at -# build-time. -APPLICATIONS_DIR="${HOME}/.local/share/applications" -DESKTOP_DIR="${HOME}/Desktop" -# Remove DESKTOP_DIR if it exists to avoid leftover files -if [ -d "${DESKTOP_DIR}" ]; then - rm -rf "${DESKTOP_DIR}" -fi -mkdir -p "${APPLICATIONS_DIR}" -mkdir -p "${DESKTOP_DIR}" -for desktop_file_path in ${REPO_DIR}/Desktop/*.desktop; do - cp "${desktop_file_path}" "${APPLICATIONS_DIR}/." - - # Symlink application to desktop and set execute permission so xfce (desktop) doesn't complain - desktop_file_name="$(basename ${desktop_file_path})" - # Set execute permissions on the copied .desktop file - chmod +x "${APPLICATIONS_DIR}/${desktop_file_name}" - ln -sf "${APPLICATIONS_DIR}/${desktop_file_name}" "${DESKTOP_DIR}/${desktop_file_name}" -done -update-desktop-database "${APPLICATIONS_DIR}" - -# Add MIME Type data from XML files to the MIME database. -MIME_DIR="${HOME}/.local/share/mime" -MIME_PACKAGES_DIR="${MIME_DIR}/packages" -mkdir -p "${MIME_PACKAGES_DIR}" -for mime_file_path in ${REPO_DIR}/Desktop/*.xml; do - cp "${mime_file_path}" "${MIME_PACKAGES_DIR}/." -done -update-mime-database "${MIME_DIR}" - # Run child start in a subshell to contain its environment [ -f ${REPO_DIR}/childimage/start ] && ( source ${REPO_DIR}/childimage/start ) From 9043c223eeab6b46406e98cd2bc3fe4b3d0dd3fc Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 14:50:26 -0700 Subject: [PATCH 08/14] Update desktop.sh --- desktop.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/desktop.sh b/desktop.sh index b77700a..40298cf 100644 --- a/desktop.sh +++ b/desktop.sh @@ -5,9 +5,6 @@ # users that really want to customize Desktop can change ~/.config/user-dirs.dirs. Though py-rocket-base might not respect that. set -e -# set the Desktop dir to something in base -echo 'XDG_DESKTOP_DIR="/usr/share/Desktop"' > /etc/xdg/user-dirs.defaults - # Copy in the Desktop files APPLICATIONS_DIR=/usr/share/applications DESKTOP_DIR=/usr/share/Desktop From 17790c83d748073e7a78f6bd340ffbf1833138c1 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 14:54:15 -0700 Subject: [PATCH 09/14] Update desktop.sh --- desktop.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop.sh b/desktop.sh index 40298cf..f3638b9 100644 --- a/desktop.sh +++ b/desktop.sh @@ -6,8 +6,9 @@ set -e # Copy in the Desktop files -APPLICATIONS_DIR=/usr/share/applications +APPLICATIONS_DIR=/usr/share/applications/packages DESKTOP_DIR=/usr/share/Desktop +mkdir -p "${APPLICATIONS_DIR}" mkdir -p "${DESKTOP_DIR}" chown :staff /usr/share/Desktop chmod 775 /usr/share/Desktop From e8f33f9b389db5f09ac6f61b248e58620b3e2f89 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 15:03:35 -0700 Subject: [PATCH 10/14] Update desktop.sh --- desktop.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop.sh b/desktop.sh index f3638b9..095c421 100644 --- a/desktop.sh +++ b/desktop.sh @@ -47,5 +47,6 @@ for icon_file_path in "${REPO_DIR}"/Desktop/*.png; do done for icon_file_path in "${REPO_DIR}"/Desktop/*.svg; do cp "${icon_file_path}" "${ICON_PACKAGES_DIR}/" || echo "Failed to copy ${icon_file_path}" -donegtk-update-icon-cache "${ICON_DIR}" +done +gtk-update-icon-cache "${ICON_DIR}" From d8b9a236e84bc48f56de77f16ab14c9a2d04f8f8 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 15:06:16 -0700 Subject: [PATCH 11/14] Update appendix --- appendix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/appendix b/appendix index 26ab571..a2eba18 100644 --- a/appendix +++ b/appendix @@ -55,6 +55,9 @@ ONBUILD USER ${NB_USER} # ${REPO_DIR} is owned by ${NB_USER} ONBUILD COPY --chown=${NB_USER}:${NB_USER} . ${REPO_DIR}/childimage +# The Desktop and apt.txt installs need to be root +ONBUILD USER root + # Copy Desktop files into ${REPO_DIR}/Desktop if they exist. start will copy to Application dir and Desktop # Will not fail if Desktop dir exists but is empty ONBUILD RUN echo "Checking for 'Desktop directory'..." \ @@ -68,7 +71,6 @@ ONBUILD RUN echo "Checking for 'Desktop directory'..." \ # Install apt packages specified in a apt.txt file if it exists. # blank lines and comments are supported in apt.txt -ONBUILD USER root ONBUILD RUN echo "Checking for 'apt.txt'..." \ ; cd "${REPO_DIR}/childimage/" \ ; if test -f "apt.txt" ; then \ @@ -79,6 +81,7 @@ ONBUILD RUN echo "Checking for 'apt.txt'..." \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ ; fi + ONBUILD USER ${NB_USER} # Add the conda environment From 83390b07c4450348e6b757331c76eab63a37ad2b Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Wed, 30 Oct 2024 15:58:37 -0700 Subject: [PATCH 12/14] Update desktop.sh --- desktop.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/desktop.sh b/desktop.sh index 095c421..da756a1 100644 --- a/desktop.sh +++ b/desktop.sh @@ -42,6 +42,13 @@ update-mime-database "${MIME_DIR}" ICON_DIR="/usr/share/icons" ICON_PACKAGES_DIR="${ICON_DIR}/packages" mkdir -p "${ICON_PACKAGES_DIR}" +# Create the required index.theme file +cat < "${ICON_PACKAGES_DIR}/index.theme" +[Icon Theme] +Name=xfce4 display icons +Comment=User provided icons for applications +EOF +# Copy in the icons for icon_file_path in "${REPO_DIR}"/Desktop/*.png; do cp "${icon_file_path}" "${ICON_PACKAGES_DIR}/" || echo "Failed to copy ${icon_file_path}" done From 725fb4cb92ef1c12ef7b7bc990cbce9990bcc7f3 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Thu, 31 Oct 2024 17:07:50 -0700 Subject: [PATCH 13/14] fix icon directory --- desktop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop.sh b/desktop.sh index da756a1..06f86b8 100644 --- a/desktop.sh +++ b/desktop.sh @@ -55,5 +55,5 @@ done for icon_file_path in "${REPO_DIR}"/Desktop/*.svg; do cp "${icon_file_path}" "${ICON_PACKAGES_DIR}/" || echo "Failed to copy ${icon_file_path}" done -gtk-update-icon-cache "${ICON_DIR}" +gtk-update-icon-cache "${ICON_PACKAGES_DIR}" From f5ee1fd5e5bbad6e6be9db0927d2d7cdbd03870d Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Thu, 31 Oct 2024 21:37:27 -0700 Subject: [PATCH 14/14] add icons to hicolor instead --- desktop.sh | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/desktop.sh b/desktop.sh index 06f86b8..ba1588a 100644 --- a/desktop.sh +++ b/desktop.sh @@ -39,21 +39,32 @@ done update-mime-database "${MIME_DIR}" # Add icons -ICON_DIR="/usr/share/icons" -ICON_PACKAGES_DIR="${ICON_DIR}/packages" -mkdir -p "${ICON_PACKAGES_DIR}" -# Create the required index.theme file -cat < "${ICON_PACKAGES_DIR}/index.theme" -[Icon Theme] -Name=xfce4 display icons -Comment=User provided icons for applications -EOF -# Copy in the icons +ICON_DIR="/usr/share/icons/hicolor" +ICON_SIZES=("16x16" "22x22" "24x24" "32x32" "48x48") + +# Copy PNG icons only to existing size directories for icon_file_path in "${REPO_DIR}"/Desktop/*.png; do - cp "${icon_file_path}" "${ICON_PACKAGES_DIR}/" || echo "Failed to copy ${icon_file_path}" + for size in "${ICON_SIZES[@]}"; do + target_dir="${ICON_DIR}/${size}/apps" + if [ -d "${target_dir}" ]; then + cp "${icon_file_path}" "${target_dir}/$(basename "${icon_file_path}")" || echo "Failed to copy ${icon_file_path} to ${target_dir}" + else + echo "Directory ${target_dir} does not exist. Skipping." + fi + done done + +# Copy SVG icons only to the existing scalable directory, if it exists +target_dir="${ICON_DIR}/scalable/apps" for icon_file_path in "${REPO_DIR}"/Desktop/*.svg; do - cp "${icon_file_path}" "${ICON_PACKAGES_DIR}/" || echo "Failed to copy ${icon_file_path}" + if [ -d "${target_dir}" ]; then + cp "${icon_file_path}" "${target_dir}/$(basename "${icon_file_path}")" || echo "Failed to copy ${icon_file_path} to ${target_dir}" + else + echo "Directory ${target_dir} does not exist. Skipping SVG." + fi done -gtk-update-icon-cache "${ICON_PACKAGES_DIR}" +# Update the icon cache for hicolor +gtk-update-icon-cache "${ICON_DIR}" +# Print a success message +echo "Icons have been copied to existing hicolor directories, and the icon cache has been updated."