summaryrefslogtreecommitdiff
path: root/dot-config/rofi/scripts/rofi_themes
blob: 854e8860dcd0b82f0ac1cb4d1577ccc823064a21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash

# Import Current Theme
DIR="$HOME/.config/rofi"
RASI="$DIR/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/$/|/' | 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
		fi
	done
}

apply_theme && exit 0