summaryrefslogtreecommitdiff
path: root/create-icon-theme.sh
blob: 50fcea57a30415dd10c942a7a3619ba7a1b69d85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#! /bin/bash

if [ "x$1" = "x" ]
then
  echo "Usage: $0 [icon theme directory]"
  exit 1
fi

THEME_NAME=`echo "$1" | sed -e 's,/$,,'`
THEME_COMMENT="$THEME_NAME Icon Theme"

OUTPUT=$(echo "output/$1" | sed 's/ //')
OUTPUT=`pwd`/$OUTPUT

rm -rf "$OUTPUT"

mkdir -p "$OUTPUT"

CWD=`pwd`
cd "$1"
cp -r * $OUTPUT
cd $CWD


echo "Creating icon theme in '$OUTPUT'"

echo "Copying build files.."

cp build/* "$OUTPUT"

cd "$OUTPUT"

echo "Creating index.theme"

echo -e "[Icon Theme]\nName=$THEME_NAME\nComment=$THEME_COMMENT\n" > index.theme
echo -n "Directories=" >> index.theme

DIRS=`find * -type d | grep -v git | grep -v scalable | grep "/" | sort -r`

for foo in $DIRS
do
	echo -n "$foo," >> index.theme
done

for foo in $DIRS
do
  size=`echo $foo | sed 's/\x.*//'`
  type="Scalable"
  maxsize="MaxSize=512"
  echo -en "\n\n[$foo]\nSize=$size\nContext=`basename $foo`\nType=$type\n$maxsize" >> index.theme
done


echo "Creating Makefiles"

SIZES=$(find * -maxdepth 0 -type d -not -name 'scalable' -printf '%f ')

MAKEFILES='Makefile\n'
for dir in $SIZES
do
  subdirs=$(find $dir/* -maxdepth 0 -type d -printf '%f ')
  echo "SUBDIRS=$subdirs" > $dir/Makefile.am
  MAKEFILES="$MAKEFILES\n$dir/Makefile"
              for context in $subdirs
              do

                      MAKEFILES="$MAKEFILES\n$dir/$context/Makefile"
                      files=`echo $dir/$context/*.{svg,icon,png}|sed "s/$dir\/$context\///g"| sed 's/\*\.\(icon\|png\|svg\)//g'`
                      echo "themedir = \$(datadir)/icons/$THEME_NAME/$dir/$context" > $dir/$context/Makefile.am
                      echo "theme_DATA = $files" >> $dir/$context/Makefile.am
                      echo "EXTRA_DIST = \$(theme_DATA)" >> $dir/$context/Makefile.am
                      echo "install-data-local: install-themeDATA"  >> $dir/$context/Makefile.am
                      echo "	(cd \"\$(DESTDIR)\$(themedir)\" && \$(ICONMAP) -c $context )" >> $dir/$context/Makefile.am
                      echo "MAINTAINERCLEANFILES = Makefile.in" >> $dir/$context/Makefile.am
              done
done

echo "Updating configure.ac"
M=`echo "$MAKEFILES" | sed 's/\//\\\\\//g'`
sed -i -e "s/MAKEFILES/$M/" configure.ac

echo "Updating Makefile.am"
sed -i -e "s/REAL_SUB_DIRS/$SIZES/" Makefile.am
sed -i -e "s/THEME_NAME/$THEME_NAME/" Makefile.am

echo "Done"