Girafenaine wrote: ↑Tue Feb 08, 2022 1:34 pm
And thanks again for having shared the wallColGradient scripts from bunsenlabs ! They are now in my fluxbox menu and a quite funny addition. I guess with some customizations, and perhaps both scripts merged in one with one or two options could be in MXFB goodies ! an idea for @Jerry3904 ? ...
Meantime I merged the three wallcol scripts into one and renamed it ‘wallcolor’.
Also added a few arguments and options that are all set in a config file named ‘wallcolor.conf’
The script uses imagemagick, plus nitrogen or feh; these are all installed by default in mx-fluxbox.
It also needs ‘gpick’ (an advanced gnome colorpicker). This can be installed from MXPI and may need one or two additional gnome dependencies.
Place ‘wallcolor’ script in a directory of your choice, like "~/.local/bin/" or: "~/.fluxbox/scripts/" - and make the file executable...
Place 'wallcolor.conf' in '~/.config' directory. Then open 'wallcolor.conf' in a text-editor, to change settings/options to your preferences:
- working directory: --> currently set to: “$HOME/wallcolor”
- image resolution: --> currently set to read the current monitor resolution. Change if you prefer larger dimensions
- image file type: --> currently set to “png”. You can change to “jpg” to reduce filesize of the image.
- wallpaper setter: --> currently set to “nitrogen” (which is mxfb default). Alternatively you can use “feh”
If you want to have the option to add noise during image generation, then an overlay image named
“.noise.png” must be placed in the wallcolor working directory.
To generate a color wallpaper, use following command:
Code: Select all
# ( <-- single color )
path-to-wallcolor -f # example: ~/.local/bin/wallcolor -f
# ( <-- two-color gradient )
path-to-wallcolor -g2 # example: ~/.local/bin/wallcolor -g2
# ( <-- four-color gradient )
path-to-wallcolor -g4 # example: ~/.local/bin/wallcolor -g4
Note that the created background will be overwritten with each new wallpaper generated by this script. So be sure to rename the creation if you want to make it available for future background setting.
script file "
wallcolor" :
Code: Select all
#!/bin/bash
#
# wallcolor
# pick color and set that as wallpaper
# original 'wallcol' scripts by brontosaurusrex / mod by ceeslans feb'22
#
# requires: gpick, imagemagick convert, nitrogen or feh
#
### usage :
# < path-to-wallcolor -f > # ( <-- single color )
# < path-to-wallcolor -g2 > # ( <-- two-color gradient )
# < path-to-wallcolor -g4 > # ( <-- four-color gradient )
#======================#
#### START SCRIPT ####
###---------------------
source $HOME/.config/wallcolor.conf
# prepare working folder for wallcolor
mkdir -p "$walldir" || echo "$walldir not found, warning..."
if [[ $1 = "-f" ]]; then
one="$(gpick -p -s -o)"
doit () {
echo "$one"
# set 1-color
convert -size $res xc:"$one" ${walldir}/bg-1color.$ext
# optionally add noise to the gradient (make sure that ".noise.png" is present in ${walldir}/
if [[ $noise = "true" ]];then
if [[ -f ${walldir}/.noise.png ]]; then
composite -alpha off -compose overlay ${walldir}/.noise.png ${walldir}/bg-1color.$ext /tmp/tmpout.$ext
mv /tmp/tmpout.$ext ${walldir}/bg-1color.$ext
fi
fi
# set wallpaper
if [[ $appl = "nitrogen" ]];then
nitrogen --save --set-zoom-fill ${walldir}/bg-1color.$ext
elif [[ $appl = "feh" ]];then
feh --bg-fill ${walldir}/bg-1color.$ext
fi
}
[[ "$one" ]] && doit
elif [[ $1 = "-g2" ]]; then
one="$(gpick -p -s -o)"
two="$(gpick -p -s -o)"
doit () {
echo "$one > $two @ $res"
# make 2-gradient
convert -size "$res" gradient:"$one-$two" -channel RGB -separate -dither FloydSteinberg -colors 256 -combine -depth 8 ${walldir}/bg-2gradient.$ext || exit
# optionally add noise to the gradient (make sure that ".noise.png" is present in ${walldir}/
if [[ $noise = "true" ]];then
if [[ -f ${walldir}/.noise.png ]]; then
composite -alpha off -compose overlay ${walldir}/.noise.png ${walldir}/bg-2gradient.$ext /tmp/tmpout.$ext
mv /tmp/tmpout.$ext ${walldir}/bg-2gradient.$ext
fi
fi
# set wallpaper
if [[ $appl = "nitrogen" ]];then
nitrogen --save --set-centered ${walldir}/bg-2gradient.$ext
elif [[ $appl = "feh" ]];then
feh --bg-fill ${walldir}/bg-2gradient.$ext
fi
}
[[ "$one" && "$two" && "$res" ]] && doit
elif [[ $1 = "-g4" ]]; then
one="$(gpick -p -s -o)"
two="$(gpick -p -s -o)"
three="$(gpick -p -s -o)"
four="$(gpick -p -s -o)"
doit () {
echo "$one > $two > $three > $four @ $res"
# make 4-gradient
convert \( xc:"$one" xc:"$two" +append \) \
\( xc:"$three" xc:"$four" +append \) -append \
-size "$res" xc: +swap -fx 'v.p{i/(w-1),j/(h-1)}' \
-channel RGB -separate -dither FloydSteinberg -colors 256 -combine -depth 8 ${walldir}/bg-4gradient.$ext || exit
# optionally add noise to the gradient (make sure that ".noise.png" is present in ${walldir}/
if [[ $noise = "true" ]];then
if [[ -f ${walldir}/.noise.png ]]; then
composite -alpha off -compose overlay ${walldir}/.noise.png ${walldir}/bg-4gradient.$ext /tmp/tmpout.$ext
mv /tmp/tmpout.$ext ${walldir}/bg-4gradient.$ext
fi
fi
# set wallpaper
if [[ $appl = "nitrogen" ]];then
nitrogen --save --set-centered ${walldir}/bg-4gradient.$ext
elif [[ $appl = "feh" ]];then
feh --bg-fill ${walldir}/bg-4gradient.$ext
fi
}
[[ "$one" && "$two" && "$three" && "$four" && "$res" ]] && doit
else
echo "Failed to execute command, as NO option [-f or -g2 or -g4] was set..."
exit
fi
config file "
wallcolor.conf"
Code: Select all
####################################
# configuration for 'wallcolor' #
####################################
### set wallcolor working directory:
walldir="$HOME/wallcolor"
#walldir="$HOME/Pictures/wallcolor"
### set desired resolution:
res="$(xdpyinfo | awk '/dimensions/{print $2}')"
#res="1920x1200"
#res="1600x900"
#res="1280x800"
### set file type [png] or [jpg]:
ext="png"
#ext="jpg"
### add noise to generated wall
### (make sure that ".noise.png" is in 'walldir' directory)
noise="true"
#noise="false"
### select your wallpaper application; --> [feh] or [nitrogen]:
#appl="nitrogen"
appl="feh"