mabox-colorizer/bin/mbclr

189 lines
7.6 KiB
Plaintext
Raw Normal View History

2022-05-15 03:25:01 +02:00
#!/bin/bash
#
# mbclr current polecenie funkcja argument backprg [config_file]
# mbclr
2022-08-15 01:42:52 +02:00
case "$LANG" in
pl*)
SELECT_COLOR="Wybierz kolor"
PICK_FROM_SCREEN="Pobierz kolor z ekranu"
SELECT_OR_PICK="Wybierz kolor z selektora"
OPACITY="Nieprzezroczystość"
SHADES_OF_CURRENT="odcienie bieżącego"
SHADES_OF="odcienie"
WALLPAPER_COLORS="Kolory z tapety"
ACCENT_COLORS="Popularne kolory akcentu"
LIGHTCOLORS="Jasne kolory..."
DARKCOLORS="Ciemne kolory..."
;;
*)
SELECT_COLOR="Select color"
PICK_FROM_SCREEN="Pick color from screen"
SELECT_OR_PICK="Select or pick from screen"
OPACITY="Opacity"
SHADES_OF_CURRENT="shades of current"
SHADES_OF="shades of"
WALLPAPER_COLORS="Wallpaper colors"
ACCENT_COLORS="Popular accent colors"
LIGHTCOLORS="Light colors..."
DARKCOLORS="Dark colors..."
;;
esac
2022-05-15 03:25:01 +02:00
main () {
#read WALLPAPER<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2)
2022-06-11 12:27:09 +02:00
WALLPALDIR="$HOME/.config/colormenu/palettes/wallp"
2022-05-15 03:25:01 +02:00
mkdir -p "$WALLPALDIR"
read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2)
WALLPAPER=${WALLPATH##*/}
if [ ! -f "$WALLPALDIR/$WALLPAPER.clr" ]; then
2022-05-24 19:32:53 +02:00
convert ${WALLPATH} -resize 25% -colors 16 -unique-colors txt:- |grep -v '^#'| awk '{print substr($3,1,7)}' |pastel sort-by brightness |pastel format hex > "$WALLPALDIR/$WALLPAPER.clr"
2022-05-15 03:25:01 +02:00
fi
mapfile -t wallcolors < "$WALLPALDIR/$WALLPAPER.clr"
2022-08-15 01:42:52 +02:00
if [[ "${#wallcolors[@]}" -lt 8 ]]; then
wallcolors+=("#2e3440" "#4c566a" "#5e81ac" "#bf616b" "#b48ead" "#a3be8c" "#ebcb8b" "#d8dee9" "#eceff4")
fi
2022-05-15 03:25:01 +02:00
dark=("#000000" "#111111" "#222222" "#333333" "#444444" "#555555" "#666666")
light=("#FFFFFF" "#EEEEEE" "#DDDDDD" "#CCCCCC" "#BBBBBB" "#AAAAAA" "#999999")
2022-06-11 12:27:09 +02:00
#yt=("#181818" "#212121" "#3d3d3d" "#FFFFFF" "#AAAAAA")
2022-08-15 01:42:52 +02:00
plasma=("#e93a9a" "#e93d58" "#e9643a" "#e8cb2d" "#3dd425" "#00d3b8" "#3daee9" "#b875dc" "#926ee4" "#686b6f")
2022-05-15 03:25:01 +02:00
#ubuntu
ubuntu=("#E95420" "#18b0b0" "#3584e4" "#0e8420" "#c748ba" "#77216f" "#c7162b" "#f4a100")
#linuxmint
mint+=("#6cabcd" "#5b73c4" "#aa876a" "#9d9d9d" "#db9d61" "#c76199" "#8c6ec9" "#c15b58" "#c8ac69" "#5aaa9a")
2022-08-15 01:42:52 +02:00
#w8+=("#a4c400" "#60a917" "#008a00" "#00aba9" "#1ba1e2" "#3e65ff" "#0050ef" "#6a00ff" "#aa00ff" "#f472d0" "#d80073" "#a20025" "#e51400" "#fa6800" "#f0a30a" "#e3c800" "#825a2c" "#6d8764" "#647687" "#76608a" "#87794e" "#a0522d")
2022-05-15 03:25:01 +02:00
#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)
2022-08-15 01:42:52 +02:00
out+=("^sep($OPACITY)")
2022-08-27 16:36:46 +02:00
out+=("$OPACITY <small>[ <b>$OP</b> ]</small>,^checkout(opacity)")
2022-05-15 03:25:01 +02:00
out2+=("^tag(opacity)")
2022-08-15 01:42:52 +02:00
out2+=("^sep($OPACITY <small>[ $OP ]</small>")
2022-05-15 03:25:01 +02:00
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
2022-08-15 01:42:52 +02:00
out+=("^sep($SELECT_COLOR)")
2022-08-27 16:36:46 +02:00
out+=(" $PICK_FROM_SCREEN,mbclr pixelcolor $2 $3 ${5} ${6}")
out+=(" $SELECT_OR_PICK,mbclr pick $2 $3 ${5} ${6}")
2022-05-15 03:25:01 +02:00
out+=("^sep()")
2022-08-27 16:36:46 +02:00
out+=("<tt><span bgcolor='$1'> </span></tt> $SHADES_OF_CURRENT (<small>$1</small>),^checkout(curshades)")
2022-05-15 03:25:01 +02:00
2022-08-15 01:42:52 +02:00
out+=("^sep($WALLPAPER_COLORS)")
2022-05-15 03:25:01 +02:00
for i in "${wallcolors[@]}"
do
out+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}")
done
2022-08-15 01:42:52 +02:00
out+=("^sep()")
out+=("$ACCENT_COLORS,^checkout(accents)")
out2+=("^tag(accents)")
out2+=("^sep(Ubuntu)")
2022-05-15 03:25:01 +02:00
for i in ${ubuntu[@]};do out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}");done
2022-08-15 01:42:52 +02:00
out2+=("^sep(Mint)")
2022-05-15 03:25:01 +02:00
for i in ${mint[@]};do out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}");done
2022-08-15 01:42:52 +02:00
out2+=("^sep(Plasma)")
2022-05-15 03:25:01 +02:00
for i in ${plasma[@]};do out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}");done
out+=("^sep()")
2022-08-27 16:36:46 +02:00
out+=("<tt><span bgcolor='#DDDDDD'> </span></tt> $LIGHTCOLORS,^checkout(light)")
2022-05-15 03:25:01 +02:00
out2+=("^tag(light)")
2022-08-15 01:42:52 +02:00
out2+=("^sep($LIGHTCOLORS)")
2022-05-15 03:25:01 +02:00
for i in "${light[@]}"
do
out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}")
done
out+=("^sep()")
2022-08-27 16:36:46 +02:00
out+=("<tt><span bgcolor='#222222'> </span></tt> $DARKCOLORS,^checkout(dark)")
2022-05-15 03:25:01 +02:00
out2+=("^tag(dark)")
2022-08-15 01:42:52 +02:00
out2+=("^sep($DARKCOLORS)")
2022-05-15 03:25:01 +02:00
for i in "${dark[@]}"
do
out2+=("<tt><small>$i</small> <span bgcolor='$i'> </span></tt>,$2 $3 '${i}' ${6};${5}")
done
#Shades
out2+=("^tag(curshades)")
2022-08-15 01:42:52 +02:00
out2+=("^sep($SHADES_OF $1)")
2022-05-15 03:25:01 +02:00
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 () {
#notify-send.sh -t 50000 "From pickcolor" "1: $1\n2: $2\n3: $3\n4: $4\n5: $5\n6: $6"
2022-05-15 03:25:01 +02:00
color=$(gcolor3 2>/dev/null)
if [ "$color" ]; then
mycmd=("$1 $2 '${color}' ${4};${3}")
fi
eval "${mycmd[@]}"
}
pixelcolor() {
picker=${picker:-gpick}
if [ "$picker" == "gpick" ]; then
command="gpick -pso 2>/dev/null"
else
command="xcolor --preview-size ${size} --scale ${scale}"
fi
color="$(${command})"
if [ -n "${color}" ]; then
mycmd=("$1 $2 '${color}' ${4};${3}")
2022-05-15 03:25:01 +02:00
fi
eval "${mycmd[@]}"
}
case "$1" in
pick) pickcolor "$2" "${3}" "${4} ${5}" "${6}";;
pixelcolor) pixelcolor "$2" "${3}" "${4} ${5}" "${6}";;
2022-05-15 03:25:01 +02:00
*) main "$@" ;;
esac