#!/bin/bash # jgwallpaperchanger - submenu to configure wallpapers # CONFIG_DIR="$HOME/.config/mbwallpaper" CONFIG_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 < ${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" NITROGEN="Nitrogen" WALLPAPERS="Tapety" RANDWALL="Losowa tapeta" GENERATOR="Generuj (ImageMagick)..." CHOOSE="Wybierz tapetę..." SLIDESHOW="Pokaz slajdów" STARTS="Uruchom Pokaz slajdów (zatrzymany)" STOPS="Zatrzymaj Pokaz slajdów (działający)" CONF="Konfiguracja" WALLDIR="Katalog z tapetami" INTERVAL="Interwał slajdów" SEC="sekund" EDITCONF="Edytuj plik konfiguracyjny" OPENDIR="Otwórz katalog z tapetami" LEFTPANEL="Lewy panel" ;; *) TITLE="Wallpaper Changer" NITROGEN="Nitrogen" WALLPAPERS="Wallpapers" RANDWALL="Random Wallpaper" GENERATOR="Generate (ImageMagick)..." CHOOSE="Choose Wallpaper..." SLIDESHOW="Slideshow" STARTS="Start Slideshow (stopped)" STOPS="Stop Slideshow (running)" CONF="Configuration" WALLDIR="Images dir" INTERVAL="Slideshow Interval" SEC="seconds" EDITCONF="Edit config file" OPENDIR="Open wallpaper directory" LEFTPANEL="Left panel" ;; 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 idea.\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)") out+=("^sep($WALLPAPERS)") if ! pgrep mbwallpaper > /dev/null; then #out+=("$NITROGEN,nitrogen") out+=("$RANDWALL,mbwallpaper -o;$me") out+=("$CHOOSE,pcmanwp") out+=("$GENERATOR,^pipe(jgwallpapergenerate)") out+=("^sep($SLIDESHOW)") out+=("$STARTS,run_wallpaperslideshow;$me") else out+=("$STOPS,killall mbwallpaper;$me") fi out+=("^sep()") out+=("\"\"\"$WALLDIR: [ $wallpaper_dir ]\"\"\",xdg-open $CONFIG_FILE") out+=("$INTERVAL [ $interval ] ($SEC),^checkout(interval)") out+=("^sep()") out+=("$EDITCONF ,xdg-open $CONFIG_FILE") out+=("$OPENDIR,pcmanfm -n $wallpaper_dir") out+=("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 " %4s,%s" "$i" "mb-setvar interval=${i} $CONFIG_FILE;$me")");done ### RUN if [[ $1 == "-s" || $1 == "-c" || $1 == "-u" ]]; then . /usr/share/mb-jgtools/pipemenu-standalone.cfg out+=("^sep()") case "$1" in -s) out+=(" ⮜ $LEFTPANEL,mb-jgtools places");; -c) out+=(" ⮜ Colorizer,colorizer -s");; -u) out+=(" ⮜ Settings menu,mb-jgtools settings");; esac . $HOME/.config/mabox/mabox.conf if [[ $panels_heightpos == "top" ]]; then MENU_VALIGN="top" MENU_MARGIN_Y=${panels_topmargin:-0} elif [[ $panels_heightpos == "bottom" ]]; then MENU_VALIGN="bottom" MENU_MARGIN_Y=${panels_topmargin:-0} else MENU_VALIGN="center" fi MENU_PADDING_TOP=${jgtools_padding:-0} MENU_HALIGN="left" 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 JGWIDTH=$((jgtools_padding + 278 + jgtools_padding)) MENU_PADDING_TOP=$((jgtools_padding + 158)) #WALLPAPER read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) THUMBDIR="$HOME/.cache/colorizer/thumbs" mkdir -p ${THUMBDIR} NAME=${WALLPATH////_} if [[ "${NAME}" =~ ^_home_.* ]]; then n=${#HOME} ((n++)) NAME=${NAME:${n}} fi THUMB="${THUMBDIR}/${NAME}.png" if [[ ! -f "$THUMB" ]] then convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} fi #TEMP POSITION: MENU_VALIGN="top" MENU_MARGIN_Y="60" mkconfigfile cat < ${MENU_ITEMS} @icon,,$((jgtools_padding + 4)),$((jgtools_padding + 4)),270,150,4,left,top,,,${THUMB} $(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' "$REMOVE,mb-setvar places_jgwallpaperchanger=false;mb-jgtools places" fi printf '%s\n' "${out2[@]}"