#!/bin/bash

# Walk through all wal built in themes,
# prompting the user to pluck one into .wal_alias with
# the following format:
# alias wal-$theme_name='wal --theme $theme_name'

for theme in $(wal --theme | grep - | grep -v random | sed s/\ -\ //g); do
echo
echo
echo $theme
check_theme=$(grep $theme .wal_alias > /dev/null 2>&1; echo $?)
if [[ $check_theme -eq 0 ]]; then
echo "Skipping $theme, already have an alias"
continue
fi
wal -n -e --theme $theme -l
if [ $? -ne 0 ]; then
echo "Wal failed on dark theme for $theme, trying light"
wal -n -e --theme $theme -l
read -p "Store this theme? " REPLY
if [[ $REPLY =~ ^[Yy] ]]; then
echo "alias wal-$theme='wal -n -e --theme $theme -l'" >> .wal_alias
fi
else
read -p "Store this theme? " REPLY
if [[ $REPLY =~ ^[Yy] ]]; then
echo "alias wal-$theme='wal -n -e --theme $theme'" >> .wal_alias
fi
fi

done