about and wallpaper generator

master
Daniel Napora 2022-02-18 20:35:11 +01:00
parent 20c2c19cc0
commit 905fb25f78
3 changed files with 406 additions and 0 deletions

View File

@ -0,0 +1,7 @@
[Desktop Entry]
Name=About Mabox Linux
Comment=About Mabox Linux
Exec=about-mabox
Icon=mbcc
Type=Application
Categories=System;

13
bin/about-mabox 100755
View File

@ -0,0 +1,13 @@
#!/bin/bash
yad --title="About Mabox" --window-icon=mbcc \
--about \
--pname="Mabox Linux" \
--pversion="$(lsb_release -rs) <i>$(lsb_release -cs)</i>" \
--image=mbcc \
--comments="Fast and Lightweight, ready to use Openbox Desktop" \
--copyright="Copyright 2016-2022, Daniel Napora <napcok@gmail.com>" \
--license=GPL3 \
--website="https://maboxlinux.org" \
--website-label=maboxlinux.org \
--authors="Daniel Napora <napcok@gmail.com>"

386
bin/mb-canvas 100755
View File

@ -0,0 +1,386 @@
#!/bin/bash
## 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
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ę..."
;;
*)
IMWG="ImageMagick Wallpaper Generator"
PICKCOLOR="Pick color from screen"
PICKCOLORS="Pick colors from screen"
PICKEDCOLOR="Picked color"
PICKNEXT="Please pick next..."
PICKEDALL="Generating Wallpaper..."
;;
esac
DIR="$(xdg-user-dir PICTURES)/mb-canvas"
size="$(xrandr --current | grep '*' | uniq | awk '{print $1}')"
name="mb-canvas_$(date +%Y-%m-%d_%I-%M-%S).png"
#SETTER="feh --bg-scale";
SETTER="nitrogen --set-scaled --save"
#picker_app="gpick -s -o --no-newline"
picker_app="xcolor"
if [[ ! -d "$DIR" ]]; then
mkdir -p "$DIR"
fi
set_bg() {
$SETTER "$DIR/$name"
}
## Pick the colors
color_picker() {
if [[ "$SOLID" == "true" ]]; then
notify-send.sh "$IMWG" "$PICKCOLOR" -i mbcc --expire-time=120000
color=$($picker_app)
elif [[ "$GRADIENT" == "true" ]] || [[ "$RGRADIENT" == "true" ]] || [[ "$TGRADIENT" == "true" ]]; then
notify-send.sh "$IMWG" "$PICKCOLORS: 2" -i mbcc --expire-time=120000
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
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
color="$color1-$color2"
elif [[ "$BGRADIENT" == "true" ]]; then
notify-send.sh "$IMWG" "$PICKCOLORS: 4" -i mbcc --expire-time=120000
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
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
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
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
fi
}
## Get colors
get_color() {
while true; do
color_picker
break
done
}
## Generate a solid color wallpaper
solid() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color="$RCOLOR"
else
get_color
fi
convert -size "$size" canvas:"$color" "$DIR/$name"
set_bg
}
## Generate a linear gradient wallpaper
linear_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color="$RCOLOR"
get_random_number "360"
angle="$RNUM"
else
get_color
#{ echo; read -p ${ORANGE}"Enter the rotation angle (default is 0): "${BLUE} angle; }
fi
name="linear_$name"
convert -size "$size" -define gradient:angle="${angle:-0}" gradient:"$color" "$DIR/$name"
set_bg
}
## Generate a radial gradient wallpaper
radial_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color1="$RCOLOR"
get_random_color
color="$color1-$RCOLOR"
get_random_number "360"
angle="$RNUM"
getRandomShape
shape="$RSHAPE"
else
get_color
{ echo; read -p ${ORANGE}"Shape? [ 1.diagonal | 2.ellipse | 3.maximum | 4.minimum ] (1/2/3/4): "${BLUE}; }
if [[ $REPLY == "1" ]]; then
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
name="radial_$name"
convert -size "$size" -define gradient:extent="${shape:-maximum}" -define gradient:angle="${angle:-0}" radial-gradient:"$color" "$DIR/$name"
set_bg
}
## Generate a twisted gradient wallpaper
twisted_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color1="$RCOLOR"
get_random_color
color="$color1-$RCOLOR"
get_random_number "500"
twist="$RNUM"
else
get_color
{ echo; read -p ${ORANGE}"Enter the twisting amount (maximum 500): "${BLUE} twist; }
fi
name="twisted_$name"
convert -size "$size" gradient:"$color" -swirl "${twist:-150}" "$DIR/$name"
set_bg
}
## Generate a 4 point gradient wallpaper
bilinear_gradient() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_color
color1="$RCOLOR"
get_random_color
color2="$RCOLOR"
get_random_color
color3="$RCOLOR"
get_random_color
color4="$RCOLOR"
get_random_number "2"
if [[ "$RNUM" == "1" ]]; then
answer="s"
else
answer="r"
fi
else
get_color
{ echo; read -p ${ORANGE}"Smooth or Regular? (s/r): "${BLUE} answer; }
fi
name="bilinear_$name"
if [[ $answer == "s" ]] || [[ $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"
else
convert \( xc:"$color1" xc:"$color2" +append \) \( xc:"$color3" xc:"$color4" +append \) -append -filter triangle -resize "$size"\! "$DIR/$name"
fi
set_bg
}
## Generate a plasma wallpaper
plasma() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_number "3"
if [[ "$RNUM" == "1" ]]; then
answer="r"
elif [[ "$RNUM" == "2" ]]; then
answer="t"
get_random_number "500"
twist="$RNUM"
else
answer="c"
get_random_color
color="$RCOLOR"
fi
else
{ echo; read -p ${ORANGE}"Random, Twisted or Custom colors? (r/t/c): "${BLUE} answer; }
fi
name="plasma_$name"
if [[ $answer == "r" ]] || [[ $answer == "R" ]]; then
convert -size "$size" plasma: "$DIR/$name"
elif [[ $answer == "t" ]] || [[ $answer == "T" ]]; then
if [[ "$RANDOMIZE" != "true" ]]; then
{ echo; read -p ${ORANGE}"Enter the twisting amount (maximum 500): "${BLUE} twist; }
fi
convert -size "$size" plasma:fractal -swirl "${twist:-150}" "$DIR/$name"
else
if [[ "$RANDOMIZE" != "true" ]]; then
{ echo; read -p ${ORANGE}"Enter the colors name or hex (format: color1-color2): "${GREEN} color; }
fi
convert -size "$size" plasma:"$color" "$DIR/$name"
fi
set_bg
}
## Generate a random, multi-colored blurred/gradient wallpaper
blurred_noise() {
if [[ "$RANDOMIZE" == "true" ]]; then
get_random_number "30"
blur="$RNUM"
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"
set_bg
}
## Generate random number lower than giver parameter
get_random_number() {
RNUM=$(( ($RANDOM % $1) + 1 ))
}
## Generate random color
get_random_color() {
RCOLOR="#"
for i in 1 2 3 4 5 6
do
get_random_number "16"
case $RNUM in
"1") NEXTDIGIT="1";;
"2") NEXTDIGIT="2";;
"3") NEXTDIGIT="3";;
"4") NEXTDIGIT="4";;
"5") NEXTDIGIT="5";;
"6") NEXTDIGIT="6";;
"7") NEXTDIGIT="7";;
"8") NEXTDIGIT="8";;
"9") NEXTDIGIT="9";;
"10") NEXTDIGIT="A";;
"11") NEXTDIGIT="B";;
"12") NEXTDIGIT="C";;
"13") NEXTDIGIT="D";;
"14") NEXTDIGIT="E";;
"15") NEXTDIGIT="F";;
"16") NEXTDIGIT="0";;
esac
RCOLOR="$RCOLOR$NEXTDIGIT"
done
}
## Generate random shape option
getRandomShape() {
get_random_number "4"
case $RNUM in
"1") RSHAPE="diagonal";;
"2") RSHAPE="ellipse";;
"3") RSHAPE="maximum";;
"4") RSHAPE="minimum";;
esac
}
## Generate random wallpaper
randomize() {
get_random_number "7"
case $RNUM in
"1") solid;;
"2") linear_gradient;;
"3") radial_gradient;;
"4") twisted_gradient;;
"5") bilinear_gradient;;
"6") plasma;;
"7") blurred_noise;;
esac
}
## 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 -- "$@")
eval set -- "$options"
while true; do
case "$1" in
-S|--size)
shift;
size=$1
;;
-s|--solid)
SOLID="true"
COLOR=$1
;;
-l|--linear)
GRADIENT="true"
;;
-r|--radial)
RGRADIENT="true"
;;
-t|--twisted)
TGRADIENT="true"
;;
-b|--bilinear)
BGRADIENT="true"
;;
-p|--plasma)
PLASMA="true"
;;
-B|--blurred)
NOISE="true"
;;
-a|--autobg)
AUTOBG="true"
;;
-R|--randomize)
RANDOMIZE="true"
;;
-n|--no-preview)
NOFEH="true"
;;
-h|--help)
usage
exit
;;
--)
shift
break
;;
esac
shift
done
## Main Execution
Prerequisite
if [[ "$SOLID" == "true" ]]; then
solid
elif [[ "$GRADIENT" == "true" ]]; then
linear_gradient
elif [[ "$RGRADIENT" == "true" ]]; then
radial_gradient
elif [[ "$TGRADIENT" == "true" ]]; then
twisted_gradient
elif [[ "$BGRADIENT" == "true" ]]; then
bilinear_gradient
elif [[ "$PLASMA" == "true" ]]; then
plasma
elif [[ "$NOISE" == "true" ]]; then
blurred_noise
elif [[ "$RANDOMIZE" == "true" ]]; then
randomize
else
usage
fi