Skip to content

Commit

Permalink
Merge pull request #130 from nmfs-opensci/eeholmes-dev-1
Browse files Browse the repository at this point in the history
Update desktop.sh
  • Loading branch information
eeholmes authored Oct 30, 2024
2 parents 17e1319 + 5c1ceec commit adc835a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
17 changes: 17 additions & 0 deletions desktop.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -34,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}"

35 changes: 0 additions & 35 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -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 )

Expand Down

0 comments on commit adc835a

Please sign in to comment.