suckless-utils/scripts/adelle-theme

215 lines
4.4 KiB
Bash
Executable file

#!/bin/sh
# Adelle Theme Manager, written in Bash.
# Adelle Theme Manager Copyright (C) 2023 Alexis Jhon Gaspar.
# This program comes with ABSOLUTELY NO WARRANTY; for details type `l'.
# This is free software, and you are welcome to redistribute it
# under certain conditions; type `l` for details.
help() {
printf "Adelle Theme Manager by lucss21a. Written in bash!\n\nh or help: Prints this text\ns or set: Set the colorscheme\nsw or setwall: Set the wallpaper\nd or download: Download themes to the \$HOME/.config/wal/colorschemes/dark directory\nc or clear: Clear the theme directory\nl or license: View the GNU General Public License Version 3.\nq or quit: Quit the program\n"
command
}
settheme() {
read -p "Where is the theme directory? " waldir
if [ -z "$waldir" ]; then
waldir="$HOME/.config/wal/colorschemes/dark"
if [[ -z $(ls -A "$waldir") ]]; then
echo "Oh no! No files here!"
settheme
else
ls -w 1 "$waldir"
fi
else
if [[ -z $(ls -A "$waldir") ]]; then
echo "Oh no! No files here!"
settheme
else
ls -w 1 "$waldir"
fi
fi
read -p "What theme? " theme
if [ -z "$theme" ]; then
settheme
else
if [[ "$theme" != *.json ]]; then
wal --theme "$waldir/$theme.json"
if [ -z "$picwaldir" ]; then
setwallq
unset theme
else
unset theme
command
fi
else
wal --theme "$waldir/$theme"
if [ -z "$picwaldir" ]; then
setwallq
unset theme
else
unset theme
command
fi
fi
fi
}
setwallq() {
read -p "Do you want to set the wallpaper as well? (default is Yes) " wallpaper
case $wallpaper in
[yY][eE][sS]|[yY]|*) setwall;;
[nN][oO]|[nN]) exit;;
esac
}
setwall() {
read -p "Where is the wallpaper directory? " picwaldir
if [ -z "$picwaldir" ]; then
picwaldir="$HOME/Pictures/Wallpapers"
if [[ -z $(ls -A "$picwaldir") ]]; then
echo "Oh no! No files here!"
setwall
else
ls -w 1 "$picwaldir"
fi
else
if [[ -z $(ls -A "$picwaldir") ]]; then
echo "Oh no! No files here!"
setwall
else
ls -w 1 "$picwaldir"
fi
fi
read -p "What wallpaper? " picwal
if [ -z "$picwal" ]; then
setwall
else
wal -i "$picwaldir/$picwal" -qst
if [ -z "$theme" ]; then
setcolor1
unset picwaldir
else
unset picwaldir
command
fi
fi
}
setcolor1() {
read -p "Do you want to set the colors as well? (default is Yes) " colors
case $colors in
[yY][eE][sS] | [yY]) setcolor2;;
[nN][oO] | [nN]) wal -R -st && command;;
*) setcolor2;;
esac
exit
}
setcolor2() {
read -p "Do you want to set colors automatically? (default is Yes) " manualcolor
case $manualcolor in
[yY][eE][sS] | [yY]) wal -R && command;;
[nN][oO] | [nN]) settheme;;
*) wal -R && command;;
esac
}
cache() {
read -p "Where is the theme directory? " waldir
if [ -z "$waldir" ]; then
waldir=".config/wal/colorschemes/dark"
if [[ -z $(ls -A "$waldir") ]]; then
echo "Already wiped out."
command
else
read -p "Are you sure? (default is No) " del
case $del in
[yY][eE][sS] | [yY]) rm -r "$waldir/*.json*";;
[nN][oO] | [nN]) command;;
*) command;;
esac
fi
else
if [[ -z $(ls -A "$waldir") ]]; then
echo "Already wiped out."
command
else
read -p "Are you sure? (default is No) " del
case $del in
[yY][eE][sS] | [yY]) rm -rf "$waldir/*.json*";;
[nN][oO] | [nN]) command;;
*) command;;
esac
fi
fi
}
download() {
read -p "Where is the theme directory? " waldir
if [ -z "$waldir" ]; then
waldir=".config/wal/colorschemes/dark"
else
$waldir
fi
read -p "Put the url of the file: " url
if [ -z "$url" ]; then
download
else
wget --show-progress -q -P $waldir $url
if [ "$?" != 0 ]; then
echo "Download failed. Check if you are connected or if the domain exists."
download
else
echo "Download complete!"
command
fi
fi
}
license() {
LICENSE=/tmp/gpl-3.0.txt
if [ -f "$LICENSE" ]; then
rm "$LICENSE"
else
wget -q https://www.gnu.org/licenses/gpl-3.0.txt -P /tmp
vim "$LICENSE" || nano "$LICENSE" || emacs "$LICENSE" || cat "$LICENSE"
command
fi
}
command () {
echo "Enter h or help for a list of commands."
read -p "adelle-themer> " command
case $command in
[hH] | help ) help;;
[sS] | set ) settheme;;
[sS][wW] | setwall ) setwall;;
[dD] | download ) download;;
[cC] | clear) cache;;
[lL] | license) license;;
[qQ] | quit | exit) printf "Bye!\n" && exit;;
*) printf "Check h or help!\n" && command;;
esac
}
command