91 lines
1.8 KiB
Bash
Executable File
91 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# cavactl - cava script for Mabox
|
|
CFGFILE=~/.config/cava/config
|
|
|
|
reload_config() {
|
|
pkill -USR1 cava
|
|
}
|
|
|
|
reload_colors() {
|
|
pkill -USR2 cava > /dev/null 2>&1
|
|
}
|
|
mode() {
|
|
case "$1" in
|
|
solid) sd ".*gradient .*" "gradient = 0" ${CFGFILE};;
|
|
gradient) sd ".*gradient .*" "gradient = 1" ${CFGFILE};;
|
|
esac
|
|
reload_colors
|
|
}
|
|
|
|
foregroundcolor(){
|
|
sd ".*foreground .*" "foreground = '${1}'" ${CFGFILE}
|
|
}
|
|
|
|
foreground() {
|
|
sd ".*foreground .*" "foreground = '${1}'" ${CFGFILE}
|
|
sd ".*gradient .*" "gradient = 0" ${CFGFILE}
|
|
reload_colors
|
|
}
|
|
gradientcolors() {
|
|
n=1
|
|
for i in $(pastel gradient -n 8 ${1} ${2}|pastel format hex)
|
|
do
|
|
sd ".*gradient_color_${n}.*" "gradient_color_${n} = '${i}'" ${CFGFILE}
|
|
((n++))
|
|
done
|
|
}
|
|
gradient() {
|
|
n=1
|
|
for i in $(pastel gradient -n 8 ${1} ${2}|pastel format hex)
|
|
do
|
|
sd ".*gradient_color_${n}.*" "gradient_color_${n} = '${i}'" ${CFGFILE}
|
|
((n++))
|
|
done
|
|
|
|
sd ".*gradient .*" "gradient = 1" ${CFGFILE}
|
|
sd ".*gradient_count .*" "gradient_count = 8" ${CFGFILE}
|
|
reload_colors
|
|
}
|
|
grad_from() {
|
|
read GR_TO <<< "$(grep '.*gradient_color_8 ' ${CFGFILE} | cut -d"'" -f2)"
|
|
gradient "$1" "${GR_TO}"
|
|
}
|
|
grad_to() {
|
|
read GR_FROM <<< "$(grep '.*gradient_color_1 ' ${CFGFILE} | cut -d"'" -f2)"
|
|
gradient "${GR_FROM}" "$1"
|
|
}
|
|
|
|
bar_width () {
|
|
sd ".*bar_width .*" "bar_width = ${1}" ${CFGFILE}
|
|
reload_config
|
|
}
|
|
|
|
|
|
bar_spacing() {
|
|
sd ".*bar_spacing .*" "bar_spacing = ${1}" ${CFGFILE}
|
|
reload_config
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
mode) mode "$2";;
|
|
foregroundcolor) foregroundcolor "$2";;
|
|
foreground) foreground "$2";;
|
|
gradientcolors) gradientcolors "$2" "$3";;
|
|
gradient) gradient "$2" "$3";;
|
|
grad_from) grad_from "$2";;
|
|
grad_to) grad_to "$2";;
|
|
reload) reload_config;;
|
|
reload_colors)reload_colors;;
|
|
bar_width)bar_width "$2";;
|
|
bar_spacing)bar_spacing "$2";;
|
|
|
|
*):;;
|
|
esac
|