#!/usr/bin/env sh

picker=dmenu
if exist bemenu; then
    picker=bemenu
elif exist wofi; then
    picker=wofi
elif exist rofi; then
    picker=rofi
fi

list=$(flavours list -l)
flavour=$(printf "%s\nrandom\nlight" "$list" | "$picker")
if [ -z "$flavour" ]; then
    return
elif [ "$flavour" = "random" ]; then
    flavours apply '*'
elif [ "$flavour" = "light" ]; then
    flavours apply '*light'
else
    flavours apply "$flavour"
fi

if [ "$1" = '-v' ]; then
    notify-send "Theme set" "set to: $flavour"
fi