#!/bin/bash # jgwallpaperchanger - dynamic menu (or submenu) to configure/set wallpapers # #SLIDESHOW CONF 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) COLORIZER_CONF="$HOME/.config/colorizer/colorizer.conf" source ${COLORIZER_CONF} #WP_DIRS CNF_FILE="$HOME/.config/mabox/wallp_dirs.conf" if [ ! -f $CNF_FILE ]; then cat < ${CNF_FILE} # User wallpapers directories - one per line # Used by "Choose wallpaper" PCmanFM wrapper # Set wallpapers using context (right click) menu in file manager ~/wallpapers/ EOF fi lclick(){ pcmanwp } main(){ case $LANG in pl*) TITLE="Zmieniacz tapet" NITROGEN="Nitrogen" WALLPAPERS="Tapety" RANDWALL="Losowa tapeta" EDIT_WPDIRS="Edytuj katalogi z tapetami" GENERATOR="Generuj (ImageMagick)..." CHOOSE="Wybierz tapetę..." SLIDESHOW="Pokaz slajdów" STARTS="Uruchom Pokaz slajdów (zatrzymany)" STOPS="Zatrzymaj Pokaz slajdów (działający - interwał: $interval sek.)" 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" OBTHEME="Motyw Openbox" MENUPANELS="Menu i Panele" AUTOGEN_THEMES="Autogenerowanie motywów?" GENERATETHEMES="Generować motywy po zmianie tapety?" GENOB="Pokolorować Dekoracje Okien?" GENMENU="Pokolorować menu i panele?" GENCONKY="Pokolorować Conky?" GENPYRADIO="Pokolorować PyRadio?" YES="Tak" NO="Nie" YESC="Tak (kliknij aby wyłączyć)" NOC="Nie (kliknij aby włączyć)" LIGHTBG="light - jasne tło" DARKBG="dark - ciemne tło" ;; *) TITLE="Wallpaper Changer" NITROGEN="Nitrogen" WALLPAPERS="Wallpapers" RANDWALL="Random Wallpaper" EDIT_WPDIRS="Edit Wallpaper dirs" GENERATOR="Generate (ImageMagick)..." CHOOSE="Choose Wallpaper..." SLIDESHOW="Slideshow" STARTS="Start Slideshow (stopped)" STOPS="Stop Slideshow (running - interval: $interval sec.)" CONF="Configuration" WALLDIR="Images dir" INTERVAL="Slideshow Interval" SEC="seconds" EDITCONF="Edit config file" OPENDIR="Open wallpaper directory" LEFTPANEL="Left panel" OBTHEME="Openbox Theme" MENUPANELS="Menus/Panels" AUTOGEN_THEMES="Auto theming - based on wallp colors" GENERATETHEMES="Generate themes on wallpaper change?" GENOB="Colorize Window Decorations?" GENMENU="Colorize Menus and Panels?" GENCONKY="Colorize Conky?" GENPYRADIO="Colorize PyRadio?" YES="Yes" NO="No" YESC="Yes (click to disable)" NOC="No (click to enable)" LIGHTBG="with light background" DARKBG="with dark background" ;; 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+=("󰉔 $CHOOSE,pcmanwp") out+=(" $RANDWALL,mbwallpaper -o;$me") #out+=("$GENERATOR,^pipe(jgwallpapergenerate)") out+=("󰧸 $SLIDESHOW,^checkout(sshow)") out+=("^sep()") out+=(" $EDIT_WPDIRS,xdg-open $CNF_FILE") [[ "$wall2themes" = "yes" ]] && out+=(" $AUTOGEN_THEMES,^checkout(colsettings)") || out+=(" $AUTOGEN_THEMES,^checkout(colsettings)") else out+=("$STOPS,killall mbwallpaper;pkill -f 'yad --not';$me") fi out1+=("^tag(sshow)") out1+=("^sep($SLIDESHOW)") out1+=("$STARTS,run_wallpaperslideshow;$me") out1+=("\"\"\"$WALLDIR: [ $wallpaper_dir ]\"\"\",xdg-open $CONFIG_FILE") out1+=("$INTERVAL [ $interval ] ($SEC),^checkout(interval)") out1+=("^sep()") out1+=(" $EDITCONF ,xdg-open $CONFIG_FILE") out1+=(" $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 " %4s,%s" "$i" "mb-setvar interval=${i} $CONFIG_FILE;$me")");done # COLORIZER_CONF SUBMENU out1+=("^tag(colsettings)") out1+=("^sep($GENERATETHEMES)") [[ "$wall2themes" = "yes" ]] && out1+=(" $YESC,mb-setvar wall2themes=no $COLORIZER_CONF;$me") || out1+=(" $NOC,mb-setvar wall2themes=yes $COLORIZER_CONF;$me") out1+=("^sep()") out1+=("$OBTHEME [ ${wall2themes_ob} ],^checkout(ob)") out2+=("^tag(ob)") out2+=("^sep($GENOB)") out2+=("$NO,mb-setvar wall2themes_ob=none $COLORIZER_CONF;$me") out2+=("^sep()") out2+=("$LIGHTBG,mb-setvar wall2themes_ob=light $COLORIZER_CONF;$me") out2+=("$DARKBG,mb-setvar wall2themes_ob=dark $COLORIZER_CONF;$me") out1+=("$MENUPANELS [ ${wall2themes_menu} ],^checkout(mp)") out2+=("^tag(mp)") out2+=("^sep($GENMENU)") out2+=("$NO,mb-setvar wall2themes_menu=none $COLORIZER_CONF;$me") out2+=("^sep()") out2+=("$LIGHTBG,mb-setvar wall2themes_menu=light $COLORIZER_CONF;$me") out2+=("$DARKBG,mb-setvar wall2themes_menu=dark $COLORIZER_CONF;$me") out1+=("Conky [ ${wall2themes_conky} ],^checkout(conky)") out2+=("^tag(conky)") out2+=("^sep($GENCONKY)") out2+=("$NO,mb-setvar wall2themes_conky=none $COLORIZER_CONF;$me") out2+=("^sep()") out2+=("$LIGHTBG,mb-setvar wall2themes_conky=light $COLORIZER_CONF;$me") out2+=("$DARKBG,mb-setvar wall2themes_conky=dark $COLORIZER_CONF;$me") out1+=("PyRadio [ ${wall2themes_pyradio} ],^checkout(pyradio)") out2+=("^tag(pyradio)") out2+=("^sep($GENPYRADIO)") out2+=("$NO,mb-setvar wall2themes_pyradio=none $COLORIZER_CONF;$me") out2+=("^sep()") out2+=("$LIGHTBG,mb-setvar wall2themes_pyradio=light $COLORIZER_CONF;$me") out2+=("$DARKBG,mb-setvar wall2themes_pyradio=dark $COLORIZER_CONF;$me") ### RUN if [[ $1 == "-s" || $1 == "-c" || $1 == "-u" || $1 == "ipc" ]]; 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");; ipc) POSITION_MODE=${1:-fixed} 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") ;; 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' "${out1[@]}") $(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' "${out1[@]}" printf '%s\n' "${out2[@]}" } case "$1" in lclick) lclick;; *) main "$@";; esac