wallpaper generator
parent
905fb25f78
commit
56d86d515b
|
@ -2,7 +2,19 @@
|
||||||
## An Imagemagick Script To Generate Wallpapers.
|
## An Imagemagick Script To Generate Wallpapers.
|
||||||
## Based on https://github.com/adi1090x/canvas by Aditya Shakya (adi1090x)
|
## Based on https://github.com/adi1090x/canvas by Aditya Shakya (adi1090x)
|
||||||
## Modified by Daniel Napora for Mabox Linux to run from menu
|
## Modified by Daniel Napora for Mabox Linux to run from menu
|
||||||
|
# TODO: add missing options to some effects
|
||||||
|
# TODO: add ability to pick and use 4 predefined colors
|
||||||
|
# TODO: choose picker: xcolor or gpick
|
||||||
|
|
||||||
|
CONFIG_DIR="$HOME/.config/mbxutils/imgw"
|
||||||
|
CONFIG_FILE="$CONFIG_DIR/imgw.cfg"
|
||||||
|
mkdir -p $CONFIG_DIR
|
||||||
|
if [ ! -f $CONFIG_FILE ]; then
|
||||||
|
cat <<EOF > ${CONFIG_FILE}
|
||||||
|
show_preview=yes
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
source <(grep = $CONFIG_FILE)
|
||||||
|
|
||||||
|
|
||||||
case $LANG in
|
case $LANG in
|
||||||
|
@ -13,6 +25,9 @@ case $LANG in
|
||||||
PICKEDCOLOR="Pobrany kolor"
|
PICKEDCOLOR="Pobrany kolor"
|
||||||
PICKNEXT="Pobierz nastepny"
|
PICKNEXT="Pobierz nastepny"
|
||||||
PICKEDALL="Generuję tapetę..."
|
PICKEDALL="Generuję tapetę..."
|
||||||
|
SETASWP="Ustawić jako tapetę?"
|
||||||
|
YES="Tak"
|
||||||
|
NO="Nie"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
IMWG="ImageMagick Wallpaper Generator"
|
IMWG="ImageMagick Wallpaper Generator"
|
||||||
|
@ -21,6 +36,9 @@ case $LANG in
|
||||||
PICKEDCOLOR="Picked color"
|
PICKEDCOLOR="Picked color"
|
||||||
PICKNEXT="Please pick next..."
|
PICKNEXT="Please pick next..."
|
||||||
PICKEDALL="Generating Wallpaper..."
|
PICKEDALL="Generating Wallpaper..."
|
||||||
|
SETASWP="Set as Wallpaper?"
|
||||||
|
YES="Yes"
|
||||||
|
NO="No"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -39,7 +57,25 @@ if [[ ! -d "$DIR" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set_bg() {
|
set_bg() {
|
||||||
|
if [[ "$show_preview" == "yes" ]];then
|
||||||
|
X="${size%x*}"
|
||||||
|
Y="${size#*x}"
|
||||||
|
P_X=$((X/4))
|
||||||
|
P_Y=$((Y/4+30))
|
||||||
|
|
||||||
|
yad --title="$SETASWP" --window-icon=mbcc --borders=0 --geometry="${P_X}x${P_Y}+200+30" \
|
||||||
|
--picture --size=fit --filename="$DIR/$name" \
|
||||||
|
--button="$NO":1 --button="$YES":2 \
|
||||||
|
|
||||||
|
ODP="$?"
|
||||||
|
|
||||||
|
[[ "$ODP" -eq "1" ]] && exit 0
|
||||||
|
if [[ "$ODP" -eq "2" ]]; then
|
||||||
|
$SETTER "$DIR/$name" && exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
$SETTER "$DIR/$name"
|
$SETTER "$DIR/$name"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +85,7 @@ color_picker() {
|
||||||
if [[ "$SOLID" == "true" ]]; then
|
if [[ "$SOLID" == "true" ]]; then
|
||||||
notify-send.sh "$IMWG" "$PICKCOLOR" -i mbcc --expire-time=120000
|
notify-send.sh "$IMWG" "$PICKCOLOR" -i mbcc --expire-time=120000
|
||||||
color=$($picker_app)
|
color=$($picker_app)
|
||||||
elif [[ "$GRADIENT" == "true" ]] || [[ "$RGRADIENT" == "true" ]] || [[ "$TGRADIENT" == "true" ]]; then
|
elif [[ "$GRADIENT" == "true" ]] || [[ "$RGRADIENT" == "true" ]] || [[ "$TGRADIENT" == "true" ]] || "$PLASMA" == "true" ]]; then
|
||||||
notify-send.sh "$IMWG" "$PICKCOLORS: 2" -i mbcc --expire-time=120000
|
notify-send.sh "$IMWG" "$PICKCOLORS: 2" -i mbcc --expire-time=120000
|
||||||
color1=$($picker_app)
|
color1=$($picker_app)
|
||||||
FNAME="/tmp/${color1:1:6}.png"
|
FNAME="/tmp/${color1:1:6}.png"
|
||||||
|
@ -110,7 +146,7 @@ linear_gradient() {
|
||||||
angle="$RNUM"
|
angle="$RNUM"
|
||||||
else
|
else
|
||||||
get_color
|
get_color
|
||||||
#{ echo; read -p ${ORANGE}"Enter the rotation angle (default is 0): "${BLUE} angle; }
|
angle=$(yad --center --window-icon=mbcc --title="Linear gradient" --text="\tRotation angle (default is 0):" --width=400 --scale --min-value=0 --max-value=360 --step=45 --enforce-step --inc-buttons)
|
||||||
fi
|
fi
|
||||||
name="linear_$name"
|
name="linear_$name"
|
||||||
convert -size "$size" -define gradient:angle="${angle:-0}" gradient:"$color" "$DIR/$name"
|
convert -size "$size" -define gradient:angle="${angle:-0}" gradient:"$color" "$DIR/$name"
|
||||||
|
@ -132,17 +168,8 @@ radial_gradient() {
|
||||||
shape="$RSHAPE"
|
shape="$RSHAPE"
|
||||||
else
|
else
|
||||||
get_color
|
get_color
|
||||||
{ echo; read -p ${ORANGE}"Shape? [ 1.diagonal | 2.ellipse | 3.maximum | 4.minimum ] (1/2/3/4): "${BLUE}; }
|
shape=$(yad --center --window-icon=mbcc --title='Choose Shape' --width=180 --height=145 --button=Ok:0 --list --no-headers --column=Shape diagonal ellipse maximum minimum | tr -d '|')
|
||||||
if [[ $REPLY == "1" ]]; then
|
angle=$(yad --center --window-icon=mbcc --title="Radial gradient" --text="\tRotation angle:" --width=400 --scale --min-value=0 --max-value=360 --step=45 --enforce-step --inc-buttons)
|
||||||
shape='diagonal'
|
|
||||||
elif [[ $REPLY == "2" ]]; then
|
|
||||||
shape='ellipse'
|
|
||||||
elif [[ $REPLY == "3" ]]; then
|
|
||||||
shape='maximum'
|
|
||||||
elif [[ $REPLY == "4" ]]; then
|
|
||||||
shape='minimum'
|
|
||||||
fi
|
|
||||||
{ echo; read -p ${ORANGE}"Enter the rotation angle (default is 0): "${BLUE} angle; }
|
|
||||||
fi
|
fi
|
||||||
name="radial_$name"
|
name="radial_$name"
|
||||||
convert -size "$size" -define gradient:extent="${shape:-maximum}" -define gradient:angle="${angle:-0}" radial-gradient:"$color" "$DIR/$name"
|
convert -size "$size" -define gradient:extent="${shape:-maximum}" -define gradient:angle="${angle:-0}" radial-gradient:"$color" "$DIR/$name"
|
||||||
|
@ -161,7 +188,7 @@ twisted_gradient() {
|
||||||
twist="$RNUM"
|
twist="$RNUM"
|
||||||
else
|
else
|
||||||
get_color
|
get_color
|
||||||
{ echo; read -p ${ORANGE}"Enter the twisting amount (maximum 500): "${BLUE} twist; }
|
twist=$(yad --center --window-icon=mbcc --title="Radial gradient" --text="\tTwisting amount (default is 150):" --width=400 --scale --value=150 --min-value=0 --max-value=500 --step=20 --inc-buttons)
|
||||||
fi
|
fi
|
||||||
name="twisted_$name"
|
name="twisted_$name"
|
||||||
convert -size "$size" gradient:"$color" -swirl "${twist:-150}" "$DIR/$name"
|
convert -size "$size" gradient:"$color" -swirl "${twist:-150}" "$DIR/$name"
|
||||||
|
@ -182,17 +209,17 @@ bilinear_gradient() {
|
||||||
|
|
||||||
get_random_number "2"
|
get_random_number "2"
|
||||||
if [[ "$RNUM" == "1" ]]; then
|
if [[ "$RNUM" == "1" ]]; then
|
||||||
answer="s"
|
answer="Smooth"
|
||||||
else
|
else
|
||||||
answer="r"
|
answer="Regular"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
get_color
|
get_color
|
||||||
{ echo; read -p ${ORANGE}"Smooth or Regular? (s/r): "${BLUE} answer; }
|
answer=$(yad --title='Choose Style' --width=220 --height=120 --button=Ok:0 --list --no-headers --column=Style Smooth Regular | tr -d '|')
|
||||||
fi
|
fi
|
||||||
name="bilinear_$name"
|
name="bilinear_$name"
|
||||||
if [[ $answer == "s" ]] || [[ $answer == "S" ]]; then
|
if [[ $answer == "Smooth" ]] || [[ $answer == "S" ]]; then
|
||||||
{ echo; echo -n ${CYAN}"Please wait... "; }
|
|
||||||
convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -size "$size" xc: +swap -fx 'v.p{i/(w-1),j/(h-1)}' "$DIR/$name"
|
convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -size "$size" xc: +swap -fx 'v.p{i/(w-1),j/(h-1)}' "$DIR/$name"
|
||||||
else
|
else
|
||||||
convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -filter triangle -resize "$size"\! "$DIR/$name"
|
convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -filter triangle -resize "$size"\! "$DIR/$name"
|
||||||
|
@ -206,9 +233,9 @@ plasma() {
|
||||||
get_random_number "3"
|
get_random_number "3"
|
||||||
|
|
||||||
if [[ "$RNUM" == "1" ]]; then
|
if [[ "$RNUM" == "1" ]]; then
|
||||||
answer="r"
|
answer="Random"
|
||||||
elif [[ "$RNUM" == "2" ]]; then
|
elif [[ "$RNUM" == "2" ]]; then
|
||||||
answer="t"
|
answer="Twisted"
|
||||||
get_random_number "500"
|
get_random_number "500"
|
||||||
twist="$RNUM"
|
twist="$RNUM"
|
||||||
else
|
else
|
||||||
|
@ -217,19 +244,19 @@ plasma() {
|
||||||
color="$RCOLOR"
|
color="$RCOLOR"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
{ echo; read -p ${ORANGE}"Random, Twisted or Custom colors? (r/t/c): "${BLUE} answer; }
|
answer=$(yad --title='Choose Style' --width=190 --height=150 --button=Ok:0 --list --no-headers --column=Style Random Twisted 'Custom colors' | tr -d '|')
|
||||||
fi
|
fi
|
||||||
name="plasma_$name"
|
name="plasma_$name"
|
||||||
if [[ $answer == "r" ]] || [[ $answer == "R" ]]; then
|
if [[ $answer == "r" ]] || [[ $answer == "Random" ]]; then
|
||||||
convert -size "$size" plasma: "$DIR/$name"
|
convert -size "$size" plasma: "$DIR/$name"
|
||||||
elif [[ $answer == "t" ]] || [[ $answer == "T" ]]; then
|
elif [[ $answer == "t" ]] || [[ $answer == "Twisted" ]]; then
|
||||||
if [[ "$RANDOMIZE" != "true" ]]; then
|
if [[ "$RANDOMIZE" != "true" ]]; then
|
||||||
{ echo; read -p ${ORANGE}"Enter the twisting amount (maximum 500): "${BLUE} twist; }
|
twist=$(yad --center --window-icon=mbcc --title="Plasma" --text="\tTwisting amount (default is 150):" --width=400 --scale --value=150 --min-value=0 --max-value=500 --step=20 --inc-buttons)
|
||||||
fi
|
fi
|
||||||
convert -size "$size" plasma:fractal -swirl "${twist:-150}" "$DIR/$name"
|
convert -size "$size" plasma:fractal -swirl "${twist:-150}" "$DIR/$name"
|
||||||
else
|
else
|
||||||
if [[ "$RANDOMIZE" != "true" ]]; then
|
if [[ "$RANDOMIZE" != "true" ]]; then
|
||||||
{ echo; read -p ${ORANGE}"Enter the colors name or hex (format: color1-color2): "${GREEN} color; }
|
get_color
|
||||||
fi
|
fi
|
||||||
convert -size "$size" plasma:"$color" "$DIR/$name"
|
convert -size "$size" plasma:"$color" "$DIR/$name"
|
||||||
fi
|
fi
|
||||||
|
@ -309,7 +336,7 @@ randomize() {
|
||||||
|
|
||||||
|
|
||||||
## Parse the arguments
|
## Parse the arguments
|
||||||
options=$(getopt -o S:,s,l,r,t,b,p,B,h,a,R,n --long size:,solid,linear,radial,twisted,bilinear,plasma,blurred,help,autobg,randomize,no-preview -- "$@")
|
options=$(getopt -o S:,s,l,r,t,b,p,B,h,a,R --long size:,solid,linear,radial,twisted,bilinear,plasma,blurred,help,autobg,randomize -- "$@")
|
||||||
eval set -- "$options"
|
eval set -- "$options"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
@ -346,9 +373,6 @@ while true; do
|
||||||
-R|--randomize)
|
-R|--randomize)
|
||||||
RANDOMIZE="true"
|
RANDOMIZE="true"
|
||||||
;;
|
;;
|
||||||
-n|--no-preview)
|
|
||||||
NOFEH="true"
|
|
||||||
;;
|
|
||||||
-h|--help)
|
-h|--help)
|
||||||
usage
|
usage
|
||||||
exit
|
exit
|
||||||
|
@ -363,7 +387,6 @@ done
|
||||||
|
|
||||||
## Main Execution
|
## Main Execution
|
||||||
|
|
||||||
Prerequisite
|
|
||||||
|
|
||||||
if [[ "$SOLID" == "true" ]]; then
|
if [[ "$SOLID" == "true" ]]; then
|
||||||
solid
|
solid
|
||||||
|
|
Loading…
Reference in New Issue