1
0
Fork 0
mirror of https://github.com/vinceliuice/WhiteSur-icon-theme.git synced 2024-11-24 14:50:08 +00:00
WhiteSur-icon-theme/install.sh

339 lines
12 KiB
Bash
Raw Normal View History

2022-02-23 13:38:43 +00:00
#!/usr/bin/env bash
2020-07-22 14:32:28 +00:00
2024-04-18 11:55:14 +00:00
set -eo pipefail
2023-03-07 07:48:51 +00:00
2020-07-22 14:32:28 +00:00
ROOT_UID=0
DEST_DIR=
# Destination directory
if [ "$UID" -eq "$ROOT_UID" ]; then
DEST_DIR="/usr/share/icons"
else
DEST_DIR="$HOME/.local/share/icons"
fi
2021-06-25 04:09:48 +00:00
SRC_DIR="$(cd "$(dirname "$0")" && pwd)"
2020-07-22 14:32:28 +00:00
THEME_NAME=WhiteSur
2023-07-03 02:48:21 +00:00
COLOR_VARIANTS=('' '-light' '-dark')
2022-07-05 15:50:46 +00:00
THEME_VARIANTS=('' '-purple' '-pink' '-red' '-orange' '-yellow' '-green' '-grey' '-nord')
2020-07-22 14:32:28 +00:00
2023-03-07 06:56:21 +00:00
themes=()
colors=()
2020-07-22 14:32:28 +00:00
usage() {
2021-06-25 04:09:48 +00:00
cat << EOF
Usage: $0 [OPTION]...
OPTIONS:
-d, --dest DIR Specify destination directory (Default: $DEST_DIR)
-n, --name NAME Specify theme name (Default: $THEME_NAME)
2022-07-05 15:50:46 +00:00
-t, --theme VARIANT Specify theme color variant(s) [default|purple|pink|red|orange|yellow|green|grey|nord|all] (Default: blue)
2021-06-25 04:09:48 +00:00
-a, --alternative Install alternative icons for software center and file-manager
2023-07-03 02:48:21 +00:00
-b, --bold Install bolder panel icons version (1.5px size)
2022-12-10 02:04:00 +00:00
-r, --remove,
-u, --uninstall Uninstall (remove) icon themes
2021-06-25 04:09:48 +00:00
-h, --help Show help
EOF
2020-07-22 14:32:28 +00:00
}
install() {
local dest=${1}
local name=${2}
2021-01-19 08:55:49 +00:00
local theme=${3}
local color=${4}
2020-07-22 14:32:28 +00:00
2021-01-19 08:55:49 +00:00
local THEME_DIR=${dest}/${name}${theme}${color}
2020-07-22 14:32:28 +00:00
2024-02-29 17:24:08 +00:00
[[ -d "${THEME_DIR}" ]] && rm -rf "${THEME_DIR}"
2020-07-22 14:32:28 +00:00
echo "Installing '${THEME_DIR}'..."
2024-02-29 17:24:08 +00:00
mkdir -p "${THEME_DIR}"
cp -r "${SRC_DIR}"/{COPYING,AUTHORS} "${THEME_DIR}"
cp -r "${SRC_DIR}"/src/index.theme "${THEME_DIR}"
2020-07-22 14:32:28 +00:00
2024-02-29 17:24:08 +00:00
#cd "${THEME_DIR}"
sed -i "s/${name}/${name}${theme}${color}/g" "${THEME_DIR}"/index.theme
2020-07-22 14:32:28 +00:00
if [[ ${color} == '' ]]; then
2024-02-29 17:24:08 +00:00
mkdir -p "${THEME_DIR}"/status
cp -r "${SRC_DIR}"/src/{actions,animations,apps,categories,devices,emblems,mimes,places,preferences} "${THEME_DIR}"
cp -r "${SRC_DIR}"/src/status/{16,22,24,32,symbolic} "${THEME_DIR}"/status
2021-07-20 10:40:06 +00:00
if [[ ${black:-} == 'true' ]]; then
sed -i "s/#ffffff/#363636/g" "${THEME_DIR}"/status/{16,22,24}/*
fi
2021-07-05 00:43:08 +00:00
if [[ ${bold:-} == 'true' ]]; then
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/bold/* "${THEME_DIR}"
2021-07-05 00:43:08 +00:00
fi
2020-08-16 07:28:44 +00:00
if [[ $DESKTOP_SESSION == '/usr/share/xsessions/budgie-desktop' ]]; then
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/src/status/symbolic-budgie/*.svg "${THEME_DIR}"/status/symbolic
2020-08-16 07:28:44 +00:00
fi
2020-07-22 14:32:28 +00:00
2021-06-25 04:09:48 +00:00
if [[ ${alternative:-} == 'true' ]]; then
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/alternative/* "${THEME_DIR}"
2021-06-25 04:09:48 +00:00
fi
if [[ ${theme} != '' ]]; then
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/colors/color${theme}/*.svg "${THEME_DIR}"/places/scalable
2021-06-25 04:09:48 +00:00
fi
2023-07-03 02:48:21 +00:00
2024-04-20 16:32:18 +00:00
rm -rf "${THEME_DIR}"/places/scalable/user-trash{'','-full'}-dark.svg
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/links/{actions,apps,categories,devices,emblems,mimes,places,status,preferences} "${THEME_DIR}"
2024-04-08 03:23:46 +00:00
ln -s "${THEME_DIR}"/preferences/32 "${THEME_DIR}"/preferences/22
2023-07-03 02:48:21 +00:00
fi
if [[ ${color} == '-light' ]]; then
2024-02-29 17:24:08 +00:00
mkdir -p "${THEME_DIR}"/status
cp -r "${SRC_DIR}"/src/status/{16,22,24} "${THEME_DIR}"/status
2023-07-03 02:48:21 +00:00
if [[ ${bold:-} == 'true' ]]; then
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/bold/status/{16,22,24} "${THEME_DIR}"/status
2023-07-03 02:48:21 +00:00
fi
# Change icon color for light theme
sed -i "s/#ffffff/#363636/g" "${THEME_DIR}"/status/{16,22,24}/*
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/links/status/{16,22,24} "${THEME_DIR}"/status
2023-07-03 02:48:21 +00:00
cd ${dest}
ln -s ../${name}${theme}/actions ${name}${theme}-light/actions
ln -s ../${name}${theme}/animations ${name}${theme}-light/animations
ln -s ../${name}${theme}/apps ${name}${theme}-light/apps
ln -s ../${name}${theme}/categories ${name}${theme}-light/categories
ln -s ../${name}${theme}/devices ${name}${theme}-light/devices
ln -s ../${name}${theme}/emblems ${name}${theme}-light/emblems
ln -s ../${name}${theme}/mimes ${name}${theme}-light/mimes
ln -s ../${name}${theme}/places ${name}${theme}-light/places
2023-09-11 14:55:27 +00:00
ln -s ../${name}${theme}/preferences ${name}${theme}-light/preferences
2023-07-03 02:48:21 +00:00
ln -s ../../${name}${theme}/status/32 ${name}${theme}-light/status/32
ln -s ../../${name}${theme}/status/symbolic ${name}${theme}-light/status/symbolic
2021-01-19 08:55:49 +00:00
fi
2020-07-22 14:32:28 +00:00
if [[ ${color} == '-dark' ]]; then
2024-02-29 17:24:08 +00:00
mkdir -p "${THEME_DIR}"/{apps,categories,emblems,devices,mimes,places,status}
cp -r "${SRC_DIR}"/src/actions "${THEME_DIR}"
2024-05-07 21:08:12 +00:00
cp -r "${SRC_DIR}"/src/apps/{22,32,symbolic} "${THEME_DIR}"/apps
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/src/categories/symbolic "${THEME_DIR}"/categories
cp -r "${SRC_DIR}"/src/emblems/symbolic "${THEME_DIR}"/emblems
cp -r "${SRC_DIR}"/src/mimes/symbolic "${THEME_DIR}"/mimes
2024-04-08 16:56:16 +00:00
cp -r "${SRC_DIR}"/src/devices/{16,22,24,32,symbolic} "${THEME_DIR}"/devices
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/src/places/{16,22,24,scalable,symbolic} "${THEME_DIR}"/places
cp -r "${SRC_DIR}"/src/status/symbolic "${THEME_DIR}"/status
2020-07-22 14:32:28 +00:00
2021-07-05 14:23:48 +00:00
if [[ ${bold:-} == 'true' ]]; then
2024-04-18 11:55:14 +00:00
cp -r "${SRC_DIR}"/bold/actions/symbolic/*.svg "${THEME_DIR}"/actions/symbolic
cp -r "${SRC_DIR}"/bold/apps/symbolic/*.svg "${THEME_DIR}"/apps/symbolic
cp -r "${SRC_DIR}"/bold/devices/symbolic/*.svg "${THEME_DIR}"/devices/symbolic
cp -r "${SRC_DIR}"/bold/status/symbolic/*.svg "${THEME_DIR}"/status/symbolic
2021-07-05 14:23:48 +00:00
fi
2023-07-03 02:48:21 +00:00
if [[ ${alternative:-} == 'true' ]]; then
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/alternative/apps/symbolic/*.svg "${THEME_DIR}"/apps/symbolic
2024-04-20 16:32:18 +00:00
cp -r "${SRC_DIR}"/alternative/places/scalable/*.svg "${THEME_DIR}"/places/scalable
2023-07-03 02:48:21 +00:00
fi
2024-04-21 16:17:42 +00:00
if [[ ${theme} != '' ]]; then
cp -r "${SRC_DIR}"/colors/color${theme}/*.svg "${THEME_DIR}"/places/scalable
fi
2020-08-16 07:28:44 +00:00
if [[ $DESKTOP_SESSION == '/usr/share/xsessions/budgie-desktop' ]]; then
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/src/status/symbolic-budgie/*.svg "${THEME_DIR}"/status/symbolic
2020-08-16 07:28:44 +00:00
fi
2024-04-20 16:32:18 +00:00
mv -f "${THEME_DIR}"/places/scalable/user-trash-dark.svg "${THEME_DIR}"/places/scalable/user-trash.svg
mv -f "${THEME_DIR}"/places/scalable/user-trash-full-dark.svg "${THEME_DIR}"/places/scalable/user-trash-full.svg
2020-07-22 14:32:28 +00:00
# Change icon color for dark theme
2023-07-03 02:48:21 +00:00
sed -i "s/#363636/#dedede/g" "${THEME_DIR}"/{actions,devices,places}/{16,22,24}/*
2024-05-07 21:08:12 +00:00
sed -i "s/#363636/#dedede/g" "${THEME_DIR}"/apps/{22,32}/*
2024-04-08 16:56:16 +00:00
sed -i "s/#363636/#dedede/g" "${THEME_DIR}"/{actions,devices}/32/*
2020-08-02 05:15:16 +00:00
sed -i "s/#363636/#dedede/g" "${THEME_DIR}"/{actions,apps,categories,emblems,devices,mimes,places,status}/symbolic/*
2020-07-22 14:32:28 +00:00
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/links/actions/{16,22,24,32,symbolic} "${THEME_DIR}"/actions
2024-04-08 16:56:16 +00:00
cp -r "${SRC_DIR}"/links/devices/{16,22,24,32,symbolic} "${THEME_DIR}"/devices
2024-02-29 17:24:08 +00:00
cp -r "${SRC_DIR}"/links/places/{16,22,24,scalable,symbolic} "${THEME_DIR}"/places
cp -r "${SRC_DIR}"/links/status/symbolic "${THEME_DIR}"/status
cp -r "${SRC_DIR}"/links/apps/symbolic "${THEME_DIR}"/apps
cp -r "${SRC_DIR}"/links/categories/symbolic "${THEME_DIR}"/categories
cp -r "${SRC_DIR}"/links/mimes/symbolic "${THEME_DIR}"/mimes
2020-07-22 14:32:28 +00:00
cd ${dest}
2021-01-19 08:55:49 +00:00
ln -s ../${name}${theme}/animations ${name}${theme}-dark/animations
2024-04-08 03:23:46 +00:00
ln -s ../${name}${theme}/preferences ${name}${theme}-dark/preferences
2021-01-19 08:55:49 +00:00
ln -s ../../${name}${theme}/categories/32 ${name}${theme}-dark/categories/32
ln -s ../../${name}${theme}/emblems/16 ${name}${theme}-dark/emblems/16
ln -s ../../${name}${theme}/emblems/22 ${name}${theme}-dark/emblems/22
ln -s ../../${name}${theme}/emblems/24 ${name}${theme}-dark/emblems/24
ln -s ../../${name}${theme}/mimes/16 ${name}${theme}-dark/mimes/16
ln -s ../../${name}${theme}/mimes/22 ${name}${theme}-dark/mimes/22
ln -s ../../${name}${theme}/mimes/scalable ${name}${theme}-dark/mimes/scalable
ln -s ../../${name}${theme}/apps/scalable ${name}${theme}-dark/apps/scalable
ln -s ../../${name}${theme}/devices/scalable ${name}${theme}-dark/devices/scalable
2023-07-03 02:48:21 +00:00
ln -s ../../${name}${theme}/status/16 ${name}${theme}-dark/status/16
ln -s ../../${name}${theme}/status/22 ${name}${theme}-dark/status/22
ln -s ../../${name}${theme}/status/24 ${name}${theme}-dark/status/24
2021-01-19 08:55:49 +00:00
ln -s ../../${name}${theme}/status/32 ${name}${theme}-dark/status/32
2020-07-22 14:32:28 +00:00
fi
2021-06-25 04:09:48 +00:00
(
2024-02-29 17:24:08 +00:00
cd "${THEME_DIR}"
2021-06-25 04:10:36 +00:00
ln -sf actions actions@2x
ln -sf animations animations@2x
ln -sf apps apps@2x
ln -sf categories categories@2x
ln -sf devices devices@2x
ln -sf emblems emblems@2x
ln -sf mimes mimes@2x
ln -sf places places@2x
2023-09-11 14:55:27 +00:00
ln -sf preferences preferences@2x
2021-06-25 04:10:36 +00:00
ln -sf status status@2x
2021-06-25 04:09:48 +00:00
)
2020-07-22 14:32:28 +00:00
2024-02-29 17:24:08 +00:00
gtk-update-icon-cache "${THEME_DIR}"
2020-07-22 14:32:28 +00:00
}
2022-12-10 02:04:00 +00:00
uninstall() {
local dest=${1}
local name=${2}
local theme=${3}
local color=${4}
local THEME_DIR=${dest}/${name}${theme}${color}
2024-02-29 17:24:08 +00:00
[[ -d "${THEME_DIR}" ]] && rm -rf "${THEME_DIR}"
2022-12-10 02:04:00 +00:00
2024-02-29 17:24:08 +00:00
echo "Uninstalling '"${THEME_DIR}"'..."
2022-12-10 02:04:00 +00:00
}
2021-06-25 04:09:48 +00:00
while [[ "$#" -gt 0 ]]; do
case "${1:-}" in
2020-07-22 14:32:28 +00:00
-d|--dest)
2021-06-25 04:09:48 +00:00
dest="$2"
mkdir -p "$dest"
2020-07-22 14:32:28 +00:00
shift 2
;;
-n|--name)
name="${2}"
shift 2
;;
2021-06-25 04:09:48 +00:00
-a|--alternative)
alternative='true'
echo "Installing 'alternative' version..."
shift
;;
2021-07-05 00:43:08 +00:00
-b|--bold)
bold='true'
echo "Installing 'bold' version..."
shift
;;
2022-12-10 02:04:00 +00:00
-r|--remove|-u|--uninstall)
remove='true'
shift
;;
2021-01-19 08:55:49 +00:00
-t|--theme)
shift
for theme in "${@}"; do
case "${theme}" in
default)
themes+=("${THEME_VARIANTS[0]}")
shift
;;
purple)
themes+=("${THEME_VARIANTS[1]}")
shift
;;
pink)
themes+=("${THEME_VARIANTS[2]}")
shift
;;
red)
themes+=("${THEME_VARIANTS[3]}")
shift
;;
orange)
themes+=("${THEME_VARIANTS[4]}")
shift
;;
yellow)
themes+=("${THEME_VARIANTS[5]}")
shift
;;
green)
themes+=("${THEME_VARIANTS[6]}")
shift
;;
grey)
themes+=("${THEME_VARIANTS[7]}")
shift
;;
2022-07-05 15:50:46 +00:00
nord)
themes+=("${THEME_VARIANTS[8]}")
shift
;;
2021-01-19 08:55:49 +00:00
all)
themes+=("${THEME_VARIANTS[@]}")
shift
;;
-*|--*)
break
;;
*)
2022-05-11 15:27:40 +00:00
echo "ERROR: Unrecognized theme variant '$1'."
echo "Try '$0 --help' for more information."
2021-01-19 08:55:49 +00:00
exit 1
;;
esac
2021-06-25 04:09:48 +00:00
# echo "Installing '${theme}' folder version..."
2021-01-19 08:55:49 +00:00
done
;;
2020-07-22 14:32:28 +00:00
-h|--help)
usage
exit 0
;;
*)
echo "ERROR: Unrecognized installation option '$1'."
echo "Try '$0 --help' for more information."
exit 1
;;
esac
done
2024-04-18 10:02:35 +00:00
if [[ "${#themes[@]}" -eq 0 ]]; then
2021-06-25 04:09:48 +00:00
themes=("${THEME_VARIANTS[0]}")
fi
2024-04-18 10:02:35 +00:00
if [[ "${#colors[@]}" -eq 0 ]]; then
2021-06-25 04:09:48 +00:00
colors=("${COLOR_VARIANTS[@]}")
fi
2020-07-22 14:32:28 +00:00
install_theme() {
2021-06-25 04:09:48 +00:00
for theme in "${themes[@]}"; do
for color in "${colors[@]}"; do
2021-01-19 08:55:49 +00:00
install "${dest:-${DEST_DIR}}" "${name:-${THEME_NAME}}" "${theme}" "${color}"
done
2020-07-22 14:32:28 +00:00
done
}
2022-12-10 02:04:00 +00:00
uninstall_theme() {
for theme in "${THEME_VARIANTS[@]}"; do
for color in "${COLOR_VARIANTS[@]}"; do
uninstall "${dest:-${DEST_DIR}}" "${name:-${THEME_NAME}}" "${theme}" "${color}"
done
done
}
if [[ "${remove}" == 'true' ]]; then
uninstall_theme
else
install_theme
fi
2023-03-07 06:56:21 +00:00
#exit 0