Skip to content

Commit

Permalink
Merge pull request #129 from nmfs-opensci/eeholmes-dev-1
Browse files Browse the repository at this point in the history
Create desktop.sh
  • Loading branch information
eeholmes authored Oct 30, 2024
2 parents 94fc9f0 + f2ae636 commit 17e1319
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
6 changes: 4 additions & 2 deletions appendix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions desktop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
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
mkdir -p "${DESKTOP_DIR}"
# 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}/."

# 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="/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}"

0 comments on commit 17e1319

Please sign in to comment.