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/themes" 9else 10 DEST_DIR="$HOME/.themes" 11fi 12 13SRC_DIR=$(cd $(dirname $0) && pwd) 14 15THEME_NAME=Layan 16COLOR_VARIANTS=('' '-light' '-dark') 17SOLID_VARIANTS=('' '-solid') 18 19if [[ "$(command -v gnome-shell)" ]]; then 20 SHELL_VERSION="$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -1)" 21 if [[ "${SHELL_VERSION:-}" -ge "40" ]]; then 22 GS_VERSION="new" 23 else 24 GS_VERSION="old" 25 fi 26 else 27 echo "'gnome-shell' not found, using styles for last gnome-shell version available." 28 GS_VERSION="new" 29fi 30 31usage() { 32 printf "%s\n" "Usage: $0 [OPTIONS...]" 33 printf "\n%s\n" "OPTIONS:" 34 printf " %-25s%s\n" "-d, --dest DIR" "Specify theme destination directory (Default: ${DEST_DIR})" 35 printf " %-25s%s\n" "-n, --name NAME" "Specify theme name (Default: ${THEME_NAME})" 36 printf " %-25s%s\n" "-c, --color VARIANTS" "Specify theme color variant(s) [standard|light|dark] (Default: All variants)" 37 printf " %-25s%s\n" "-s, --solid VARIANTS" "Specify theme solid variant(s) [standard|solid] (Default: All variants)" 38 printf " %-25s%s\n" "-h, --help" "Show this help" 39} 40 41install() { 42 local dest=${1} 43 local name=${2} 44 local color=${3} 45 local solid=${4} 46 47 [[ ${color} == '-dark' ]] && local ELSE_DARK=${color} 48 [[ ${color} == '-light' ]] && local ELSE_LIGHT=${color} 49 50 local THEME_DIR=${dest}/${name}${color}${solid} 51 52 [[ -d ${THEME_DIR} ]] && rm -rf ${THEME_DIR} 53 54 echo "Installing '${THEME_DIR}'..." 55 56 mkdir -p ${THEME_DIR} 57 cp -pr ${SRC_DIR}/COPYING ${THEME_DIR} 58 cp -pr ${SRC_DIR}/AUTHORS ${THEME_DIR} 59 60 echo "[Desktop Entry]" >> ${THEME_DIR}/index.theme 61 echo "Type=X-GNOME-Metatheme" >> ${THEME_DIR}/index.theme 62 echo "Name=${name}${color}${solid}" >> ${THEME_DIR}/index.theme 63 echo "Comment=An Flat Gtk+ theme based on Material Design" >> ${THEME_DIR}/index.theme 64 echo "Encoding=UTF-8" >> ${THEME_DIR}/index.theme 65 echo "" >> ${THEME_DIR}/index.theme 66 echo "[X-GNOME-Metatheme]" >> ${THEME_DIR}/index.theme 67 echo "GtkTheme=${name}${color}${solid}" >> ${THEME_DIR}/index.theme 68 echo "MetacityTheme=${name}${color}${solid}" >> ${THEME_DIR}/index.theme 69 echo "IconTheme=Tela${ELSE_DARK}" >> ${THEME_DIR}/index.theme 70 echo "CursorTheme=Adwaita" >> ${THEME_DIR}/index.theme 71 echo "ButtonLayout=menu:minimize,maximize,close" >> ${THEME_DIR}/index.theme 72 73 mkdir -p ${THEME_DIR}/gnome-shell 74 cp -pr ${SRC_DIR}/src/gnome-shell/{*.svg,noise-texture.png,pad-osd.css} ${THEME_DIR}/gnome-shell 75 cp -pr ${SRC_DIR}/src/gnome-shell/gnome-shell-theme.gresource.xml ${THEME_DIR}/gnome-shell 76 cp -pr ${SRC_DIR}/src/gnome-shell/assets${ELSE_DARK} ${THEME_DIR}/gnome-shell/assets 77 cp -pr ${SRC_DIR}/src/gnome-shell/common-assets/*.svg ${THEME_DIR}/gnome-shell/assets 78 79 if [[ "${GS_VERSION:-}" == 'new' ]]; then 80 cp -pr ${SRC_DIR}/src/gnome-shell/shell-40-0/gnome-shell${ELSE_DARK}.css ${THEME_DIR}/gnome-shell/gnome-shell.css 81 else 82 cp -pr ${SRC_DIR}/src/gnome-shell/shell-3-36/gnome-shell${ELSE_DARK}.css ${THEME_DIR}/gnome-shell/gnome-shell.css 83 fi 84 85 mkdir -p ${THEME_DIR}/gtk-2.0 86 cp -pr ${SRC_DIR}/src/gtk-2.0/{apps.rc,hacks.rc,main.rc,panel.rc} ${THEME_DIR}/gtk-2.0 87 cp -pr ${SRC_DIR}/src/gtk-2.0/assets${ELSE_DARK} ${THEME_DIR}/gtk-2.0/assets 88 cp -pr ${SRC_DIR}/src/gtk-2.0/gtkrc${color} ${THEME_DIR}/gtk-2.0/gtkrc 89 90 cp -pr ${SRC_DIR}/src/gtk/assets ${THEME_DIR}/gtk-assets 91 92 mkdir -p ${THEME_DIR}/gtk-3.0 93 ln -sf ../gtk-assets ${THEME_DIR}/gtk-3.0/assets 94 cp -pr ${SRC_DIR}/src/gtk/3.0/gtk${color}${solid}.css ${THEME_DIR}/gtk-3.0/gtk.css 95 [[ ${color} != '-dark' ]] && \ 96 cp -pr ${SRC_DIR}/src/gtk/3.0/gtk-dark${solid}.css ${THEME_DIR}/gtk-3.0/gtk-dark.css 97 98 mkdir -p ${THEME_DIR}/gtk-4.0 99 ln -sf ../gtk-assets ${THEME_DIR}/gtk-4.0/assets 100 cp -pr ${SRC_DIR}/src/gtk/4.0/gtk${color}${solid}.css ${THEME_DIR}/gtk-4.0/gtk.css 101 [[ ${color} != '-dark' ]] && \ 102 cp -pr ${SRC_DIR}/src/gtk/4.0/gtk-dark${solid}.css ${THEME_DIR}/gtk-4.0/gtk-dark.css 103 104 mkdir -p ${THEME_DIR}/xfwm4 105 cp -pr ${SRC_DIR}/src/xfwm4/assets${ELSE_LIGHT}/*.png ${THEME_DIR}/xfwm4 106 cp -pr ${SRC_DIR}/src/xfwm4/themerc${ELSE_LIGHT} ${THEME_DIR}/xfwm4/themerc 107 108 cp -pr ${SRC_DIR}/src/plank ${THEME_DIR} 109} 110 111while [[ $# -gt 0 ]]; do 112 case "${1}" in 113 -d|--dest) 114 dest="${2}" 115 if [[ ! -d "${dest}" ]]; then 116 echo "ERROR: Destination directory does not exist." 117 exit 1 118 fi 119 shift 2 120 ;; 121 -n|--name) 122 name="${2}" 123 shift 2 124 ;; 125 -c|--color) 126 shift 127 for color in "${@}"; do 128 case "${color}" in 129 standard) 130 colors+=("${COLOR_VARIANTS[0]}") 131 shift 132 ;; 133 light) 134 colors+=("${COLOR_VARIANTS[1]}") 135 shift 136 ;; 137 dark) 138 colors+=("${COLOR_VARIANTS[2]}") 139 shift 140 ;; 141 -*|--*) 142 break 143 ;; 144 *) 145 echo "ERROR: Unrecognized color variant '$1'." 146 echo "Try '$0 --help' for more information." 147 exit 1 148 ;; 149 esac 150 done 151 ;; 152 -s|--solid) 153 shift 154 for solid in "${@}"; do 155 case "${solid}" in 156 standard) 157 colors+=("${SOLID_VARIANTS[0]}") 158 shift 159 ;; 160 solid) 161 colors+=("${SOLID_VARIANTS[1]}") 162 shift 163 ;; 164 -*|--*) 165 break 166 ;; 167 *) 168 echo "ERROR: Unrecognized color variant '$1'." 169 echo "Try '$0 --help' for more information." 170 exit 1 171 ;; 172 esac 173 done 174 ;; 175 -h|--help) 176 usage 177 exit 0 178 ;; 179 *) 180 echo "ERROR: Unrecognized installation option '$1'." 181 echo "Try '$0 --help' for more information." 182 exit 1 183 ;; 184 esac 185done 186 187for color in "${colors[@]:-${COLOR_VARIANTS[@]}}"; do 188 for solid in "${solids[@]:-${SOLID_VARIANTS[@]}}"; do 189 install "${dest:-${DEST_DIR}}" "${name:-${THEME_NAME}}" "${color}" "${solid}" 190 done 191done 192 193echo 194echo Done. 195