This commit is contained in:
Daniel Napora 2023-06-02 14:47:27 +02:00
parent d56c1c3230
commit 4c082c65e0

View File

@ -1,29 +1,35 @@
#!/bin/bash
# jgwallpaperchanger - dynamic menu (or submenu) to configure/set wallpapers
#
if [[ $1 == "-r" ]];then
me="${0##*/} -s"
else
me="${0##*/} ${1:--s}"
fi
#SLIDESHOW CONF
CONFIG_DIR="$HOME/.config/mbwallpaper"
CONFIG_FILE="$CONFIG_DIR/mbwallpaper.conf"
CONF_FILE="$CONFIG_DIR/mbwallpaper.conf"
WALLPAPERS_LIST="$CONFIG_DIR/wplist"
# Make config directory if not exist
mkdir -p $CONFIG_DIR
# If config file not exist create one with defaults
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
if [ ! -f $CONF_FILE ]; then
cat <<EOF > ${CONF_FILE}
# Directory with wallpapers
wallpaper_dir=/usr/share/backgrounds/
# Rotate time in seconds
interval=10
# Wallpaper setter program: nitrogen or feh
setter=nitrogen
# Tint2 panel executor button left click action
t2_button_lclick_action=choose
EOF
fi
# read config variables from file
source <(grep = $CONFIG_FILE)
source <(grep = $CONF_FILE)
COLORIZER_CONF="$HOME/.config/colorizer/colorizer.conf"
source ${COLORIZER_CONF}
@ -41,7 +47,11 @@ EOF
fi
lclick(){
if [[ "$t2_button_lclick_action" == "random" ]];then
mbwallpaper -o
else
pcmanwp
fi
}
@ -54,7 +64,7 @@ case $LANG in
RANDWALL="Losowa tapeta"
EDIT_WPDIRS="Edytuj katalogi z tapetami"
GENERATOR="Generuj (ImageMagick)..."
CHOOSE="Wybierz tapetę..."
CHOOSE_WP="Wybierz tapetę..."
SLIDESHOW="Pokaz slajdów"
STARTS="Uruchom Pokaz slajdów <small>(<i>zatrzymany</i>)</small>"
STOPS="Zatrzymaj Pokaz slajdów <small>(<i>działający - interwał: $interval sek.</i>)</small>"
@ -79,6 +89,16 @@ case $LANG in
NOC="<b>Nie</b> <i>(kliknij aby włączyć)</i>"
LIGHTBG="<b>light</b> - jasne tło"
DARKBG="<b>dark</b> - ciemne tło"
COLORIZER_HELP="Okno główne i Pomoc"
COLORIZER_ROOT="Colorizer rootmenu"
COLORIZER_OB="Moduł Openbox"
COLORIZER_MENU="Moduł Menu i Panele"
COLORIZER_CONKY="Moduł Conky"
B_LC_ACTION="Akcja przycisku (lewy klik)"
RAND="losuj"
CHOOSE="wybierz"
RANDOM_DESC="Ustaw losową tapetę"
CHOOSE_DESC="Wybierz tapetę (z menu kontekstowego)"
;;
*)
TITLE="Wallpaper Changer"
@ -87,7 +107,7 @@ case $LANG in
RANDWALL="Random Wallpaper"
EDIT_WPDIRS="Edit Wallpaper dirs"
GENERATOR="Generate (ImageMagick)..."
CHOOSE="Choose Wallpaper..."
CHOOSE_WP="Choose Wallpaper..."
SLIDESHOW="Slideshow"
STARTS="Start Slideshow <small>(<i>stopped</i>)</small>"
STOPS="Stop Slideshow <small>(<i>running - interval: $interval sec.</i>)</small>"
@ -112,16 +132,22 @@ case $LANG in
NOC="<b>No</b> <i>(click to enable)</i>"
LIGHTBG="with <b>light</b> background"
DARKBG="with <b>dark</b> background"
COLORIZER_HELP="Main Window and Help"
COLORIZER_ROOT="Colorizer rootmenu"
COLORIZER_OB="Openbox module"
COLORIZER_MENU="Menus/Panels module"
COLORIZER_CONKY="Conky module"
B_LC_ACTION="Button left click action"
RAND="random"
CHOOSE="choose"
RANDOM_DESC="Set random wallpaper"
CHOOSE_DESC="Choose wallpaper (from context menu)"
;;
esac
. $HOME/.config/mabox/mabox.conf
if [[ $1 == "-r" ]];then
me="${0##*/} -s"
else
me="${0##*/} ${1:--s}"
fi
help="\nBased on Mabox forum member Shwaybo <a href='https://forum.maboxlinux.org/t/chwp-desktop-wallpaper-changer/496'>idea</a>.\n\nchange wallpapers from a directory, never using the same picture twice until all the pictures have been shown, and rotating x number of seconds (configurable) before the next wallpaper change.\n"
@ -129,7 +155,7 @@ help="\nBased on Mabox forum member Shwaybo <a href='https://forum.maboxlinux.or
out+=("^sep($WALLPAPERS)")
if ! pgrep mbwallpaper > /dev/null; then
#out+=("$NITROGEN,nitrogen")
out+=("<big>󰉔</big> $CHOOSE,pcmanwp")
out+=("<big>󰉔</big> $CHOOSE_WP,pcmanwp")
out+=("<big></big> $RANDWALL,mbwallpaper -o;$me")
#out+=("$GENERATOR,^pipe(jgwallpapergenerate)")
out+=("<big>󰧸</big> $SLIDESHOW,^checkout(sshow)")
@ -145,15 +171,15 @@ fi
out1+=("^tag(sshow)")
out1+=("^sep($SLIDESHOW)")
out1+=("$STARTS,run_wallpaperslideshow;$me")
out1+=("\"\"\"$WALLDIR: <small>[ <b>$wallpaper_dir</b> ]</small>\"\"\",xdg-open $CONFIG_FILE")
out1+=("\"\"\"$WALLDIR: <small>[ <b>$wallpaper_dir</b> ]</small>\"\"\",xdg-open $CONF_FILE")
out1+=("$INTERVAL [ <b>$interval</b> ] <small>($SEC)</small>,^checkout(interval)")
out1+=("^sep()")
out1+=("<big></big> $EDITCONF ,xdg-open $CONFIG_FILE")
out1+=("<big></big> $EDITCONF ,xdg-open $CONF_FILE")
out1+=("<big></big> $OPENDIR,pcmanfm -n $wallpaper_dir")
out1+=("About Slideshow,\"\"\"notify-send.sh -u critical -i mbcc 'Wallpaper Changer - rotate desktop wallpaper every n-seconds' \"$help\" -o 'Edit configuration file:geany ~/.config/mbwallpaper/mbwallpaper.conf'\"\"\"")
out2+=("^tag(interval)")
for i in 3 5 10 30 60 120 300 600 1800 3600; do out2+=("$(printf "<tt> %4s</tt>,%s" "$i" "mb-setvar interval=${i} $CONFIG_FILE;$me")");done
for i in 3 5 10 30 60 120 300 600 1800 3600; do out2+=("$(printf "<tt> %4s</tt>,%s" "$i" "mb-setvar interval=${i} $CONF_FILE;$me")");done
# COLORIZER_CONF SUBMENU
@ -207,13 +233,20 @@ case "$1" in
-c) out+=(" ⮜ Colorizer,colorizer -s");;
-u) out+=(" ⮜ Settings menu,mb-jgtools settings");;
ipc) POSITION_MODE=${1:-fixed}
out+=("^sep(COLORIZER)")
out+=("COLORIZER_HELP,ycolorizer")
out+=("COLORIZER_ROOT,colorizer -s")
out+=("^sep(Colorizer)")
out+=("$COLORIZER_HELP,ycolorizer")
out+=("$COLORIZER_ROOT,colorizer -s")
out+=("^sep()")
out+=("COLORIZER_OB,colorizer-ob -s")
out+=("COLORIZER_MENU,colorizer-menus -s")
out+=("COLORIZER_CONKY,colorizer-conky -s")
out+=("$COLORIZER_OB,colorizer-ob -s")
out+=("$COLORIZER_MENU,colorizer-menus -s")
out+=("$COLORIZER_CONKY,colorizer-conky -s")
out+=("^sep()")
[[ "$t2_button_lclick_action" == "random" ]] && out+=("$B_LC_ACTION: <b>[ $RAND ]</b>,^checkout(laction)") || out+=("$B_LC_ACTION: <b>[ $CHOOSE ]</b>,^checkout(laction)")
out2+=("^tag(laction)")
out2+=("^sep(Panel button left click action)")
out2+=("$CHOOSE_DESC,mb-setvar t2_button_lclick_action=choose $CONF_FILE;$me")
out2+=("$RANDOM_DESC,mb-setvar t2_button_lclick_action=random $CONF_FILE;$me")
;;
esac