dotfiles/config/i3/scripts/rofi_themes
2024-04-04 12:51:24 +02:00

51 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
## Copyright (C) 2020-2023 Aditya Shakya <adi1090x@gmail.com>
# Import Current Theme
DIR="$HOME/.config/i3"
STYLE="onedark"
RASI="$DIR/themes/$STYLE/rofi/themes.rasi"
# List Available Themes
THEMES=(`cd $DIR/themes && ls -d */ | cut -d '/' -f1`)
# Theme Elements
prompt="Themes"
mesg="<b>Available Themes</b> : `cd $DIR/themes && ls -d */ | cut -d '/' -f1 | wc -l`"
# Rofi CMD
rofi_cmd() {
rofi -dmenu \
-p "$prompt" \
-mesg "$mesg" \
-sep '|' \
-markup-rows \
-theme ${RASI}
}
# Pass variables to rofi dmenu
run_rofi() {
echo ${THEMES[@]} | sed 's/ /|/g' | sed 's/$/|/' | sed 's/^/Random||/' | rofi_cmd
}
# Apply Theme
apply_theme() {
selected="`run_rofi`"
current="`cat $DIR/themes/.current`"
for theme in "${THEMES[@]}"; do
if [[ -z "$selected" ]]; then
break
elif [[ "$selected" == "$theme" ]]; then
"$DIR"/themes/"$theme"/apply.sh
break
elif [[ "$selected" == 'Random' ]]; then
"$DIR"/themes/"$current"/random.sh
break
fi
done
}
apply_theme && exit 0