1#!/usr/local/bin/bash
2#
3# This file is part of plata-theme
4#
5# Copyright (C) 2018-2020 Tista <tista.gma500@gmail.com>
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13SRC_DIR="../assets-metacity"
14ASSETS_DIR="../../metacity-1"
15INDEX_C="assets-metacity-common.txt"
16INDEX="assets-metacity.txt"
17RECOLOR_FILE1=$SRC_DIR/"common/button_close_pressed.svg"
18RECOLOR_FILE2=$SRC_DIR/"common/button_close_prelight.svg"
19RECOLOR_FILE3=$SRC_DIR/"common-compact/button_close_pressed.svg"
20RECOLOR_FILE4=$SRC_DIR/"common-compact/button_close_prelight.svg"
21COL_FILE="../../../gtk/sass/common/_colors.scss"
22KEY_FILE="../../../gtk/sass/common/resources/_key_colors.scss"
23
24# Default colours
25selection1="`grep 'Indigo500' $COL_FILE | \
26                   cut -d' ' -f3`"
27destruction1="`grep 'Red500' $COL_FILE | \
28                     cut -d' ' -f3`"
29
30# Check and re-color 'button_close_pressed' button
31if [ -e $KEY_FILE ]; then
32    selection2="`grep 'key_selection' $KEY_FILE | \
33                 cut -d' ' -f2 | cut -d';' -f1`"
34    destruction2="`grep 'key_destruction' $KEY_FILE | \
35                   cut -d' ' -f2 | cut -d';' -f1`"
36
37    cp -f $RECOLOR_FILE1.in $RECOLOR_FILE1
38    cp -f $RECOLOR_FILE2.in $RECOLOR_FILE2
39    cp -f $RECOLOR_FILE3.in $RECOLOR_FILE3
40    cp -f $RECOLOR_FILE4.in $RECOLOR_FILE4
41
42    if [ $selection1 != $selection2 ]; then
43        sed -i '' "s/$selection1/$selection2/gi" $RECOLOR_FILE1
44        sed -i '' "s/$selection1/$selection2/gi" $RECOLOR_FILE3
45        echo $selection1 is re-colored with $selection2.
46    fi
47
48    if [ $destruction1 != $destruction2 ]; then
49        sed -i '' "s/$destruction1/$destruction2/gi" $RECOLOR_FILE2
50        sed -i '' "s/$destruction1/$destruction2/gi" $RECOLOR_FILE4
51        echo $destruction1 is re-colored with $destruction2.
52    fi
53else
54    echo ../../../gtk/sass/common/resources/_key_colors.scss was not found. Stopped...
55    exit 1
56fi
57
58# Clone stock SVG files
59for i in $(<$INDEX_C)
60do
61    if [ '!' -d $ASSETS_DIR/light ]; then
62        mkdir -p $ASSETS_DIR/light
63    fi
64    if [ '!' -d $ASSETS_DIR/dark ]; then
65        mkdir -p $ASSETS_DIR/dark
66    fi
67    if [ '!' -d $ASSETS_DIR/light-compact ]; then
68        mkdir -p $ASSETS_DIR/light-compact
69    fi
70    if [ '!' -d $ASSETS_DIR/dark-compact ]; then
71        mkdir -p $ASSETS_DIR/dark-compact
72    fi
73    if [ -f $ASSETS_DIR/light/$i.svg ] && \
74        [ $SRC_DIR/common/$i.svg -ot $ASSETS_DIR/light/$i.svg ]; then
75        echo $ASSETS_DIR/light/$i.svg exists.
76    else
77        echo Cloning $ASSETS_DIR/light/$i.svg
78        cp $SRC_DIR/common/$i.svg $ASSETS_DIR/light
79    fi
80    if [ -f $ASSETS_DIR/light-compact/$i.svg ] && \
81        [ $SRC_DIR/common-compact/$i.svg -ot $ASSETS_DIR/light-compact/$i.svg ]; then
82        echo $ASSETS_DIR/light-compact/$i.svg exists.
83    else
84        echo Cloning $ASSETS_DIR/light-compact/$i.svg
85        cp $SRC_DIR/common-compact/$i.svg $ASSETS_DIR/light-compact
86    fi
87    if [ -f $ASSETS_DIR/dark/$i.svg ] && \
88        [ $SRC_DIR/common/$i.svg -ot $ASSETS_DIR/dark/$i.svg ]; then
89        echo $ASSETS_DIR/dark/$i.svg exists.
90    else
91        echo Cloning $ASSETS_DIR/dark/$i.svg
92        cp $SRC_DIR/common/$i.svg $ASSETS_DIR/dark
93    fi
94    if [ -f $ASSETS_DIR/dark-compact/$i.svg ] && \
95        [ $SRC_DIR/common-compact/$i.svg -ot $ASSETS_DIR/dark-compact/$i.svg ]; then
96        echo $ASSETS_DIR/dark-compact/$i.svg exists.
97    else
98        echo Cloning $ASSETS_DIR/dark-compact/$i.svg
99        cp $SRC_DIR/common-compact/$i.svg $ASSETS_DIR/dark-compact
100    fi
101done
102for i in $(<$INDEX)
103do
104    if [ -f $ASSETS_DIR/light/$i.svg ] && \
105        [ $SRC_DIR/light/$i.svg -ot $ASSETS_DIR/light/$i.svg ]; then
106        echo $ASSETS_DIR/light/$i.svg exists.
107    else
108        echo Cloning $ASSETS_DIR/light/$i.svg
109        cp $SRC_DIR/light/$i.svg $ASSETS_DIR/light
110    fi
111    if [ -f $ASSETS_DIR/light-compact/$i.svg ] && \
112        [ $SRC_DIR/light-compact/$i.svg -ot $ASSETS_DIR/light-compact/$i.svg ]; then
113        echo $ASSETS_DIR/light-compact/$i.svg exists.
114    else
115        echo Cloning $ASSETS_DIR/light-compact/$i.svg
116        cp $SRC_DIR/light-compact/$i.svg $ASSETS_DIR/light-compact
117    fi
118    if [ -f $ASSETS_DIR/dark/$i.svg ] && \
119        [ $SRC_DIR/dark/$i.svg -ot $ASSETS_DIR/dark/$i.svg ]; then
120        echo $ASSETS_DIR/dark/$i.svg exists.
121    else
122        echo Cloning $ASSETS_DIR/dark/$i.svg
123        cp $SRC_DIR/dark/$i.svg $ASSETS_DIR/dark
124    fi
125    if [ -f $ASSETS_DIR/dark-compact/$i.svg ] && \
126        [ $SRC_DIR/dark-compact/$i.svg -ot $ASSETS_DIR/dark-compact/$i.svg ]; then
127        echo $ASSETS_DIR/dark-compact/$i.svg exists.
128    else
129        echo Cloning $ASSETS_DIR/dark-compact/$i.svg
130        cp $SRC_DIR/dark-compact/$i.svg $ASSETS_DIR/dark-compact
131    fi
132done
133
134exit 0
135