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

208 lines
7.6 KiB
Bash
Raw Normal View History

2021-01-19 08:55:49 +00:00
#! /usr/bin/env bash
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
SRC_DIR=$(cd $(dirname $0) && pwd)
THEME_NAME=WhiteSur
COLOR_VARIANTS=('' '-dark')
2021-01-19 08:55:49 +00:00
THEME_VARIANTS=('' '-purple' '-pink' '-red' '-orange' '-yellow' '-green' '-grey')
2020-07-22 14:32:28 +00:00
usage() {
printf "%s\n" "Usage: $0 [OPTIONS...]"
printf "\n%s\n" "OPTIONS:"
printf " %-25s%s\n" "-d, --dest DIR" "Specify theme destination directory (Default: ${DEST_DIR})"
printf " %-25s%s\n" "-n, --name NAME" "Specify theme name (Default: ${THEME_NAME})"
2021-01-19 08:55:49 +00:00
printf " %-25s%s\n" "-t, --theme VARIANTS" "Specify folder color [default|purple|pink|red|orange|yellow|green|grey|all] (Default: MacOS blue)"
2020-07-22 14:32:28 +00:00
printf " %-25s%s\n" "-h, --help" "Show this help"
}
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
[[ -d ${THEME_DIR} ]] && rm -rf ${THEME_DIR}
echo "Installing '${THEME_DIR}'..."
mkdir -p ${THEME_DIR}
cp -r ${SRC_DIR}/{COPYING,AUTHORS} ${THEME_DIR}
cp -r ${SRC_DIR}/src/index.theme ${THEME_DIR}
cd ${THEME_DIR}
2021-01-19 08:55:49 +00:00
sed -i "s/${name}/${name}${theme}${color}/g" index.theme
2020-07-22 14:32:28 +00:00
if [[ ${color} == '' ]]; then
mkdir -p ${THEME_DIR}/status
cp -r ${SRC_DIR}/src/{actions,animations,apps,categories,devices,emblems,mimes,places} ${THEME_DIR}
cp -r ${SRC_DIR}/src/status/{16,22,24,32,symbolic} ${THEME_DIR}/status
2020-12-17 07:36:46 +00:00
cp -r ${SRC_DIR}/links/{actions,apps,categories,devices,emblems,mimes,places,status} ${THEME_DIR}
2020-08-16 07:28:44 +00:00
if [[ $DESKTOP_SESSION == '/usr/share/xsessions/budgie-desktop' ]]; then
cp -r ${SRC_DIR}/src/status/symbolic-budgie/*.svg ${THEME_DIR}/status/symbolic
fi
2020-07-22 14:32:28 +00:00
fi
2021-01-19 08:55:49 +00:00
if [[ ${color} == '' && ${theme} != '' ]]; then
cp -r ${SRC_DIR}/colors/color${theme}/*.svg ${THEME_DIR}/places/scalable
fi
2020-07-22 14:32:28 +00:00
if [[ ${color} == '-dark' ]]; then
mkdir -p ${THEME_DIR}/{apps,categories,emblems,devices,mimes,places,status}
cp -r ${SRC_DIR}/src/actions ${THEME_DIR}
cp -r ${SRC_DIR}/src/apps/symbolic ${THEME_DIR}/apps
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
cp -r ${SRC_DIR}/src/devices/{16,22,24,symbolic} ${THEME_DIR}/devices
cp -r ${SRC_DIR}/src/places/{16,22,24,symbolic} ${THEME_DIR}/places
cp -r ${SRC_DIR}/src/status/{16,22,24,symbolic} ${THEME_DIR}/status
2020-08-16 07:28:44 +00:00
if [[ $DESKTOP_SESSION == '/usr/share/xsessions/budgie-desktop' ]]; then
cp -r ${SRC_DIR}/src/status/symbolic-budgie/*.svg ${THEME_DIR}/status/symbolic
fi
2020-07-22 14:32:28 +00:00
# Change icon color for dark theme
2020-08-17 12:22:13 +00:00
sed -i "s/#363636/#dedede/g" "${THEME_DIR}"/{actions,devices,places,status}/{16,22,24}/*
2020-08-02 05:15:16 +00:00
sed -i "s/#363636/#dedede/g" "${THEME_DIR}"/actions/32/*
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
2020-08-02 05:15:16 +00:00
cp -r ${SRC_DIR}/links/actions/{16,22,24,32,symbolic} ${THEME_DIR}/actions
2020-07-22 14:32:28 +00:00
cp -r ${SRC_DIR}/links/devices/{16,22,24,symbolic} ${THEME_DIR}/devices
cp -r ${SRC_DIR}/links/places/{16,22,24,symbolic} ${THEME_DIR}/places
cp -r ${SRC_DIR}/links/status/{16,22,24,symbolic} ${THEME_DIR}/status
cp -r ${SRC_DIR}/links/apps/symbolic ${THEME_DIR}/apps
2020-12-17 07:36:46 +00:00
cp -r ${SRC_DIR}/links/categories/symbolic ${THEME_DIR}/categories
2020-07-22 14:32:28 +00:00
cp -r ${SRC_DIR}/links/mimes/symbolic ${THEME_DIR}/mimes
cd ${dest}
2021-01-19 08:55:49 +00:00
ln -s ../${name}${theme}/animations ${name}${theme}-dark/animations
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
ln -s ../../${name}${theme}/places/scalable ${name}${theme}-dark/places/scalable
ln -s ../../${name}${theme}/status/32 ${name}${theme}-dark/status/32
2020-07-22 14:32:28 +00:00
fi
cd ${THEME_DIR}
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
ln -sf status status@2x
cd ${dest}
2021-01-19 08:55:49 +00:00
gtk-update-icon-cache ${name}${theme}${color}
2020-07-22 14:32:28 +00:00
}
while [[ $# -gt 0 ]]; do
case "${1}" in
-d|--dest)
dest="${2}"
if [[ ! -d "${dest}" ]]; then
echo "ERROR: Destination directory does not exist."
exit 1
fi
shift 2
;;
-n|--name)
name="${2}"
shift 2
;;
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
;;
all)
themes+=("${THEME_VARIANTS[@]}")
shift
;;
-*|--*)
break
;;
*)
prompt -e "ERROR: Unrecognized theme variant '$1'."
prompt -i "Try '$0 --help' for more information."
exit 1
;;
esac
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
shift
done
install_theme() {
2021-01-19 08:55:49 +00:00
for theme in "${themes[@]-${THEME_VARIANTS[0]}}"; do
for color in "${colors[@]-${COLOR_VARIANTS[@]}}"; do
install "${dest:-${DEST_DIR}}" "${name:-${THEME_NAME}}" "${theme}" "${color}"
done
2020-07-22 14:32:28 +00:00
done
}
install_theme