aboutsummaryrefslogtreecommitdiff
path: root/pixmaps/icons/icon-theme-installer
diff options
context:
space:
mode:
Diffstat (limited to 'pixmaps/icons/icon-theme-installer')
-rwxr-xr-xpixmaps/icons/icon-theme-installer196
1 files changed, 196 insertions, 0 deletions
diff --git a/pixmaps/icons/icon-theme-installer b/pixmaps/icons/icon-theme-installer
new file mode 100755
index 00000000..b1c93f59
--- /dev/null
+++ b/pixmaps/icons/icon-theme-installer
@@ -0,0 +1,196 @@
1#!/bin/bash
2
3# icon-theme-installer
4# Copyright (C) 2006 Novell, Inc.
5# Written by Aaron Bockover <abock@gnome.org>
6# Licensed under the MIT/X11 license
7#
8# This script is meant to be invoked from within a Makefile/Makefile.am
9# in the install-data-local and uninstall-data sections. It handles the
10# task of properly installing icons into the icon theme. It requires a
11# few arguments to set up its environment, and a list of files to be
12# installed. The format of the file list is critical:
13#
14# <category>,<local-src-file-name>
15#
16# apps,music-player-banshee.svg
17# apps,music-player-banshee-16.png
18# apps,music-player-banshee-22.png
19#
20# <category> is the icon theme category, for instance, apps, devices,
21# actions, emblems...
22#
23# <local-src-file-name> must have a basename in the form of:
24#
25# proper-theme-name[-<SIZE>].<EXTENSION>
26#
27# Where <SIZE> should be either nothing, which will default to scalable
28# or \-[0-9]{2}, which will expand to <SIZE>x<SIZE>. For example:
29#
30# music-player-banshee-16.png
31#
32# The <SIZE> here is -16 and will expand to 16x16 per the icon theme
33spec
34#
35# What follows is an example Makefile.am for icon theme installation:
36#
37# ---------------
38# theme=hicolor
39# themedir=$(datadir)/icons/$(theme)
40# theme_icons = \
41# apps,music-player-banshee.svg \
42# apps,music-player-banshee-16.png \
43# apps,music-player-banshee-22.png \
44# apps,music-player-banshee-24.png \
45# apps,music-player-banshee-32.png
46#
47# install_icon_exec = $(top_srcdir)/build/icon-theme-installer -t
48$(theme) -s $(srcdir) -d "x$(DESTDIR)" -b $(themedir) -m
49"$(mkinstalldirs)" -x "$(INSTALL_DATA)"
50# install-data-local:
51# $(install_icon_exec) -i $(theme_icons)
52#
53# uninstall-hook:
54# $(install_icon_exec) -u $(theme_icons)
55#
56# MAINTAINERCLEANFILES = Makefile.in
57# EXTRA_DIST = $(wildcard *.svg *.png)
58# ---------------
59#
60# Arguments to this program:
61#
62# -i : Install
63# -u : Uninstall
64# -t <theme> : Theme name (hicolor)
65# -b <dir> : Theme installation dest directory [x$(DESTDIR)] - Always
66prefix
67# this argument with x; it will be stripped but will act as
68a
69# placeholder for zero $DESTDIRs (only set by packagers)
70# -d <dir> : Theme installation directory [$(hicolordir)]
71# -s <dir> : Source directory [$(srcdir)]
72# -m <exec> : Command to exec for directory creation [$(mkinstalldirs)]
73# -x <exec> : Command to exec for single file installation
74[$(INSTALL_DATA)]
75# <remainging> : All remainging should be category,filename pairs
76
77while getopts "iut:b:d:s:m:x:" flag; do
78 case "$flag" in
79 i) INSTALL=yes ;;
80 u) UNINSTALL=yes ;;
81 t) THEME_NAME=$OPTARG ;;
82 d) INSTALL_DEST_DIR=${OPTARG##x} ;;
83 b) INSTALL_BASE_DIR=$OPTARG ;;
84 s) SRC_DIR=$OPTARG ;;
85 m) MKINSTALLDIRS_EXEC=$OPTARG ;;
86 x) INSTALL_DATA_EXEC=$OPTARG ;;
87 esac
88done
89
90shift $(($OPTIND - 1))
91
92if test "x$INSTALL" = "xyes" -a "x$UNINSTALL" = "xyes"; then
93 echo "Cannot pass both -i and -u"
94 exit 1
95elif test "x$INSTALL" = "x" -a "x$UNINSTALL" = "x"; then
96 echo "Must path either -i or -u"
97 exit 1
98fi
99
100if test -z "$THEME_NAME"; then
101 echo "Theme name required (-t hicolor)"
102 exit 1
103fi
104
105if test -z "$INSTALL_BASE_DIR"; then
106 echo "Base theme directory required [-d \$(hicolordir)]"
107 exit 1
108fi
109
110if test ! -x $(echo "$MKINSTALLDIRS_EXEC" | cut -f1 -d' '); then
111 echo "Cannot find '$MKINSTALLDIRS_EXEC'; You probably want to
112pass -m \$(mkinstalldirs)"
113 exit 1
114fi
115
116if test ! -x $(echo "$INSTALL_DATA_EXEC" | cut -f1 -d' '); then
117 echo "Cannot find '$INSTALL_DATA_EXEC'; You probably want to
118pass -x \$(INSTALL_DATA)"
119 exit 1
120fi
121
122if test -z "$SRC_DIR"; then
123 SRC_DIR=.
124fi
125
126for icon in $@; do
127 size=$(echo $icon | sed s/[^0-9]*//g)
128 category=$(echo $icon | cut -d, -f1)
129 build_name=$(echo $icon | cut -d, -f2)
130 install_name=$(echo $build_name | sed "s/[0-9]//g; s/-\././")
131 install_name=$(basename $install_name)
132
133 if test -z $size; then
134 size=scalable;
135 else
136 size=${size}x${size};
137 fi
138
139
140install_dir=${INSTALL_DEST_DIR}${INSTALL_BASE_DIR}/$size/$category
141 install_path=$install_dir/$install_name
142
143 if test "x$INSTALL" = "xyes"; then
144 echo "Installing $size $install_name into $THEME_NAME
145icon theme"
146
147 $($MKINSTALLDIRS_EXEC $install_dir) || {
148 echo "Failed to create directory $install_dir"
149 exit 1
150 }
151
152 $($INSTALL_DATA_EXEC $SRC_DIR/$build_name $install_path)
153|| {
154 echo "Failed to install $SRC_DIR/$build_name
155into $install_path"
156 exit 1
157 }
158
159 if test ! -e $install_path; then
160 echo "Failed to install $SRC_DIR/$build_name
161into $install_path"
162 exit 1
163 fi
164 else
165 if test -e $install_path; then
166 echo "Removing $size $install_name from
167$THEME_NAME icon theme"
168
169 rm $install_path || {
170 echo "Failed to remove $install_path"
171 exit 1
172 }
173 fi
174 fi
175done
176
177if test "x$INSTALL" = "xyes"; then
178 gtk_update_icon_cache_bin="$((which gtk-update-icon-cache ||
179echo /opt/gnome/bin/gtk-update-icon-cache)2>/dev/null)"
180 gtk_update_icon_cache="$gtk_update_icon_cache_bin -f -t
181$INSTALL_BASE_DIR"
182
183 if test -z "$INSTALL_DEST_DIR"; then
184 if test -x $gtk_update_icon_cache_bin; then
185 echo "Updating GTK icon cache"
186 $gtk_update_icon_cache
187 else
188 echo "*** Icon cache not updated. Could not
189execute $gtk_update_icon_cache_bin"
190 fi
191 else
192 echo "*** Icon cache not updated. After install, run
193this:"
194 echo "*** $gtk_update_icon_cache"
195 fi
196fi