-
Notifications
You must be signed in to change notification settings - Fork 0
/
desktop.sh
70 lines (61 loc) · 2.92 KB
/
desktop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/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
# Copy in the Desktop files
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
# 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}"
# Add 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
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
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
# 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."