2016-12-12 20:14:57 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
2021-08-14 11:03:16 +00:00
|
|
|
# This code is released in public domain by Dave Davenport <qball@gmpclient.org>
|
2016-12-12 20:14:57 +00:00
|
|
|
# This converts from old style theme (< 1.4) to new style theme (>= 1.4)
|
|
|
|
#
|
2021-08-14 11:03:16 +00:00
|
|
|
update_color()
|
2016-12-12 20:14:57 +00:00
|
|
|
{
|
|
|
|
var=${1}
|
|
|
|
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
|
|
|
|
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
|
|
|
|
if [[ ${var} =~ argb:[0-9a-fA-F]{6,8} ]]
|
|
|
|
then
|
|
|
|
echo "#${var:5}"
|
|
|
|
else
|
2021-08-14 11:03:16 +00:00
|
|
|
echo "${var}"
|
2016-12-12 20:14:57 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-08-14 11:03:16 +00:00
|
|
|
parse_window_color()
|
2016-12-12 20:14:57 +00:00
|
|
|
{
|
|
|
|
OLDIFS=${IFS}
|
|
|
|
IFS=","
|
|
|
|
entries=( ${1} )
|
|
|
|
echo "@window {"
|
|
|
|
echo " background: $( update_color ${entries[0]});"
|
|
|
|
echo " foreground: $( update_color ${entries[1]});"
|
|
|
|
echo "}"
|
|
|
|
if [ -n "${entries[2]}" ]
|
|
|
|
then
|
|
|
|
echo "@separator {"
|
|
|
|
echo " foreground: $( update_color ${entries[2]});"
|
|
|
|
echo "}"
|
|
|
|
echo "@scrollbar {"
|
|
|
|
echo " foreground: $( update_color ${entries[2]});"
|
|
|
|
echo "}"
|
|
|
|
fi
|
|
|
|
IFS=${OLDIFS}
|
|
|
|
}
|
|
|
|
|
2021-08-14 11:03:16 +00:00
|
|
|
parse_color()
|
2016-12-12 20:14:57 +00:00
|
|
|
{
|
|
|
|
state=$1
|
|
|
|
OLDIFS=${IFS}
|
|
|
|
IFS=","
|
|
|
|
entries=( ${2} )
|
|
|
|
echo "@textbox normal.${state} { "
|
|
|
|
echo " background: $( update_color ${entries[0]});"
|
|
|
|
echo " foreground: $( update_color ${entries[1]});"
|
|
|
|
echo "}"
|
|
|
|
echo "@textbox selected.${state} { "
|
|
|
|
echo " background: $( update_color ${entries[3]});"
|
|
|
|
echo " foreground: $( update_color ${entries[4]});"
|
|
|
|
echo "}"
|
|
|
|
echo "@textbox alternate.${state} { "
|
|
|
|
echo " background: $( update_color ${entries[2]});"
|
|
|
|
echo " foreground: $( update_color ${entries[1]});"
|
|
|
|
echo "}"
|
|
|
|
IFS=${OLDIFS}
|
|
|
|
}
|
|
|
|
|
|
|
|
while read LINE
|
|
|
|
do
|
|
|
|
if [[ ${LINE} =~ ^rofi\.color-normal: ]]
|
|
|
|
then
|
2021-08-14 11:03:16 +00:00
|
|
|
parse_color "normal" "${LINE:18}"
|
2016-12-12 20:14:57 +00:00
|
|
|
elif [[ ${LINE} =~ ^rofi\.color-urgent: ]]
|
|
|
|
then
|
2021-08-14 11:03:16 +00:00
|
|
|
parse_color "urgent" "${LINE:18}"
|
2016-12-12 20:14:57 +00:00
|
|
|
elif [[ ${LINE} =~ ^rofi\.color-active: ]]
|
|
|
|
then
|
2021-08-14 11:03:16 +00:00
|
|
|
parse_color "active" "${LINE:18}"
|
2016-12-12 20:14:57 +00:00
|
|
|
elif [[ ${LINE} =~ ^rofi\.color-window: ]]
|
|
|
|
then
|
|
|
|
parse_window_color "${LINE:18}"
|
|
|
|
fi
|
|
|
|
done
|