1#!/usr/local/bin/bash 2 3ROOT_UID=0 4DEST_DIR= 5 6# Destination directory 7if [ "$UID" -eq "$ROOT_UID" ]; then 8 DEST_DIR="/usr/share/icons" 9else 10 DEST_DIR="$HOME/.local/share/icons" 11fi 12 13SRC_DIR=$(cd "$(dirname "${0}")" && pwd) 14 15THEME_NAME=Qogir 16THEME_VARIANTS=('' '-ubuntu' '-manjaro') 17COLOR_VARIANTS=('' '-dark') 18 19usage() { 20 printf "%s\n" "Usage: $0 [OPTIONS...]" 21 printf "\n%s\n" "OPTIONS:" 22 printf " %-25s%s\n" "-d, --dest DIR" "Specify theme destination directory (Default: ${DEST_DIR})" 23 printf " %-25s%s\n" "-n, --name NAME" "Specify theme name (Default: ${THEME_NAME})" 24 printf " %-25s%s\n" "-h, --help" "Show this help" 25} 26 27install() { 28 local dest=${1} 29 local name=${2} 30 local theme=${3} 31 local color=${4} 32 33 local THEME_DIR=${dest}/${name}${theme}${color} 34 35 [[ -d ${THEME_DIR} ]] && rm -rf "${THEME_DIR}" 36 37 echo "Installing '${THEME_DIR}'..." 38 39 mkdir -p "${THEME_DIR}" 40 cp -R "${SRC_DIR}/COPYING" "${THEME_DIR}" 41 cp -R "${SRC_DIR}/AUTHORS" "${THEME_DIR}" 42 43 if [[ "${noapp:-}" == 'true' ]]; then 44 cp -R "${SRC_DIR}/src/index-noapp.theme" "${THEME_DIR}/index.theme" 45 else 46 cp -R "${SRC_DIR}/src/index.theme" "${THEME_DIR}" 47 fi 48 49 cp -R "${SRC_DIR}/src/cursors/dist${theme}${color}/cursors" "${THEME_DIR}" 50 51 cd "${THEME_DIR}" || exit 1 52 gsed -i "s/${name}/${name}${theme}${color}/g" index.theme 53 54 if [[ ${color} == '' ]]; then 55 cp -R "${SRC_DIR}"/src/{16,22,24,32,48,96,128,scalable,symbolic} "${THEME_DIR}" 56 cp -R "${SRC_DIR}"/links/{16,22,24,32,48,96,128,scalable,symbolic} "${THEME_DIR}" 57 [[ ${theme} != '' ]] && \ 58 cp -R "${SRC_DIR}"/src/theme"${theme}"/* "${THEME_DIR}" 59 else 60 mkdir -p "${THEME_DIR}/16" 61 mkdir -p "${THEME_DIR}/22" 62 mkdir -p "${THEME_DIR}/24" 63 mkdir -p "${THEME_DIR}/32" 64 cp -R "${SRC_DIR}"/src/16/{actions,places,devices} "${THEME_DIR}/16" 65 cp -R "${SRC_DIR}"/src/22/{actions,places,devices} "${THEME_DIR}/22" 66 cp -R "${SRC_DIR}"/src/24/{actions,places,devices} "${THEME_DIR}/24" 67 cp -R "${SRC_DIR}"/src/32/actions "${THEME_DIR}/32" 68 69 gsed -i "s/#5d656b/#d3dae3/g" "${THEME_DIR}"/{16,22,24,32}/actions/* 70 gsed -i "s/#5d656b/#d3dae3/g" "${THEME_DIR}"/{16,22,24}/places/* 71 gsed -i "s/#5d656b/#d3dae3/g" "${THEME_DIR}"/{16,22,24}/devices/* 72 73 cp -R "${SRC_DIR}"/links/16/{actions,places,devices} "${THEME_DIR}/16" 74 cp -R "${SRC_DIR}"/links/22/{actions,places,devices} "${THEME_DIR}/22" 75 cp -R "${SRC_DIR}"/links/24/{actions,places,devices} "${THEME_DIR}/24" 76 cp -R "${SRC_DIR}"/links/32/actions "${THEME_DIR}/32" 77 78 cd "${dest}" || exit 1 79 ln -sf "../${name}${theme}/scalable" "${name}${theme}-dark/scalable" 80 ln -sf "../${name}${theme}/symbolic" "${name}${theme}-dark/symbolic" 81 ln -sf "../${name}${theme}/48" "${name}${theme}-dark/48" 82 ln -sf "../${name}${theme}/96" "${name}${theme}-dark/96" 83 ln -sf "../${name}${theme}/128" "${name}${theme}-dark/128" 84 ln -sf "../../${name}${theme}/16/apps" "${name}${theme}-dark/16/apps" 85 ln -sf "../../${name}${theme}/16/emblems" "${name}${theme}-dark/16/emblems" 86 ln -sf "../../${name}${theme}/16/mimetypes" "${name}${theme}-dark/16/mimetypes" 87 ln -sf "../../${name}${theme}/16/panel" "${name}${theme}-dark/16/panel" 88 ln -sf "../../${name}${theme}/16/status" "${name}${theme}-dark/16/status" 89 ln -sf "../../${name}${theme}/22/emblems" "${name}${theme}-dark/22/emblems" 90 ln -sf "../../${name}${theme}/22/mimetypes" "${name}${theme}-dark/22/mimetypes" 91 ln -sf "../../${name}${theme}/22/panel" "${name}${theme}-dark/22/panel" 92 ln -sf "../../${name}${theme}/24/animations" "${name}${theme}-dark/24/animations" 93 ln -sf "../../${name}${theme}/24/panel" "${name}${theme}-dark/24/panel" 94 ln -sf "../../${name}${theme}/32/apps" "${name}${theme}-dark/32/apps" 95 ln -sf "../../${name}${theme}/32/devices" "${name}${theme}-dark/32/devices" 96 ln -sf "../../${name}${theme}/32/places" "${name}${theme}-dark/32/places" 97 ln -sf "../../${name}${theme}/32/status" "${name}${theme}-dark/32/status" 98 fi 99 100 cd "${THEME_DIR}" || exit 101 ln -sf 16 16@2x 102 ln -sf 22 22@2x 103 ln -sf 24 24@2x 104 ln -sf 32 32@2x 105 ln -sf 48 48@2x 106 ln -sf 96 96@2x 107 ln -sf 128 128@2x 108 ln -sf scalable scalable@2x 109 110 if [[ "${noapp:-}" == 'true' ]]; then 111 rm -rf "${THEME_DIR}/16/apps" 112 rm -rf "${THEME_DIR}/32/apps" 113 rm -rf "${THEME_DIR}/32/devices" 114 rm -rf "${THEME_DIR}/48/apps" 115 rm -rf "${THEME_DIR}/scalable/apps" 116 rm -rf "${THEME_DIR}/scalable/devices" 117 rm -rf "${THEME_DIR}/symbolic/apps" 118 fi 119 120 cd "${dest}" || exit 121 gtk-update-icon-cache "${name}${theme}${color}" 122} 123 124while [[ $# -gt 0 ]]; do 125 case "${1}" in 126 -d|--dest) 127 dest="${2}" 128 if [[ ! -d "${dest}" ]]; then 129 echo "ERROR: Destination directory does not exist." 130 exit 1 131 fi 132 shift 2 133 ;; 134 -n|--name) 135 name="${2}" 136 shift 2 137 ;; 138 --noapp) 139 noapp='true' 140 echo "INFO: Use system app icons." 141 shift 142 ;; 143 -h|--help) 144 usage 145 exit 0 146 ;; 147 *) 148 echo "ERROR: Unrecognized installation option '$1'." 149 echo "Try '$0 --help' for more information." 150 exit 1 151 ;; 152 esac 153done 154 155for theme in "${themes[@]:-${THEME_VARIANTS[@]}}"; do 156 for color in "${colors[@]:-${COLOR_VARIANTS[@]}}"; do 157 install "${dest:-${DEST_DIR}}" "${name:-${THEME_NAME}}" "${theme}" "${color}" 158 done 159done 160