Set plain as fallback theme if theme not found. Better variable names.

This commit is contained in:
Ceda EI 2019-09-06 19:21:53 +05:30
parent 2c6c83b826
commit ab5df51c2a
1 changed files with 21 additions and 11 deletions

32
wish.sh
View File

@ -2,26 +2,36 @@
function wish_init() { function wish_init() {
# Source all plugins # Source all plugins
local i local plugin
local j local path
for i in ${WISH_PLUGINS[@]}; do for plugin in ${WISH_PLUGINS[@]}; do
for j in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do for path in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do
source "$j/wish/plugins/$i.sh" &> /dev/null && break source "$path/wish/plugins/$plugin.sh" &> /dev/null && break
done done
[[ $? -ne 0 ]] && echo "Plugin $i not found." >&2 [[ $? -ne 0 ]] && echo "Plugin $i not found." >&2
done done
# Source theme # Source theme
WISH_THEME=${WISH_THEME:-plain} WISH_THEME=${WISH_THEME:-plain}
for i in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do while :; do
source "$i/wish/themes/$WISH_THEME.sh" &> /dev/null && break for theme in "$XDG_CONFIG_HOME" "/usr/share" "$HOME/.config"; do
source "$theme/wish/themes/$WISH_THEME.sh" &> /dev/null && break
done
if [[ $? -eq 0 ]]; then
break
else
echo "Theme $WISH_THEME not found. Using theme plain." >&2
if [[ $WISH_THEME == "plain" ]]; then
break
else
WISH_THEME=plain
fi
fi
done done
[[ $? -ne 0 ]] && echo "Theme $WISH_THEME not found." >&2
# Call plugins to set colors # Call plugins to set colors
for i in ${WISH_PLUGINS[@]}; do for plugin in ${WISH_PLUGINS[@]}; do
eval wish_$(echo $i)_set_colors $prev eval wish_$(echo $plugin)_set_colors $prev
done done
} }