#!/bin/bash # w2theme - generate themes from wallpaper colors WALLPALDIR="$HOME/.config/colormenu/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 substr($3,1,7)}' |pastel sort-by brightness |pastel format hex > "$WALLPALDIR/$WALLPAPER.clr" fi mapfile -t w < "$WALLPALDIR/$WALLPAPER.clr" menu_theme () { case "$1" in dark) #dark bg jgctl color_menu_bg "${w[0]}" jgctl color_norm_fg "${w[-2]}" jgctl color_title_bg "${w[2]}" jgctl color_title_fg "${w[-2]}" jgctl color_title_border "${w[3]}" jgctl color_sel_bg "${w[4]}" jgctl color_sel_fg "${w[-1]}" jgctl color_sel_border "${w[3]}" jgctl color_sep_fg "${w[3]}" ;; *) #light bg jgctl color_menu_bg "${w[-1]}" jgctl color_norm_fg "${w[1]}" jgctl color_title_bg "${w[-3]}" jgctl color_title_fg "${w[1]}" jgctl color_title_border "${w[-4]}" jgctl color_sel_bg "${w[-5]}" jgctl color_sel_fg "${w[0]}" jgctl color_sel_border "${w[-4]}" jgctl color_sep_fg "${w[-5]}" ;; esac } conky_colors() { case "$1" in dark) #dark bg conkyctl win_bgcolor_all "${w[0]}" conkyctl default_color_all "${w[-1]}" conkyctl color0_all "${w[-3]}" conkyctl color1_all "${w[-4]}" conkyctl color2_all "${w[-5]}" ;; *) #light bg conkyctl win_bgcolor_all "${w[-1]}" conkyctl default_color_all "${w[0]}" conkyctl color0_all "${w[2]}" conkyctl color1_all "${w[3]}" conkyctl color2_all "${w[4]}" ;; esac } pyradio_theme() { case "$1" in dark) #dark bg prtctl stations "${w[-3]}" "${w[0]}" prtctl active_station "${w[-1]}" prtctl status_bar "${w[0]}" "${w[-3]}" prtctl normal_cursor "${w[1]}" "${w[-4]}" prtctl active_cursor "${w[2]}" "${w[-3]}" prtctl edit_cursor "${w[2]}" "${w[-3]}" prtctl extra_func "${w[6]}" prtctl pyradio_url "${w[2]}" prtctl messages_border "${w[2]}" ;; *) # light bg prtctl stations "${w[4]}" "${w[-1]}" prtctl active_station "${w[0]}" prtctl status_bar "${w[0]}" "${w[-3]}" prtctl normal_cursor "${w[4]}" "${w[-3]}" prtctl active_cursor "${w[2]}" "${w[-3]}" prtctl edit_cursor "${w[2]}" "${w[-3]}" prtctl extra_func "${w[6]}" prtctl pyradio_url "${w[2]}" prtctl messages_border "${w[4]}" ;; esac } case "$1" in ob) obtheme "$2";; menu) menu_theme "$2";; conky) conky_colors "$2";; pyradio) pyradio_theme "$2";; *) ;; esac