wallpaper tools review

master
Daniel Napora 2024-09-16 00:44:33 +02:00
parent 96cf3eb18d
commit bca43bd80b
3 changed files with 60 additions and 52 deletions

View File

@ -2,55 +2,61 @@
## An Imagemagick Script To Generate Wallpapers.
## Based on https://github.com/adi1090x/canvas by Aditya Shakya (adi1090x)
## 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"
CONFIG_DIR="$HOME/.config/mabox/tools/"
CONFIG_FILE="$CONFIG_DIR/mb-canvas.cfg"
mkdir -p $CONFIG_DIR
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Imagetype extension avif or png
# avif (recommended) faster and much smaller size
extenstion=avif
# Show preview window, and then decide to set as wallpaper or not
# if no denerated wallpaper will be applied immadietely
# yes (recommended) or no
show_preview=yes
EOF
fi
source <(grep = $CONFIG_FILE)
extension=${extension:-avif}
show_preview=${show_preview:-yes}
case $LANG in
pl*)
IMWG="Generator Tapet"
PICKCOLOR="Pobierz kolor z ekranu"
PICKCOLORS="Pobierz kolory z ekranu"
PICKEDCOLOR="Pobrany kolor"
PICKNEXT="Pobierz nastepny"
PICKEDALL="Generuję tapetę..."
SETASWP="Ustawić jako tapetę?"
YES="Tak"
NO="Nie"
_IMWG="Generator Tapet"
_PICKCOLOR="Pobierz kolor z ekranu"
_PICKCOLORS="Pobierz kolory z ekranu"
_PICKEDCOLOR="Pobrany kolor"
_PICKNEXT="Pobierz nastepny"
_PICKEDALL="Generuję tapetę..."
_SETASWP="Ustawić jako tapetę?"
_YES="Tak"
_NO="Nie"
;;
*)
IMWG="ImageMagick Wallpaper Generator"
PICKCOLOR="Pick color from screen"
PICKCOLORS="Pick colors from screen"
PICKEDCOLOR="Picked color"
PICKNEXT="Please pick next..."
PICKEDALL="Generating Wallpaper..."
SETASWP="Set as Wallpaper?"
YES="Yes"
NO="No"
_IMWG="ImageMagick Wallpaper Generator"
_PICKCOLOR="Pick color from screen"
_PICKCOLORS="Pick colors from screen"
_PICKEDCOLOR="Picked color"
_PICKNEXT="Please pick next..."
_PICKEDALL="Generating Wallpaper..."
_SETASWP="Set as Wallpaper?"
_YES="Yes"
_NO="No"
;;
esac
DIR="$(xdg-user-dir PICTURES)/mb-canvas"
DIR="$(xdg-user-dir PICTURES)/imagick"
size="$(xrandr --current | grep '*' | uniq | awk '{print $1}')"
name="mb-canvas_$(date +%Y-%m-%d_%I-%M-%S).png"
name="imagick_$(date +%Y-%m-%d_%I-%M-%S).${extension}"
#SETTER="feh --bg-scale";
SETTER="nitrogen --set-scaled --save"
#picker_app="gpick -s -o --no-newline"
#picker_app="xcolor"
picker_app="gpick -pso 2>/dev/null"
if [[ ! -d "$DIR" ]]; then
@ -64,13 +70,15 @@ set_bg() {
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" \
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 \
--button="$_NO":1 --button="$_YES":2 \
ODP="$?"
[[ "$ODP" -eq "1" ]] && exit 0
if [[ "$ODP" -eq "1" ]]; then
rm "$DIR/$name" && exit 0
fi
if [[ "$ODP" -eq "2" ]]; then
$SETTER "$DIR/$name" && exit 0
fi
@ -84,37 +92,37 @@ set_bg() {
color_picker() {
if [[ "$SOLID" == "true" ]]; then
notify-send.sh "$IMWG" "$PICKCOLOR" -i mbcc --expire-time=120000
notify-send.sh "$_IMWG" "$_PICKCOLOR" -i mbcc --expire-time=12000
color=$($picker_app)
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=12000
color1=$($picker_app)
FNAME="/tmp/${color1:1:6}.png"
convert -size 100x100 xc:"$color1" "$FNAME"
notify-send.sh "$PICKEDCOLOR 1" "$color1\n $PICKNEXT..." --icon="$FNAME" --expire-time=120000
notify-send.sh "$_PICKEDCOLOR 1" "$color1\n $_PICKNEXT..." --icon="$FNAME" --expire-time=12000
color2=$($picker_app)
FNAME="/tmp/${color2:1:6}.png"
convert -size 100x100 xc:"$color2" "$FNAME"
notify-send.sh "$PICKEDCOLOR 2" "$color1\n $PICKEDALL" --icon="$FNAME" --expire-time=120000
notify-send.sh "$_PICKEDCOLOR 2" "$color1\n $_PICKEDALL" --icon="$FNAME" --expire-time=12000
color="$color1-$color2"
elif [[ "$BGRADIENT" == "true" ]]; then
notify-send.sh "$IMWG" "$PICKCOLORS: 4" -i mbcc --expire-time=120000
notify-send.sh "$_IMWG" "$_PICKCOLORS: 4" -i mbcc --expire-time=12000
color1=$($picker_app)
FNAME="/tmp/${color1:1:6}.png"
convert -size 100x100 xc:"$color1" "$FNAME"
notify-send.sh "$PICKEDCOLOR 1" "$color1\n $PICKNEXT..." --icon="$FNAME" --expire-time=120000
notify-send.sh "$_PICKEDCOLOR 1" "$color1\n $_PICKNEXT..." --icon="$FNAME" --expire-time=12000
color2=$($picker_app)
FNAME="/tmp/${color2:1:6}.png"
convert -size 100x100 xc:"$color2" "$FNAME"
notify-send.sh "$PICKEDCOLOR 2" "$color2\n $PICKNEXT..." --icon="$FNAME" --expire-time=120000
notify-send.sh "$_PICKEDCOLOR 2" "$color2\n $_PICKNEXT..." --icon="$FNAME" --expire-time=12000
color3=$($picker_app)
FNAME="/tmp/${color3:1:6}.png"
convert -size 100x100 xc:"$color3" "$FNAME"
notify-send.sh "$PICKEDCOLOR 3" "$color3\n $PICKNEXT..." --icon="$FNAME" --expire-time=120000
notify-send.sh "$_PICKEDCOLOR 3" "$color3\n $_PICKNEXT..." --icon="$FNAME" --expire-time=12000
color4=$($picker_app)
FNAME="/tmp/${color4:1:6}.png"
convert -size 100x100 xc:"$color4" "$FNAME"
notify-send.sh "$PICKEDCOLOR 4" "$color4\n $PICKEDALL" --icon="$FNAME" --expire-time=120000
notify-send.sh "$_PICKEDCOLOR 4" "$color4\n $_PICKEDALL" --icon="$FNAME" --expire-time=12000
fi
}
@ -133,7 +141,7 @@ solid() {
else
get_color
fi
convert -size "$size" canvas:"$color" "$DIR/$name"
magick convert -size "$size" canvas:"$color" "$DIR/$name"
set_bg
}
@ -150,7 +158,7 @@ linear_gradient() {
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
name="linear_$name"
convert -size "$size" -define gradient:angle="${angle:-0}" gradient:"$color" "$DIR/$name"
magick convert -size "$size" -define gradient:angle="${angle:-0}" gradient:"$color" "$DIR/$name"
set_bg
}
@ -173,7 +181,7 @@ radial_gradient() {
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)
fi
name="radial_$name"
convert -size "$size" -define gradient:extent="${shape:-maximum}" -define gradient:angle="${angle:-0}" radial-gradient:"$color" "$DIR/$name"
magick convert -size "$size" -define gradient:extent="${shape:-maximum}" -define gradient:angle="${angle:-0}" radial-gradient:"$color" "$DIR/$name"
set_bg
}
@ -192,7 +200,7 @@ twisted_gradient() {
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
name="twisted_$name"
convert -size "$size" gradient:"$color" -swirl "${twist:-150}" "$DIR/$name"
magick convert -size "$size" gradient:"$color" -swirl "${twist:-150}" "$DIR/$name"
set_bg
}
@ -221,9 +229,9 @@ bilinear_gradient() {
name="bilinear_$name"
if [[ $answer == "Smooth" ]] || [[ $answer == "S" ]]; then
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"
magick 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
convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -filter triangle -resize "$size"\! "$DIR/$name"
magick convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -filter triangle -resize "$size"\! "$DIR/$name"
fi
set_bg
}
@ -254,12 +262,12 @@ plasma() {
if [[ "$RANDOMIZE" != "true" ]]; then
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
convert -size "$size" plasma:fractal -swirl "${twist:-150}" "$DIR/$name"
magick convert -size "$size" plasma:fractal -swirl "${twist:-150}" "$DIR/$name"
else
if [[ "$RANDOMIZE" != "true" ]]; then
get_color
fi
convert -size "$size" plasma:"$color" "$DIR/$name"
magick convert -size "$size" plasma:"$color" "$DIR/$name"
fi
set_bg
}
@ -272,12 +280,12 @@ blurred_noise() {
else
{ echo; read -p ${ORANGE}"Enter the blur strength (maximum 30): "${BLUE} blur; }
fi
convert -size "100x56" xc: +noise Random "/tmp/noise.png"
convert "/tmp/noise.png" -virtual-pixel tile -blur 0x"${blur:-14}" -auto-level -resize "$size" "$DIR/$name"
magick convert -size "100x56" xc: +noise Random "/tmp/noise.png"
magick convert "/tmp/noise.png" -virtual-pixel tile -blur 0x"${blur:-14}" -auto-level -resize "$size" "$DIR/$name"
set_bg
}
## Generate random number lower than giver parameter
## Generate random number lower than given parameter
get_random_number() {
RNUM=$(( ($RANDOM % $1) + 1 ))
}

View File

@ -71,9 +71,9 @@ esac
SCREENSIZE=$(wmctrl -d |grep "*" | awk -F' ' '{print $4}')
W="${SCREENSIZE%x*}"
H="${SCREENSIZE#*x}"
FW=$((W/2))
FH=$((H/2))
X="40"
FW=$((W/4))
FH=$((H/4))
X=$((FW*3/2))
Y=$((H-FH-40))
notify-send.sh -t 12000 -i ~/.config/mabox/wpicon.png "$TITLE" "$TEXT"
feh -B "#4D4D4D" -N -x --scale-down -E ${FH} -y ${FW} -^ "Enter=select, Arrows=next/prev Esc=quit" -g ${FW}x${FH}+${X}+${Y} ${wallpaper_dir} -A "${command} '%f'"

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB