#!/bin/bash

# wallcolGradient

# pick two colors and set that gradient as wallpaper

one="$(gpick -p -s -o)"
two="$(gpick -p -s -o)"

res="$(xdpyinfo | awk '/dimensions/{print $2}')"

doit () {
    
    # info
    echo "$one > $two @ $res"
    
    # make gradient
    convert -size "${res}" gradient:"${one}-${two}" -channel RGB -separate -dither FloydSteinberg -colors 256 -combine -depth 8 ~/.gradient.png || exit
    
     # -set colorspace HSB -colorspace RGB
    
    # if there is ~/.noise.png, lets overlay that automagically
    if [[ -f ~/.noise.png ]]; then
        composite -tile -alpha off -compose overlay ~/.noise.png ~/.gradient.png /tmp/tmpout.png
        mv /tmp/tmpout.png ~/.gradient.png
    fi 
    
   
    
    # set wallpaper
    nitrogen --save --set-centered ~/.gradient.png

}

[[ "$one" && "$two" && "$res" ]] && doit