mabox-pipemenus/usr/bin/jgwallpaperchanger

150 lines
4.9 KiB
Plaintext
Raw Normal View History

2021-05-30 01:50:56 +02:00
#!/bin/bash
# jgwallpaperchanger - rotate desktop wallpaper every n-seconds,
#
CONFIG_DIR="$HOME/.config/mbwallpaper"
CONFIG_FILE="$CONFIG_DIR/mbwallpaper.conf"
WALLPAPERS_LIST="$CONFIG_DIR/wplist"
SCRNLOCKCFG="$HOME/.config/mbscreenlocker/mbscreenlocker.conf"
# 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}
# Directory with wallpapers
wallpaper_dir=/usr/share/backgrounds/
# Rotate time in seconds
interval=10
# Wallpaper setter program: nitrogen or feh
setter=nitrogen
EOF
fi
# read config variables from file
source <(grep = $CONFIG_FILE)
case $LANG in
pl*)
TITLE="Zmieniacz tapet i Blokada ekranu"
RANDWALL="Losowa tapeta"
CHOOSE="Wybierz tapetę..."
STARTS="Uruchom Pokaz slajdów <small>(<i>zatrzymany</i>)</small>"
STOPS="Zatrzymaj Pokaz slajdów <small>(<i>działający</i>)</small>"
CONF="Konfiguracja"
WALLDIR="Katalog z tapetami"
INTERVAL="Interwał"
SEC="sekund"
EDITCONF="Edytuj plik konfiguracyjny"
OPENDIR="Otwórz katalog z tapetami"
LOCKER="Blokada ekranu <small>(W+l)</small>"
TYPETO="wpisz hasło aby odblokować"
CACHE="Użyj aktualnej tapety"
EFFECT="Efekt (ustaw i wypróbuj)"
DIM="przyciemnienie"
BLUR="rozmycie"
DIMBLUR="przyciemnienie i rozmycie"
PIXEL="pikseloza"
DESK="Rozmyty pulpit"
;;
*)
TITLE="Wallpaper Changer &amp; ScreenLocker"
RANDWALL="Random Wallpaper"
CHOOSE="Choose Wallpaper..."
STARTS="Start Slideshow <small>(<i>stopped</i>)</small>"
STOPS="Stop Slideshow <small>(<i>running</i>)</small>"
CONF="Configuration"
WALLDIR="Wallpaper dir"
INTERVAL="Slideshow Interval"
SEC="seconds"
EDITCONF="Edit config file"
OPENDIR="Open wallpaper directory"
LOCKER="ScreenLocker <small>(W+l)</small>"
TYPETO="type password to unlock"
CACHE="Cache current wallpaper for ScreenLock"
EFFECT="Effect (set and run)"
DIM="dim"
BLUR="blur"
DIMBLUR="dim and blur"
PIXEL="pixel"
DESK="Blurred desktop"
;;
esac
. $HOME/.config/mabox/mabox.conf
me="jgwallpaperchanger -s"
#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'
out+=("^sep($TITLE)")
if ! pgrep mbwallpaper > /dev/null; then
out+=("$RANDWALL,mbwallpaper -o;$me")
out+=("$CHOOSE,mbwallpaper -c")
out+=("$STARTS,run_wallpaperslideshow;$me")
else
out+=("$STOPS,killall mbwallpaper;$me")
fi
out+=("^sep($CONF)")
#out+=("About Wallpaper changer,\"\"\"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'\"\"\"")
out+=("$WALLDIR: <small>[ <b>$wallpaper_dir</b> ]</small>,geany $CONFIG_FILE")
out+=("$INTERVAL [ <b>$interval</b> ] <small>($SEC)</small>,^checkout(interval)")
out+=("^sep()")
out+=("$EDITCONF ,geany $CONFIG_FILE")
out+=("$OPENDIR,pcmanfm -n $wallpaper_dir")
out+=("^sep($LOCKER)")
out+=("^sep(<i><small>$TYPETO</small></i>")
#out+=("^sep(Betterlockscreen)")
out+=("$CACHE,mbscreenlocker -c")
out+=("^sep(<i><small>$EFFECT</small></i>)")
out+=("$DIM,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=dim $SCRNLOCKCFG;mbscreenlocker")
out+=("$BLUR,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=blur $SCRNLOCKCFG;mbscreenlocker")
out+=("$DIMBLUR,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=dimblur $SCRNLOCKCFG;mbscreenlocker")
out+=("$PIXEL,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=pixel $SCRNLOCKCFG;mbscreenlocker")
out+=("^sep()")
out+=("$DESK,mb-setvar screenlocker=i3lock $SCRNLOCKCFG;mbscreenlocker")
out2+=("^tag(interval)")
for i in 10 30 60 120 300 600 1800 3600; do out2+=("$(printf "<tt> %4s</tt>,%s" "$i" "mb-setvar interval=${i} $CONFIG_FILE;$me")");done
### RUN
if [[ "$1" == "-s" ]]; then
. /usr/bin/pipemenu-standalone.cfg
. $HOME/.config/mabox/mabox.conf
MENU_PADDING_TOP=0
MENU_HALIGN="left"
MENU_VALIGN="center"
jgmenu_icon_size=0
JGWIDTH=40
menu_margin_x=${submenu_spacing:-0}
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
$(printf '%s\n' "${out[@]}")
$(printf '%s\n' "${out2[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
printf '%s\n' "${out[@]}"
if [[ $1 == "-r" ]]; then
case $LANG in
pl*) REMOVE="Usuń to menu z panelu";;
es*) REMOVE="Eliminar este menú del panel";;
*) REMOVE="Remove this menu from panel";;
esac
printf '%s\n' "^sep()"
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_jgwallpaperchanger=false;mb-jgtools places"
fi
printf '%s\n' "${out2[@]}"