1#!/usr/local/bin/bash
2#
3# This file is part of plata-theme
4#
5# Copyright (C) 2019-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_LIGHT_FILE="plata-light.xml"
14SRC_DARK_FILE="plata-dark.xml"
15KEY_FILE="../../gtk/sass/common/resources/_key_colors.scss"
16
17# Generate CSS for color source
18SASSC="`command -v sassc`"
19SASSC_OPTION="-M -t nested"
20
21$SASSC $SASSC_OPTION sass/gtksourceview.scss sass/gtksourceview.css
22
23# Colors in HEXs
24selection1="`grep -e selection1 sass/gtksourceview.css | cut -c15-21`"
25selection2="`grep -e selection2 sass/gtksourceview.css | cut -c15-21`"
26
27# Check and re-color color-scheme
28if [ -e $KEY_FILE ]; then
29    cp -f $SRC_LIGHT_FILE.in $SRC_LIGHT_FILE && \
30    cp -f $SRC_DARK_FILE.in $SRC_DARK_FILE && sleep 1
31
32    echo Setting selection-color-1 $selection1...
33    sed -i '' "s/@selection1@/$selection1/gi" $SRC_LIGHT_FILE
34    sed -i '' "s/@selection1@/$selection1/gi" $SRC_DARK_FILE
35
36    echo Setting selection-color-2 $selection2...
37    sed -i '' "s/@selection2@/$selection2/gi" $SRC_LIGHT_FILE
38
39    rm -f sass/gtksourceview.css # clean up CSS
40else
41    echo ../../gtk/sass/common/resource/_key_colors.scss was not found. Stopped...
42    exit 1
43fi
44
45exit 0
46