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_FILE="../assets-gtk2.svg"
14COL_FILE="../../sass/common/_colors.scss"
15KEY_FILE="../../sass/common/resources/_key_colors.scss"
16
17# Default colors
18selection1="`grep 'Indigo500' $COL_FILE | \
19                   cut -d' ' -f3`"
20accent1="`grep 'Indigo300' $COL_FILE | \
21                cut -d' ' -f3`"
22
23# Check and re-color color-scheme
24if [ -e $KEY_FILE ]; then
25    selection2="`grep 'key_selection' $KEY_FILE | \
26                 cut -d' ' -f2 | cut -d';' -f1`"
27    accent2="`grep 'key_accent' $KEY_FILE | \
28              cut -d' ' -f2 | cut -d';' -f1`"
29
30    cp -f $SRC_FILE.in $SRC_FILE && sleep 1
31
32    if [ $selection1 != $selection2 ]; then
33        sed -i '' "s/$selection1/$selection2/gi" $SRC_FILE
34        echo $selection1 is re-colored with $selection2.
35    fi
36    if [ $accent1 != $accent2 ]; then
37        sed -i '' "s/$accent1/$accent2/gi" $SRC_FILE
38        echo $accent1 is re-colored with $accent2.
39    fi
40else
41    echo ../../sass/common/resources/_key_colors.scss was not found. Stopped...
42    exit 1
43fi
44