testing create-icon-theme universal
This commit is contained in:
parent
83e285f13d
commit
74f8b6ef5e
144
create-icon-theme-uni.sh
Normal file
144
create-icon-theme-uni.sh
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
#!/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"
|
||||||
|
curl -L -o icons.zip https://cloud.qortal.org/s/machinePicturesFolder/download
|
||||||
|
unzip icons.zip
|
||||||
|
mv Pictures/* "${HOME}/Pictures/"
|
||||||
|
cd
|
||||||
|
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="${XDG_CURRENT_DESKTOP,,}"
|
||||||
|
echo "[*] Attempting to set theme on $CURRENT_DESKTOP..."
|
||||||
|
|
||||||
|
if command -v gsettings >/dev/null; then
|
||||||
|
case "$CURRENT_DESKTOP" in
|
||||||
|
cinnamon)
|
||||||
|
gsettings set org.cinnamon.desktop.interface icon-theme "${ICON_THEME_NAME}"
|
||||||
|
;;
|
||||||
|
gnome)
|
||||||
|
gsettings set org.gnome.desktop.interface icon-theme "${ICON_THEME_NAME}"
|
||||||
|
;;
|
||||||
|
xfce|xfce4)
|
||||||
|
xfconf-query -c xsettings -p /Net/IconThemeName -s "${ICON_THEME_NAME}" 2>/dev/null
|
||||||
|
;;
|
||||||
|
kde|plasma)
|
||||||
|
kwriteconfig5 --file kdeglobals --group Icons --key Theme "${ICON_THEME_NAME}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "[!] Unsupported or unknown DE: '$CURRENT_DESKTOP'. Set icon theme manually if needed."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo "[!] gsettings not available. Please set icon theme manually if needed."
|
||||||
|
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."
|
@ -1,31 +1,84 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DEBUG=${DEBUG:-false}
|
||||||
|
|
||||||
|
log() {
|
||||||
|
echo -e "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
debug() {
|
||||||
|
if [ "$DEBUG" = true ]; then echo -e "[DEBUG] $1"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
for cmd in rsync curl unzip convert; do
|
for cmd in rsync curl unzip convert; do
|
||||||
if ! command -v $cmd >/dev/null; then
|
if ! command -v $cmd &>/dev/null; then
|
||||||
echo "[!] Required command '$cmd' is not installed. Please install it and re-run."
|
echo "[!] Required command '$cmd' is not installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Customize Yaru-blue-dark icon theme locally and add Qortal icons
|
# Detect icon install path
|
||||||
ICON_THEME_NAME="Yaru-blue-qortal"
|
ICON_THEME_NAME="Yaru-blue-qortal"
|
||||||
ICON_SOURCE_DIR="${HOME}/Pictures/icons/icons_theme"
|
ICON_SOURCE_DIR="${HOME}/Pictures/icons/icons_theme"
|
||||||
ICON_CACHE_DIR="${HOME}/.icons/${ICON_THEME_NAME}"
|
if [ -d "$HOME/.local/share/icons" ]; then
|
||||||
TARGET_THEME_DIR="${ICON_CACHE_DIR}/48x48/apps"
|
USER_ICON_ROOT="$HOME/.local/share/icons"
|
||||||
|
else
|
||||||
|
USER_ICON_ROOT="$HOME/.icons"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ICON_CACHE_DIR="${USER_ICON_ROOT}/${ICON_THEME_NAME}"
|
||||||
|
TARGET_THEME_DIR="${ICON_CACHE_DIR}/48x48/apps"
|
||||||
|
mkdir -p "${TARGET_THEME_DIR}"
|
||||||
|
|
||||||
|
# Download icons if missing
|
||||||
if [ ! -d "${ICON_SOURCE_DIR}" ]; then
|
if [ ! -d "${ICON_SOURCE_DIR}" ]; then
|
||||||
echo "downloading icon files..."
|
log "📥 Downloading Qortal icons..."
|
||||||
mkdir -p "${HOME}/iconTemp"
|
mkdir -p "${HOME}/iconTemp"
|
||||||
trap 'rm -rf "${HOME}/iconTemp"' EXIT
|
trap 'rm -rf "${HOME}/iconTemp"' EXIT
|
||||||
cd "${HOME}/iconTemp"
|
cd "${HOME}/iconTemp"
|
||||||
curl -L -O https://cloud.qortal.org/s/machinePicturesFolder/download
|
curl -L -O https://cloud.qortal.org/s/machinePicturesFolder/download
|
||||||
unzip download
|
unzip download
|
||||||
mv Pictures/* "${HOME}/Pictures/"
|
mv Pictures/* "${HOME}/Pictures/"
|
||||||
rm -rf "${HOME}/iconTemp"
|
|
||||||
cd
|
cd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Mapping of source icons to icon names
|
# Copy and modify base icon theme
|
||||||
|
if [ ! -d "${ICON_CACHE_DIR}" ]; then
|
||||||
|
log "🎨 Creating theme '${ICON_THEME_NAME}' from Yaru-dark..."
|
||||||
|
|
||||||
|
if [ -d /usr/share/icons/Yaru-dark ]; then
|
||||||
|
rsync -a /usr/share/icons/Yaru-dark/ "${ICON_CACHE_DIR}/"
|
||||||
|
else
|
||||||
|
echo "[!] Yaru-dark not found. Cannot create icon theme."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy over index.theme
|
||||||
|
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"
|
||||||
|
elif [ ! -f "${ICON_CACHE_DIR}/index.theme" ]; then
|
||||||
|
cat <<EOF > "${ICON_CACHE_DIR}/index.theme"
|
||||||
|
[Icon Theme]
|
||||||
|
Name=${ICON_THEME_NAME}
|
||||||
|
Comment=Qortal custom icons with Yaru base
|
||||||
|
Inherits=Yaru-dark,Yaru,hicolor
|
||||||
|
Directories=48x48/apps
|
||||||
|
|
||||||
|
[48x48/apps]
|
||||||
|
Size=48
|
||||||
|
Context=Applications
|
||||||
|
Type=Fixed
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -i "s/^Name=.*/Name=${ICON_THEME_NAME}/" "${ICON_CACHE_DIR}/index.theme"
|
||||||
|
sed -i "s/^Inherits=.*/Inherits=Yaru-blue-dark,Yaru-dark,Yaru,hicolor/" "${ICON_CACHE_DIR}/index.theme"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Map and install icons
|
||||||
declare -A ICON_MAP=(
|
declare -A ICON_MAP=(
|
||||||
["qortal-menu-button.png"]="qortal-menu-button"
|
["qortal-menu-button.png"]="qortal-menu-button"
|
||||||
["qortal-menu-button-2.png"]="qortal-menu-button-2"
|
["qortal-menu-button-2.png"]="qortal-menu-button-2"
|
||||||
@ -36,101 +89,60 @@ declare -A ICON_MAP=(
|
|||||||
["qortal.png"]="qortal"
|
["qortal.png"]="qortal"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Step 1: Copy system Yaru-dark theme as base
|
|
||||||
if [ ! -d "${ICON_CACHE_DIR}" ]; then
|
|
||||||
echo "[*] Creating local copy of Yaru-dark theme as '${ICON_THEME_NAME}'..."
|
|
||||||
mkdir -p "${ICON_CACHE_DIR}"
|
|
||||||
rsync -a /usr/share/icons/Yaru-dark/ "${ICON_CACHE_DIR}/"
|
|
||||||
|
|
||||||
# Copy index.theme from Yaru-blue-dark if it exists
|
|
||||||
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
|
|
||||||
|
|
||||||
# Update index.theme metadata
|
|
||||||
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"
|
|
||||||
|
|
||||||
# Ensure Directories includes 48x48/apps
|
|
||||||
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 2: Ensure target icon directory exists
|
|
||||||
mkdir -p "${TARGET_THEME_DIR}"
|
|
||||||
|
|
||||||
# Step 3: Install icons (resized if possible)
|
|
||||||
install_icon() {
|
install_icon() {
|
||||||
local src="$1"
|
local src="$1"
|
||||||
local name="$2"
|
local name="$2"
|
||||||
local dest="${TARGET_THEME_DIR}/${name}.png"
|
local dest="${TARGET_THEME_DIR}/${name}.png"
|
||||||
|
|
||||||
if [ ! -f "$src" ]; then
|
if [ ! -f "$src" ]; then
|
||||||
echo "[!] Source icon not found: $src"
|
echo "[!] Icon not found: $src"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v convert &>/dev/null; then
|
if command -v convert &>/dev/null; then
|
||||||
echo "[*] Resizing and installing $name to ${TARGET_THEME_DIR}"
|
|
||||||
convert "$src" -resize 48x48 "$dest"
|
convert "$src" -resize 48x48 "$dest"
|
||||||
|
debug "Installed and resized $name to $dest"
|
||||||
else
|
else
|
||||||
echo "[*] Copying $name without resizing to ${TARGET_THEME_DIR}"
|
|
||||||
cp "$src" "$dest"
|
cp "$src" "$dest"
|
||||||
|
debug "Copied $name to $dest without resizing"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 4: Loop through and install icons
|
log "🧩 Installing icons..."
|
||||||
for src in "${!ICON_MAP[@]}"; do
|
for src in "${!ICON_MAP[@]}"; do
|
||||||
install_icon "${ICON_SOURCE_DIR}/${src}" "${ICON_MAP[$src]}"
|
install_icon "${ICON_SOURCE_DIR}/${src}" "${ICON_MAP[$src]}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Step 5: Update the icon cache
|
# Update icon cache
|
||||||
if [ -f "${ICON_CACHE_DIR}/index.theme" ]; then
|
if command -v gtk-update-icon-cache &>/dev/null && [ -f "${ICON_CACHE_DIR}/index.theme" ]; then
|
||||||
echo "[*] Updating icon cache for '${ICON_THEME_NAME}'..."
|
gtk-update-icon-cache -f "${ICON_CACHE_DIR}" || true
|
||||||
gtk-update-icon-cache -f "${ICON_CACHE_DIR}" || echo "[!] gtk-update-icon-cache failed or not found."
|
|
||||||
else
|
|
||||||
echo "[!] No index.theme file found. Cannot update icon cache."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 6: Set as active icon theme
|
# Set icon theme based on DE
|
||||||
if [ -z "$CURRENT_DESKTOP" ]; then
|
CURRENT_DE=$(echo "${XDG_CURRENT_DESKTOP:-${DESKTOP_SESSION:-unknown}}" | tr '[:upper:]' '[:lower:]')
|
||||||
echo "[!] XDG_CURRENT_DESKTOP not set. Unable to auto-detect DE. Set icon theme manually if needed."
|
|
||||||
else
|
|
||||||
echo "[*] Setting '${ICON_THEME_NAME}' as the current icon theme..."
|
|
||||||
CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP,,}"
|
|
||||||
|
|
||||||
if command -v gsettings >/dev/null; then
|
log "🖥️ Detected Desktop Environment: $CURRENT_DE"
|
||||||
case "$CURRENT_DESKTOP" in
|
|
||||||
cinnamon)
|
|
||||||
gsettings set org.cinnamon.desktop.interface icon-theme "${ICON_THEME_NAME}"
|
|
||||||
;;
|
|
||||||
gnome)
|
|
||||||
gsettings set org.gnome.desktop.interface icon-theme "${ICON_THEME_NAME}"
|
|
||||||
;;
|
|
||||||
xfce|xfce4)
|
|
||||||
xfconf-query -c xsettings -p /Net/IconThemeName -s "${ICON_THEME_NAME}" 2>/dev/null
|
|
||||||
;;
|
|
||||||
kde|plasma)
|
|
||||||
kwriteconfig5 --file kdeglobals --group Icons --key Theme "${ICON_THEME_NAME}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "[!] Unsupported or unknown DE: '$CURRENT_DESKTOP'. Set icon theme manually if needed."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
echo "[!] gsettings not found. Cannot apply icon theme automatically."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
case "$CURRENT_DE" in
|
||||||
|
cinnamon)
|
||||||
|
gsettings set org.cinnamon.desktop.interface icon-theme "${ICON_THEME_NAME}" 2>/dev/null || true
|
||||||
|
;;
|
||||||
|
gnome)
|
||||||
|
gsettings set org.gnome.desktop.interface icon-theme "${ICON_THEME_NAME}" 2>/dev/null || true
|
||||||
|
;;
|
||||||
|
mate)
|
||||||
|
gsettings set org.mate.interface icon-theme "${ICON_THEME_NAME}" 2>/dev/null || true
|
||||||
|
;;
|
||||||
|
xfce|xfce4)
|
||||||
|
xfconf-query -c xsettings -p /Net/IconThemeName -s "${ICON_THEME_NAME}" 2>/dev/null || true
|
||||||
|
;;
|
||||||
|
kde|plasma)
|
||||||
|
kwriteconfig5 --file kdeglobals --group Icons --key Theme "${ICON_THEME_NAME}" 2>/dev/null || true
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "[ℹ️] Unknown or unsupported DE. Please set '${ICON_THEME_NAME}' manually in system settings."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
echo "✅ Qortal icons installed into local theme: ${ICON_THEME_NAME}"
|
log "✅ Qortal icons installed into theme '${ICON_THEME_NAME}'"
|
||||||
echo " You can now use Icon=qortal-ui (etc.) in .desktop files."
|
log "ℹ️ If icons don't appear immediately, restart your session or reapply theme."
|
||||||
echo " Theme is now active with blue-dark base styling."
|
|
||||||
echo "ℹ️ If icons don't update immediately, try logging out and back in."
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user