-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreate-icon-theme-uni.sh
More file actions
executable file
·195 lines (166 loc) · 6.11 KB
/
create-icon-theme-uni.sh
File metadata and controls
executable file
·195 lines (166 loc) · 6.11 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
set -euo pipefail
for cmd in rsync curl unzip convert; do
if ! command -v "$cmd" >/dev/null; then
echo "[!] Required command '$cmd' is not installed. Please install it and re-run."
exit 1
fi
done
ICON_SOURCE_DIR="${HOME}/Pictures/icons/icons_theme"
ICON_THEME_NAME="Yaru-blue-qortal"
ICON_CACHE_DIR="${HOME}/.icons/${ICON_THEME_NAME}"
TARGET_THEME_DIR="${ICON_CACHE_DIR}/48x48/apps"
# Download icons if missing
if [ ! -d "${ICON_SOURCE_DIR}" ]; then
echo "🔽 Downloading Qortal icon set..."
mkdir -p "${HOME}/iconTemp"
trap 'rm -rf "${HOME}/iconTemp"' EXIT
cd "${HOME}/iconTemp" || exit 1
#TODO - UPDATE THESE DOWNLOAD LOCATIONS WITH QDN LOCATIONS (MOST LIKELY PUBLISHED AS A WEBSITE TO ALLOW DIRECT WGET DOWNLOADS)
PRIMARY_URL="https://cloud.qortal.org/s/machinePicturesFolder/download"
BACKUP_URL="https://cloud.crowetic.com/s/m9GZyy8k6n7NYJZ/download"
echo "🌐 Trying primary source..."
if curl -fL -o Pictures.zip "$PRIMARY_URL"; then
echo "✅ Downloaded from primary."
else
echo "⚠️ Primary download failed. Trying backup source..."
if curl -fL -o Pictures.zip "$BACKUP_URL"; then
echo "✅ Downloaded from backup."
else
echo "❌ Both downloads failed. Aborting. ICON FILES FAILED TO DOWNLOAD, PLEASE RUN ./create-icon-theme-uni.sh LATER TO TRY AGAIN!"
exit 1
fi
fi
if unzip Pictures.zip; then
echo "📂 Extracted icon archive."
mv Pictures/* "${HOME}/Pictures/"
else
echo "❌ Failed to unzip icon archive. Aborting."
exit 1
fi
cd || exit 1
fi
# Define icon mappings
declare -A ICON_MAP=(
["qortal-menu-button.png"]="qortal-menu-button"
["qortal-menu-button-2.png"]="qortal-menu-button-2"
["qortal-menu-button-3.png"]="qortal-menu-button-3"
["qortal-menu-button-4.png"]="qortal-menu-button-4"
["qortal-ui.png"]="qortal-ui"
["qortal-hub.png"]="qortal-hub"
["qortal.png"]="qortal"
)
# Step 1: Choose base theme
BASE_THEME_DIR=""
if [ -d "/usr/share/icons/Yaru-dark" ]; then
BASE_THEME_DIR="/usr/share/icons/Yaru-dark"
echo "[*] Using Yaru-dark as base."
else
CURRENT_THEME=$(gsettings get org.gnome.desktop.interface icon-theme 2>/dev/null | tr -d "'")
if [ -n "$CURRENT_THEME" ] && [ -d "/usr/share/icons/$CURRENT_THEME" ]; then
BASE_THEME_DIR="/usr/share/icons/$CURRENT_THEME"
echo "[*] Falling back to current icon theme: $CURRENT_THEME"
else
echo "[!] Could not find Yaru-dark or current theme. Creating minimal fallback..."
mkdir -p "${ICON_CACHE_DIR}/48x48/apps"
cat <<EOF > "${ICON_CACHE_DIR}/index.theme"
[Icon Theme]
Name=${ICON_THEME_NAME}
Inherits=hicolor
Directories=48x48/apps
[48x48/apps]
Size=48
Context=Applications
Type=Fixed
EOF
fi
fi
# Step 2: Copy base theme if found
if [ -n "$BASE_THEME_DIR" ] && [ ! -d "${ICON_CACHE_DIR}" ]; then
echo "[*] Copying base theme from: $BASE_THEME_DIR"
mkdir -p "${ICON_CACHE_DIR}"
rsync -a "$BASE_THEME_DIR/" "${ICON_CACHE_DIR}/"
if [ -f "/usr/share/icons/Yaru-blue-dark/index.theme" ]; then
cp /usr/share/icons/Yaru-blue-dark/index.theme "${ICON_CACHE_DIR}/index.theme"
fi
sed -i 's/^Name=.*/Name=Yaru-blue-qortal/' "${ICON_CACHE_DIR}/index.theme"
sed -i 's/^Inherits=.*/Inherits=Yaru-blue-dark,Yaru-dark,Yaru,hicolor/' "${ICON_CACHE_DIR}/index.theme"
if ! grep -q "48x48/apps" "${ICON_CACHE_DIR}/index.theme"; then
echo "Directories=48x48/apps" >> "${ICON_CACHE_DIR}/index.theme"
echo "
[48x48/apps]
Size=48
Context=Applications
Type=Fixed" >> "${ICON_CACHE_DIR}/index.theme"
fi
fi
# Step 3: Install icons
mkdir -p "${TARGET_THEME_DIR}"
install_icon() {
local src="$1"
local name="$2"
local dest="${TARGET_THEME_DIR}/${name}.png"
if [ ! -f "$src" ]; then
echo "[!] Missing source icon: $src"
return
fi
echo "[*] Installing icon: $name"
convert "$src" -resize 48x48 "$dest"
}
for src in "${!ICON_MAP[@]}"; do
install_icon "${ICON_SOURCE_DIR}/${src}" "${ICON_MAP[$src]}"
done
# Step 4: Update icon cache
if [ -f "${ICON_CACHE_DIR}/index.theme" ]; then
gtk-update-icon-cache -f "${ICON_CACHE_DIR}" || echo "[!] gtk-update-icon-cache failed or not found."
fi
# Step 5: Set icon theme if DE supports it
CURRENT_DESKTOP=$(printf '%s' "${XDG_CURRENT_DESKTOP:-}" | tr '[:upper:]' '[:lower:]')
# Normalize aliases
case "$CURRENT_DESKTOP" in
x-cinnamon) CURRENT_DESKTOP="cinnamon" ;;
xfce*) CURRENT_DESKTOP="xfce" ;;
*plasma* | *kde*) CURRENT_DESKTOP="plasma" ;;
kde-plasma) CURRENT_DESKTOP="plasma" ;;
esac
case "$CURRENT_DESKTOP" in
cinnamon)
if command -v gsettings >/dev/null 2>&1; then
gsettings set org.cinnamon.desktop.interface icon-theme "${ICON_THEME_NAME}"
else
echo "[!] gsettings not available. Please set the Cinnamon icon theme manually if needed."
fi
;;
gnome)
if command -v gsettings >/dev/null 2>&1; then
gsettings set org.gnome.desktop.interface icon-theme "${ICON_THEME_NAME}"
else
echo "[!] gsettings not available. Please set the GNOME icon theme manually if needed."
fi
;;
xfce)
if command -v xfconf-query >/dev/null 2>&1; then
xfconf-query -c xsettings -p /Net/IconThemeName -s "${ICON_THEME_NAME}" 2>/dev/null
else
echo "[!] xfconf-query not available. Please set the XFCE icon theme manually if needed."
fi
;;
kde | plasma)
if command -v kwriteconfig6 >/dev/null 2>&1; then
kwriteconfig6 --file kdeglobals --group Icons --key Theme "${ICON_THEME_NAME}"
elif command -v kwriteconfig5 >/dev/null 2>&1; then
kwriteconfig5 --file kdeglobals --group Icons --key Theme "${ICON_THEME_NAME}"
else
echo "[!] Neither kwriteconfig6 nor kwriteconfig5 is available. Please set the Plasma icon theme manually if needed."
fi
;;
*)
echo "[!] Unsupported or unknown DE: '$CURRENT_DESKTOP'. Set icon theme manually if needed."
;;
esac
if [ "$CURRENT_DESKTOP" = "plasma" ] && command -v qdbus >/dev/null 2>&1; then
qdbus org.kde.KWin /KWin reconfigure >/dev/null 2>&1 || true
fi
echo "✅ Qortal icons installed into local theme: ${ICON_THEME_NAME}"
echo "ℹ️ You can now use Icon=qortal-ui (etc.) in .desktop files."
echo "💡 If icons don't show up immediately, try logging out and back in."