| 1 |
#! /bin/bash |
| 2 |
# |
| 3 |
# install-all |
| 4 |
# Part of ComixCursors, a desktop cursor theme. |
| 5 |
# |
| 6 |
# Copyright © 2010–2013 Ben Finney <[email protected]> |
| 7 |
# Copyright © 2006–2013 Jens Luetkens <[email protected]> |
| 8 |
# |
| 9 |
# This work is free software: you can redistribute it and/or modify it |
| 10 |
# under the terms of the GNU General Public License as published by |
| 11 |
# the Free Software Foundation, either version 3 of the License, or |
| 12 |
# (at your option) any later version. |
| 13 |
# |
| 14 |
# This work is distributed in the hope that it will be useful, but |
| 15 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
# General Public License for more details. |
| 18 |
# |
| 19 |
# You should have received a copy of the GNU General Public License |
| 20 |
# along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 21 |
|
| 22 |
# Build and install all the ComixCursors themes. |
| 23 |
|
| 24 |
themename_stem="ComixCursors" |
| 25 |
configfile_dir="${themename_stem}Configs" |
| 26 |
configfile_template_name="Custom" |
| 27 |
|
| 28 |
bindir="$(dirname $0)/bin" |
| 29 |
|
| 30 |
# We want to use cursors with multiple sizes combined. |
| 31 |
# The script check wether MULTISIZE is exported at all, so don't export |
| 32 |
# MULTISIZE if you want distinct cursor sizes, comment it out here or |
| 33 |
# unset it from the shell. |
| 34 |
export MULTISIZE=true |
| 35 |
|
| 36 |
# argument processing and usage |
| 37 |
function show_usage_message { |
| 38 |
cat <<_EOT_ |
| 39 |
Usage: $0 [option] |
| 40 |
|
| 41 |
Install the ComixCursors mouse theme. |
| 42 |
|
| 43 |
Options: |
| 44 |
-h: Display this help text, then exit. |
| 45 |
-u: Uninstall the ComixCursors mouse theme. |
| 46 |
-v: Be verbose. |
| 47 |
|
| 48 |
_EOT_ |
| 49 |
} |
| 50 |
|
| 51 |
while getopts ":uhv" opt; do |
| 52 |
case $opt in |
| 53 |
h) |
| 54 |
show_usage_message |
| 55 |
exit |
| 56 |
;; |
| 57 |
u) |
| 58 |
UNINSTALL=true |
| 59 |
;; |
| 60 |
v) |
| 61 |
export VERBOSE=true |
| 62 |
;; |
| 63 |
*) |
| 64 |
printf "Unexpected option: -%s\n" "$OPTARG" >&2 |
| 65 |
show_usage_message |
| 66 |
exit 2 |
| 67 |
;; |
| 68 |
esac |
| 69 |
done |
| 70 |
|
| 71 |
function build_theme { |
| 72 |
# Build the cursors for a particular theme. |
| 73 |
THEMENAME="$1" |
| 74 |
export THEMENAME |
| 75 |
|
| 76 |
THEMEVARIANT="${THEMENAME}${THEMEOPTIONS}${THEMEINCLUDE}" |
| 77 |
export THEMEVARIANT |
| 78 |
|
| 79 |
if [ $UNINSTALL ]; then |
| 80 |
make uninstall |
| 81 |
else |
| 82 |
if [ ${MULTISIZE} ] ; then |
| 83 |
printf "\nBuilding \"%s\" (multisize)\n" "${THEMEVARIANT}" |
| 84 |
"${bindir}"/build-cursors |
| 85 |
if [ $VERBOSE ] ; then |
| 86 |
make |
| 87 |
make install |
| 88 |
else |
| 89 |
make -s |
| 90 |
make -s install |
| 91 |
fi |
| 92 |
else |
| 93 |
# build one theme for each configured size |
| 94 |
configfile="${configfile_dir}/${THEMENAME}.CONFIG" |
| 95 |
source "${configfile}" |
| 96 |
for SIZENAMES in ${SIZES[@]} ; do |
| 97 |
export SIZENAME="-${SIZENAMES%%=*}" |
| 98 |
export CURSORSIZE=${SIZENAMES##*=} |
| 99 |
printf "\nBuilding \"%s%s\"\n" "${THEMEVARIANT}" "${SIZENAME}" |
| 100 |
"${bindir}"/build-cursors |
| 101 |
if [ $VERBOSE ] ; then |
| 102 |
make |
| 103 |
make install |
| 104 |
else |
| 105 |
make -s |
| 106 |
make -s install |
| 107 |
fi |
| 108 |
done |
| 109 |
fi |
| 110 |
fi |
| 111 |
} |
| 112 |
|
| 113 |
function build_include_theme { |
| 114 |
themename="$1" |
| 115 |
|
| 116 |
# build the right-handed version |
| 117 |
export ORIENTATION="RightHanded" |
| 118 |
export THEMEOPTIONS="" |
| 119 |
build_theme "$themename" |
| 120 |
|
| 121 |
# also build the left-handed version |
| 122 |
export ORIENTATION="LeftHanded" |
| 123 |
export THEMEOPTIONS="-LH" |
| 124 |
build_theme "$themename" |
| 125 |
} |
| 126 |
|
| 127 |
for configfile in "${configfile_dir}"/*.CONFIG ; do |
| 128 |
# Each config file represents a theme to be built. |
| 129 |
configfile_name=$(basename "$configfile") |
| 130 |
themename="${configfile_name%.CONFIG}" |
| 131 |
if [ "$themename" == "$configfile_template_name" ]; then |
| 132 |
# The template isn't a theme we want to build. |
| 133 |
continue |
| 134 |
fi |
| 135 |
|
| 136 |
unset THEMEINCLUDE |
| 137 |
build_include_theme "$themename" |
| 138 |
|
| 139 |
for includefile in "${configfile_dir}"/*.INCLUDE ; do |
| 140 |
includefile_name=$(basename "$includefile") |
| 141 |
export THEMEINCLUDE="-${includefile_name%.INCLUDE}" |
| 142 |
build_include_theme "$themename" |
| 143 |
done |
| 144 |
done |
| 145 |
|
| 146 |
exit 0 |