mabox-colorizer/bin/mbclr

155 lines
6.6 KiB
Bash
Executable File

#!/bin/bash
#
# mbclr current polecenie funkcja argument backprg [config_file]
# mbclr
main () {
#read WALLPAPER<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2)
WALLPALDIR="$HOME/.config/mbxcolors/palettes/wallp"
mkdir -p "$WALLPALDIR"
read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2)
WALLPAPER=${WALLPATH##*/}
if [ ! -f "$WALLPALDIR/$WALLPAPER.clr" ]; then
convert ${WALLPATH} -resize 25% -colors 16 -unique-colors txt:- |grep -v '^#'| awk '{print $3}' |pastel sort-by brightness |pastel format hex > "$WALLPALDIR/$WALLPAPER.clr"
fi
mapfile -t wallcolors < "$WALLPALDIR/$WALLPAPER.clr"
dark=("#000000" "#111111" "#222222" "#333333" "#444444" "#555555" "#666666")
light=("#FFFFFF" "#EEEEEE" "#DDDDDD" "#CCCCCC" "#BBBBBB" "#AAAAAA" "#999999")
yt=("#181818" "#212121" "#3d3d3d" "#FFFFFF" "#AAAAAA")
plasma=("#e93a9a" "#e93d58" "#e9643a" "#e8cb2d" "#3dd425" "#00d3b8" "#3daee9" "#b875dc" "#926ee4" "#686b6f",)
#ubuntu
ubuntu=("#E95420" "#18b0b0" "#3584e4" "#0e8420" "#c748ba" "#77216f" "#c7162b" "#f4a100")
#linuxmint
mint+=("#6cabcd" "#5b73c4" "#aa876a" "#9d9d9d" "#db9d61" "#c76199" "#8c6ec9" "#c15b58" "#c8ac69" "#5aaa9a")
w8+=("#a4c400" "#60a917" "#008a00" "#00aba9" "#1ba1e2" "#3e65ff" "#0050ef" "#6a00ff" "#aa00ff" "#f472d0" "#d80073" "#a20025" "#e51400" "#fa6800" "#f0a30a" "#e3c800" "#825a2c" "#6d8764" "#647687" "#76608a" "#87794e" "#a0522d")
#for i in $(theme.sh -p |cut -d':' -f2)
#do
#colors+=("$i")
#done
out+=("^sep($4)")
if [[ "$2" == "jgctl" ]]; then
. $HOME/.config/mabox/mabox.conf
case "$jgmenu_theme" in
obtheme)
OBTHEME=$(awk '/<theme>/ {while (getline n) {if (match(n, /<name>/))
{l=n; exit}}} END {split(l, a, "[<>]"); print a[3]}' "$HOME/.config/openbox/rc.xml");
THEMERC="$HOME/.config/mabox/jgobthemes/${OBTHEME}.colorrc";;
*)
THEMERC="$HOME/.config/mabox/jgobthemes/${jgmenu_theme}.colorrc";;
esac
read COLOR OP<<< $(grep "${3}" ${THEMERC} | cut -d'=' -f2)
out+=("^sep(OPACITY)")
out+=("OPACITY <small>[ $OP ]</small>,^checkout(opacity)")
out2+=("^tag(opacity)")
out2+=("^sep(OPACITY <small>[ $OP ]</small>")
out2+=("<tt><small>100</small> <span bgcolor='$1' bgalpha='100%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 100;${5}")
out2+=("<tt><small> 95</small> <span bgcolor='$1' bgalpha='95%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 95 ;${5}")
out2+=("<tt><small> 90</small> <span bgcolor='$1' bgalpha='90%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 90 ;${5}")
out2+=("<tt><small> 80</small> <span bgcolor='$1' bgalpha='80%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 80 ;${5}")
out2+=("<tt><small> 70</small> <span bgcolor='$1' bgalpha='70%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 70 ;${5}")
out2+=("<tt><small> 60</small> <span bgcolor='$1' bgalpha='60%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 60 ;${5}")
out2+=("<tt><small> 50</small> <span bgcolor='$1' bgalpha='50%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 50 ;${5}")
out2+=("<tt><small> 40</small> <span bgcolor='$1' bgalpha='40%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 40 ;${5}")
out2+=("<tt><small> 30</small> <span bgcolor='$1' bgalpha='30%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 30 ;${5}")
out2+=("<tt><small> 20</small> <span bgcolor='$1' bgalpha='20%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 20 ;${5}")
out2+=("<tt><small> 10</small> <span bgcolor='$1' bgalpha='10%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 10 ;${5}")
out2+=("<tt><small> 5</small> <span bgcolor='$1' bgalpha='5%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 5 ;${5}")
out2+=("<tt><small> 0</small> <span bgcolor='$1' bgalpha='1%'> </span><span bgcolor='$1'> </span></tt>,jgctl $3 0 ;${5}")
fi
#Current
out+=("^sep(SELECT_COLOR)")
out+=(" Select or pick from screen,mbclr pick $2 $3 ${5} ${6}")
out+=("^sep()")
out+=("<tt><span bgcolor='$1'> </span></tt> shades of current,^checkout(curshades)")
out+=("^sep(Wallpaper colors)")
for i in "${wallcolors[@]}"
do
out+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}")
done
out+=("^sep(ACCENT COLORS)")
out+=("Ubuntu,^checkout(ubuntu)")
out2+=("^tag(ubuntu)" "^sep(Ubuntu)")
for i in ${ubuntu[@]};do out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}");done
out+=("Mint,^checkout(mint)")
out2+=("^tag(mint)" "^sep(Mint)")
for i in ${mint[@]};do out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}");done
out+=("Plasma,^checkout(plasma)")
out2+=("^tag(plasma)" "^sep(Plasma)")
for i in ${plasma[@]};do out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}");done
out+=("W8,^checkout(w8)")
out2+=("^tag(w8)" "^sep(W8)")
for i in ${w8[@]};do out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}");done
out+=("^sep()")
out+=("<tt><span bgcolor='#DDDDDD'> </span></tt> Light colors..,^checkout(light)")
out2+=("^tag(light)")
out2+=("^sep(LIGHT)")
for i in "${light[@]}"
do
out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}")
done
out+=("^sep()")
out+=("<tt><span bgcolor='#222222'> </span></tt> Dark colors..,^checkout(dark)")
out2+=("^tag(dark)")
out2+=("^sep(DARK)")
for i in "${dark[@]}"
do
out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}")
done
out+=("^sep()")
out+=("<tt><span bgcolor='#181818'> </span></tt> YT colors..,^checkout(yt)")
out2+=("^tag(yt)")
out2+=("^sep(yt)")
for i in "${yt[@]}"
do
out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}")
done
#Shades
out2+=("^tag(curshades)")
out2+=("^sep(Shades of $1)")
for i in 3 25 2 15 1 05; do
clr=$(pastel lighten 0.$i "${1}" | pastel format hex)
if [ "${clr}" != "#ffffff" ];then
out2+=("<tt><small>$clr</small> <span bgcolor='$clr'> </span></tt>,$2 $3 '${clr}' ${6};${5}")
fi
done
out2+=("^sep()")
out2+=("<tt><small>$1</small> <span bgcolor='$1'> </span></tt>,$2 $3 '${1}' ${6};${5}")
out2+=("^sep()")
for i in 05 1 15 2 25 3; do
clr=$(pastel darken 0.$i "${1}" | pastel format hex)
if [ "${clr}" != "#000000" ];then
out2+=("<tt><small>$clr</small> <span bgcolor='$clr'> </span></tt>,$2 $3 '${clr}' ${6};${5}")
fi
done
printf '%s\n' "${out[@]}"
printf '%s\n' "${out2[@]}"
}
pickcolor () {
color=$(gcolor3 2>/dev/null)
if [ "$color" ]; then
mycmd=("$1 $2 '${color}' ${4};${3} -s")
fi
eval "${mycmd[@]}"
#notify-send.sh "Qpa $1" "${mycmd[@]}"
}
case "$1" in
pick) pickcolor "$2" "${3}" "${5}" "${6}";;
*) main "$@" ;;
esac