diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-12-12 21:14:57 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-12-12 21:14:57 +0100 |
commit | be0677cf498aa885a6203fcd0c21c315ad1face3 (patch) | |
tree | 2a61753ec3644ef9c74044f06c91eee7ca56bad3 /script/rofi-convert-theme.sh | |
parent | c6030063c6eeee267eca07d06dbe69a2657181c6 (diff) |
Update theme to new format.
- @class state {
}
- #name state {
}
Diffstat (limited to 'script/rofi-convert-theme.sh')
-rwxr-xr-x | script/rofi-convert-theme.sh | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/script/rofi-convert-theme.sh b/script/rofi-convert-theme.sh new file mode 100755 index 00000000..7ec801d0 --- /dev/null +++ b/script/rofi-convert-theme.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# +# This code is released in public domain by Dave Davenport <qball@gmpclient.org> +# This converts from old style theme (< 1.4) to new style theme (>= 1.4) +# +function update_color () +{ + 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 + echo ${var} + fi +} + +function parse_window_color () +{ + 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} +} + +function parse_color () +{ + 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 + parse_color "normal" "${LINE:18}" + elif [[ ${LINE} =~ ^rofi\.color-urgent: ]] + then + parse_color "urgent" "${LINE:18}" + elif [[ ${LINE} =~ ^rofi\.color-active: ]] + then + parse_color "active" "${LINE:18}" + elif [[ ${LINE} =~ ^rofi\.color-window: ]] + then + parse_window_color "${LINE:18}" + fi +done |