#!/usr/bin/env bash


# Favorites:
# - horizon-terminal-dark
# - heetch
# - blueforest
# - tarot

if [[ -n "$1" ]]; then
	export SCHEME=$1
fi

if [ ! -r "$(shchemes path)" ]; then
	if ! shchemes install_tinted_scheme; then
		exit 1
	fi
fi

# shchemes inject "$HOME/.profile"

shchemes inject "$HOME/.config/qutebrowser/config.py"
shchemes create_theme css > "$HOME/.config/base16.css"
shchemes create_theme css > "$HOME/.config/qutebrowser/base16.css"
pkill -HUP qutebrowser

shchemes create_theme xfce4-terminal | sh

shchemes create_theme i3 > "$HOME/.config/i3/theme"
i3-msg reload

shchemes create_theme rofi > "$HOME/.config/rofi/theme.rasi"
shchemes create_theme better-discord > "$HOME/.config/vesktop/themes/theme.css"
# shchemes create_theme obsidian > "$HOME/media/vault/.obsidian/themes/base16.css"

# "$HOME/repos/oomox-gtk-theme/change_color.sh" -o base16 <(shchemes create_theme oomox-gtk)

# Reload XFCE theme
# xfconf-query -c xsettings -p /Net/ThemeName -r
# xfconf-query -c xsettings -p /Net/ThemeName -s base16

xrandr | awk '$2 == "connected" { system("le-wallpaper " $1) }'

# WALLPAPER_OUT="$HOME/.wallpaper.png"
# shchemes create_theme imagemagick \
	# | convert ~/pictures/wallpapers/tradin.jpg -dither FloydSteinberg -colorspace srgb -remap txt:- "$WALLPAPER_OUT"
# feh --bg-scale "$WALLPAPER_OUT"

# terminal=$(ps -o comm= -p "$(($(ps -o ppid= -p "$(($(ps -o sid= -p "$$")))")))")
# if [[ "$terminal" == "kitty" ]]; then
	# tmp=$(mktemp)
	# shchemes create_theme imagemagick \
		# | convert txt:- -filter point -resize 2400% "$tmp"
	# kitty +kitten icat "$tmp"
# fi
