Hi @napcok,
- I added the function: Set Wallpaper directory(first or second display’s) For my own pleasure…
- And added a file count when loading the entries. I have set it to 100 items. (Could be more probably)
IDEA=“Adding a file count to jgbrowser, for speeding up loading time.”
WHY?
Of course i am crazy with sometimes more than 5000 of (anim)images in one wallpaper directory.
When i used the menu to go to a folder it took ages to load.
I don’t necessarily need to scroll to a picture, only able to choose the directory to set wallpaper path.
For my other stuff i don’t have more than 100 items in a folder.
What do you think of the “$IDEA”.
Or (fancy)… at the bottom … next page of X files.
Jgbrowser: edited version…
#!/usr/bin/env bash
# Daniel Napora 2020 - 2023 <napcok@gmail.com>
# Set the maximum number of files to load.
MAX_FILES=100
. "$HOME"/.config/mabox/mabox.conf
CONFIG_DIR="$HOME/.config/mbwallpaper"
CONF_FILE="$CONFIG_DIR/mbwallpaper.conf"
CONF_FILE2="$CONFIG_DIR/mbwallpaper2mon.conf"
source <(grep = "$CONF_FILE")
case $LANG in
pl*)
DIRECTORIES="Katalogi"
FILES="Pliki"
ADDBOOKMARK="Dodaj do zakładek"
OPENDIR="Otwórz w menadżerze plików"
OPENTERM="Otwórz w terminalu"
;;
es*)
DIRECTORIES="Directorios"
FILES="Archivos"
ADDBOOKMARK="Agregar a marcadores"
OPENDIR="Abrir Gestor de archivos aquí"
OPENTERM="Abrir terminal aquí"
;;
*)
DIRECTORIES="Directories"
FILES="Files"
ADDBOOKMARK="Add to Bookmarks"
OPENDIR="Open filemanager here"
OPENTERM="Open terminal here"
SET_WDIR="Set wallpaper dir for 0"
SET_WDIR2="Set wallpaper dir for 1"
;;
esac
: "${JGMENU_RESOURCE_OPENER="xdg-open"}"
DIRECTORY=${1:-$HOME}
# If '$DIRECTORY' is '/', unset it to avoid '//'.
[[ $DIRECTORY == / ]] && DIRECTORY=
if [ "$jgbrowser_show_hidden" == false ]; then
count=0 # Counter to keep track of processed items
for item in "$DIRECTORY"/*; do
if [[ -d $item ]]; then
dirs+=("${item##*/},^pipe(jgbrowser \"$DIRECTORY/${item##*/}\")")
else
if [[ -f $item ]]; then
files+=("${item##*/},xdg-open \"$DIRECTORY/${item##*/}\"")
((count++))
fi
fi
# Check if the maximum number of files has been reached
if [ $count -eq $MAX_FILES ]; then
break
fi
done
else
count=0
for item in "$DIRECTORY"/* "$DIRECTORY"/.[^.]*; do
if [[ -d $item ]]; then
dirs+=("${item##*/},^pipe(jgbrowser \"$DIRECTORY/${item##*/}\")")
else
if [[ -f $item ]]; then
files+=("${item##*/},xdg-open \"$DIRECTORY/${item##*/}\"")
((count++))
fi
fi
if [ $count -eq $MAX_FILES ]; then
break
fi
done
fi
printf "%b\n" "^sep(<small><i>${DIRECTORY:-/}</i></small>)"
printf "%b\n" " ${ADDBOOKMARK},\"\"\"echo \" ${DIRECTORY##*/},^pipe(jgbrowser ${DIRECTORY:-/})\" >> $HOME/.config/mabox/places.csv;mb-places -s\"\"\""
printf "%b\n" "^sep()"
printf "%b\n" " $SET_WDIR,awk -v newdir='${DIRECTORY:-/}' '/^wallpaper_dir=/{\$1=\"wallpaper_dir=\"newdir}1' $CONF_FILE > $CONF_FILE.tmp && mv $CONF_FILE.tmp $CONF_FILE ; "
printf "%b\n" " $SET_WDIR2,awk -v newdir='${DIRECTORY:-/}' '/^wallpaper_dir2=/{\$1=\"wallpaper_dir2=\"newdir}1' $CONF_FILE2 > $CONF_FILE2.tmp && mv $CONF_FILE2.tmp $CONF_FILE2"
printf "%b\n" "^sep()"
printf "%b\n" " $OPENDIR,${JGMENU_RESOURCE_OPENER} \"${DIRECTORY:-/}\""
printf "%b\n" "<big></big> $OPENTERM,exo-open --launch TerminalEmulator --working-directory=\"${DIRECTORY:-/}\""
#printf "%b\n" " $OPENTERM,terminator --working-directory=\"${DIRECTORY:-/}\""
if [ ${#dirs[@]} -ne 0 ]; then
printf "%b\n" "^sep($DIRECTORIES <small>(${#dirs[@]})</small>)"
printf "%s\n" "${dirs[@]/&/&}"
fi
if [ ${#files[@]} -ne 0 ]; then
printf "%b\n" "^sep($FILES <small>(${#files[@]})</small>)"
#printf "%s\n" "${files[@]}"
#okfiles=("${files[@]/</ <}")
printf "%s\n" "${files[@]/&/&}"
fi
Side question: about mb-setvar
.
I tried something like this:
`printf "%b\n" " Set Wallpaper dir 1,mb-setvar wallpaper_dir='${DIRECTORY:-/}' $CONF_FILE"`
This did’t work. That’s why i changed it to awk
.
But i rather use ‘mb-setvar’. (nice and short)
What can i do to use mb-setvar instead.